; ----------------------------------------------------------------------------- ; Example programming instructions for ISPnub (http://www.fischl.de/ispnub/) ; ; Instructions for ATmega32A. See ATmega-datasheet for more information about ; single spi instructions. ; ; This is an enhanced example which uses clock switching to speed up the ; programming process. After programming the clock is set back to 4 MHz. ; ; ----------------------------------------------------------------------------- ; ----------------------------------------------------------------------------- ; Check chip signature and set fuses to internal 8MHz, so we can use high sck ; ----------------------------------------------------------------------------- CONNECT 62500 ; connect with SCK = 62.5 kHz SPIVERIFY 0x30, 0x00, 0x00, 0x00, 0x1E ; check signature byte 0x00 (0x1E = manufactured by Atmel) SPIVERIFY 0x30, 0x00, 0x01, 0x00, 0x95 ; check signature byte 0x01 (0x95 = 32KB Flash memory) SPIVERIFY 0x30, 0x00, 0x02, 0x00, 0x02 ; check signature byte 0x02 (0x02 = ATmega32A device) SPIWRITE 0xAC, 0x80, 0x00, 0x00 ; chip erase WAIT 1 ; wait 10 ms SPIWRITE 0xAC, 0xA0, 0x00, 0x24 ; write fuse bits (use internal 8 MHz) WAIT 1 ; wait 10 ms SPIVERIFY 0x50, 0x00, 0x00, 0x00, 0x24 ; check fuse bits SPIWRITE 0xAC, 0xA8, 0x00, 0xD9 ; write high fuse bits WAIT 1 ; wait 10 ms SPIVERIFY 0x58, 0x08, 0x00, 0x00, 0xD9 ; check high fuse bits DISCONNECT ; ----------------------------------------------------------------------------- ; Write eeprom and flash ; ----------------------------------------------------------------------------- CONNECT 2000000 ; connect with SCK = 2 MHz SPIWRITE 0xC0, 0x00, 0x00, 0x12 ; write eeprom WAIT 1 SPIVERIFY 0xA0, 0x00, 0x00, 0x00, 0x12 ; verify eeprom SPIWRITE 0xC0, 0x00, 0x01, 0x34 ; write eeprom WAIT 1 SPIVERIFY 0xA0, 0x00, 0x01, 0x00, 0x34 ; verify eeprom SPIWRITE 0xC0, 0x00, 0x02, 0x56 ; write eeprom WAIT 1 SPIVERIFY 0xA0, 0x00, 0x02, 0x00, 0x56 ; verify eeprom SPIWRITE 0xC0, 0x00, 0x03, 0x78 ; write eeprom WAIT 1 SPIVERIFY 0xA0, 0x00, 0x03, 0x00, 0x78 ; verify eeprom FLASH main.hex, 0, 64 ; flash hex file starting at address 0 with pagesize 64 DISCONNECT ; disconnect SPI ; ----------------------------------------------------------------------------- ; Set correct clock option and write lock bits ; ----------------------------------------------------------------------------- CONNECT 62500 ; connect with SCK = 62.5 kHz SPIWRITE 0xAC, 0xA0, 0x00, 0x2E ; write fuse bits WAIT 1 ; wait 10 ms SPIVERIFY 0x50, 0x00, 0x00, 0x00, 0x2E ; check fuse bits SPIWRITE 0xAC, 0xE0, 0x00, 0xFC ; write lock bits WAIT 1 ; wait 10 ms SPIVERIFY 0x58, 0x00, 0x00, 0x00, 0xFC ; check lock bits DISCONNECT ; ----------------------------------------------------------------------------- ; Decrement counter and exit ; ----------------------------------------------------------------------------- DECCOUNTER 100 ; decrement cycle counter (allow 100 programming cycles) END