
5
0943E–AVR–08/08
AVR910
SCK pin stable, as one single edge will cause the target to loose synchronization with the pro-
grammer. For other devices use the synchronization algorithm specified in the datasheet. After
pulling Reset low, wait at least 20 ms before issuing the first command.
Command Format
All commands have a common format consisting of four bytes. The first byte contains the com-
mand code, selecting operation and target memory. The second and third byte contain the
address of the selected memory area. The fourth byte contains the data, going in either
direction.
The data returned from the target is usually the data sent in the previous byte. Table 3 shows an
example, where two consecutive commands are sent to the target. Notice how all bytes returned
equal the bytes just received. Some commands return one byte from the target’s memory. This
byte is always returned in the last byte (byte 4). Data is alwa‘ys sent on MOSI and MISO lines
with most significant bit (MSB) first.
For details on available instructions, please refer to the Serial Programming section of the
datasheet.
Enable Memory
Access
When the Reset pin is first pulled active, the only instruction accepted by the SPI interface is
“Programming Enable”. Only this command will open for access to the Flash and EEPROM
memories, and without this access, any other command issued will be ignored. Table 3 shows
an example where memory access is enabled in the first command sent to the chip.
After a “Programming Enable” command has been sent to the target, access is given to the non-
volatile memories of the chip according to the current setting of the protecting Lock bits.
The target AVR microcontroller will not respond with an acknowledge to the “Programming
Enable” command. To check if the command has been accepted by the target AVR microcon-
troller, the device code could be read. The device code is also known as the signature bytes.
Device Code
After the “Programming Enable” command has been successfully read by the SPI interface, the
programmer can read the device code. The device code will identify the chip vendor (Atmel), the
part family (AVR), Flash size in kilobytes, and family member (i.e., AT90S1200). The “Read
Device Code” command format is found in the Serial Programming section of the datasheet. As
an example, this command will, for the AT90S1200, be [$30, $XX, $adr, $code]. Valid addresses
are $00, $01 and $02. Table 4 shows what the expected result will be.
.
Table 5 indicates that Device Code will sometimes read as $FF. If this happens, the part device
code has not been programmed into the device. This does not indicate an error, but the part has
to be manually identified to the programmer.
Device code $FF might also occur if there is no target ready or if the MISO line is constantly
pulled high. The programmer can detect this situation by detecting that also a command sent to
the target is returned as $FF.
If the target reports Vendor Code $00, Part Family $01, and Part Number $02, both Lock bits
have been set. This prevents the memory blocks from responding, and the valued returned will
be the byte just received from the programmer, which just happens to be the current address. To
erase the Lock bits, it is necessary to perform a valid “Chip Erase”.
Table 3. Example, Enabling Memory Access and Erasing the Chip
Action
MOSI, Sent to
Target AVR
MISO, Returned from
Target AVR
Programming Enable
$AC 53 xx yy
$zz AC 53 xx
Read Device Code $1E at Address $00
$30 nn 00 mm
$yy 30 nn 1E