
190
ATmega8515(L)
2512A–AVR–04/02
Serial Programming
Algorithm
When writing serialdatatothe ATmega8515,data isclocked on the rising edge ofSCK.
When reading data from the ATmega8515,data isclocked on the falling edge ofSCK.
See Figure84,Figure85, and Table 95 for timing details.
To program and verify the ATmega8515 in the Serial Programming mode, the following
sequenceisrecommended(See fourbyte instruction formats in Table 94.):
1. Power-upsequence:
Apply powerbetween V
CC
and GND whileRESET andSCKare set to “0”. In
some systems, the programmercan not guarantee that SCK isheld lowduring
Power-up. Inthiscase, RESET
must begivenapositive pulseof at leasttwo
CPUclock cyclesduration afterSCKhasbeen set to “0”.
2. Wait for at least20ms and enable serialprogramming by sending theProgram-
ming Enable serial instruction to pin MOSI.
3.The Serial Programming instructionswill not work if the communication is out of
synchronization. When in synchronization, the secondbyte ($53), will echo back
when issuing thethird byte of theProgramming Enableinstruction. Whether the
echoiscorrector not, all fourbytes of theinstruction must betransmitted. If the
$53did not echo back, give RESET
a positive pulseand issueanew Program-
ming Enable command.
4. The Flash isprogrammed one page at a time. Thememory page isloaded one
byte at a time by supplying the5LSB of theaddress anddata togetherwith the
Load Program Memory Page instruction. To ensure correct loading of the page,
the data lowbyte must be loadedbefore data highbyte is appliedfor agiven
address.TheProgram Memory Page isstoredbyloading the Write Program
Memory Page instruction with the 7MSBof theaddress. If polling is not used,
theuser must wait at leastt
WD_FLASH
beforeissuing thenext page,see Table 93.
Accessing the serialprogramming interface beforethe Flash write operation
completescan resultinincorrect programming.
5. The EEPROM array isprogrammed one byte at a time by supplying theaddress
anddata togetherwith theappropriate Write instruction. An EEPROM memory
location isfirst automatically erasedbeforenewdata iswritten. If polling is not
used, theuser must wait at leastt
WD_EEPROM
beforeissuing thenext byte,see
Table 93. Inachip eraseddevice, no $FFs in the data file(s) need to be
programmed.
6.Any memory location can beverifiedbyusing theRead instruction which returns
the content at the selected address at serial output MISO.
7.Attheend of the programming session, RESET
can be set high to commence
normal operation.
8. Power-off sequence (if needed):
Set RESET
to “1”.
Tu rnV
CC
power off.
Data Polling Flash When a page isbeing programmed into the Flash, reading an address location within
the page being programmedwill give thevalue $FF.Atthetimethe deviceisready for a
newpage, the programmed value will readcorrectly.This is used to determine when the
next page can be written. Note that theentire page iswritten simultaneously and any
address within the page can beusedforpolling. Data polling of the Flash will not work
for thevalue $FF, so when programming this value, theuserwill have to wait for at least
t
WD_FLASH
before programming thenext page. As a chip eraseddevice contains$FFin
all locations, programming of addresses that are meant to contain $FF, can be skipped.
See Table 93 for t
WD_FLASH
value.
Kommentare zu diesen Handbüchern