In some devices there is no method to detect when the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: emory Page” command. In some devices, there is no method to detect when the Flash write cycle has ended. For this reason, the programmer presented in this application note waits N ms before attempting to send another command to the interface (the delay N will depend on target device, and can be found in the programming section of the datasheet). For some devices it is possible to use polling. When a byte is being programmed into the Flash or EEPROM, reading the addressed location being programmed will give a value M (often $FF). At the time the device is ready for a new byte, the programmed value will read correctly. This can be used to determine when the next byte can be written. When programming the value M polling will not work, and a delay N should be used before writing the next value. Polled mode will decrease the time required to program a device. Table 7. Example, Reading “add r16,r17” as $0F01 From Flash Memory Location $104 MOSI, Sent to Target AVR MISO, Returned from Target AVR Read $01 at address $104, low byte $20 01 04 xx $zz 20 01 01 Read $0F at address $104, high byte $28 01 04 yy $xx 28 01 0F Action 7 0943E–AVR–08/08 Table 8. Example, Writing “add r17,r18” as $0F12 to Flash Memory Location $10C (Byte Programming Mode) Action MOSI, Sent to Target AVR MISO, Returned from Target AVR Write $12 at address $10C, low byte $60 01 0C 12 $zz 60 01 0C $68 01 0C 0F $xx 68 01 0C Wait N ms Write $0F at address $10C, high byte Wait N ms EEPROM Data Memory Access Using the “Read EEPROM Data Memory” command, EEPROM contents can be read one byte at a time. The command sends a memory address ($aa bb) to select a byte location in the EEPROM. Table 9. Example, Reading $ab From EEPROM Location $3F Action Read $ab at address $3F MOSI, Sent to Target AVR MISO, Returned from Target AVR $A0 00 3F xx $zz A0 00 AB EEPROM is written one byte at a time, with the “Write EEPROM Memory” command. This command selects the byte to write just like “Read EEPROM Memory”, and transfers the data to be written in the last byte sent to the target. For some devices there is no method to detect when the write cycle has ended. The programmer should simply wait N ms before attempting to send another command to the interface (the delay N will depend on target device, and can be found in the programming section of the datasheet). For increased programming speed, polling can be used as described in the “Flash Program Memory Access” section. An example of an EEPROM Write is shown in Table 10. Table 10. Example, Writing $0F to EEPROM Location $11 Action MOSI, Sent to Target AVR MISO, Returned from Target AVR Write $0F at address $11 $C0 00 11 0F $zz C0 00 11 Wait N ms Lock Bits Access To protect memory contents from being accidentally overwritten, or from unauthorized reading, the Lock bits can be set to protect the memory contents. As shown on Table 11, the memories can be either protected from further writing, or you may completely disable both reading and w...
View Full Document

Ask a homework question - tutors are online