Datasheet
191
ATmega323(L)
1457E–11/01
Serial Downloading Both the Flash and EEPROM memory arrays can be programmed using the serial SPI
bus while RESET
is pulled to GND. The serial interface consists of pins SCK, MOSI
(input) and MISO (output). After RESET
is set low, the Programming Enable instruction
needs to be executed first before program/erase operations can be executed.
Figure 98. Serial Programming and Verify
When programming the EEPROM, an auto-erase cycle is built into the self-timed pro-
gramming operation (in the serial mode ONLY) and there is no need to first execute the
Chip Erase instruction. The Chip Erase operation turns the content of every memory
location in both the Program and EEPROM arrays into $FF.
The Program and EEPROM memory arrays have separate address spaces:
$0000 to $3FFF for Program memory and $0000 to $03FF for EEPROM memory.
The device can be clocked by any clock option during Low Voltage Serial Programming.
The minimum low and high periods for the serial clock (SCK) input are defined as
follows:
Low: > 2 CPU clock cycles
High: > 2 CPU clock cycles
Serial Programming
Algorithm
When writing serial data to the ATmega323, data is clocked on the rising edge of SCK.
When reading data from the ATmega323, data is clocked on the falling edge of SCK.
See Figure 99, Figure 100 and Table 70 for timing details.
To program and verify the ATmega323 in the serial programming mode, the following
sequence is recommended (See four byte instruction formats in Table 69
):
1. Power-up sequence:
Apply power between V
CC
and GND while RESET and SCK are set to “0”. The
RESET
and SCK are set to “0”. In accordance with the setting of CKSEL fuses,
apply a crystal/resonator, external clock or RC network, or let the device run on the
internal RC oscillator. In some systems, the programmer can not guarantee that
SCK is held low during power-up. In this case, RESET
must be given a positive
pulse of at least two XTAL1 cycles duration after SCK has been set to “0”.
2. Wait for at least 20 ms and enable serial programming by sending the Program-
ming Enable serial instruction to pin MOSI/PB5.
ATmega323
VCC
2.7 - 5.5V
GND
PB6
PB7
PB5
SCK
MISO
MOSI
RESET