Serial programming algorithm, Atmega128(l) – Rainbow Electronics ATmega128L User Manual

Page 293

Advertising
background image

293

ATmega128(L)

2467B–09/01

Figure 143. Serial Programming and Verify

Note:

If the device is clocked by the internal oscillator, it is no need to connect a clock source to
the XTAL1 pin.

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.

Depending on CKSEL Fuses, a valid clock must be present. The minimum low and high
periods for the serial clock (SCK) input are defined as follows:

Low:> 2 CPU clock cycles for f

ck

< 12 MHz, 3 CPU clock cycles for f

ck

≥ 12 MHz

High:> 2 CPU clock cycles for f

ck

< 12 MHz, 3 CPU clock cycles for f

ck

≥ 12 MHz

Serial Programming
Algorithm

When writing serial data to the ATmega128, data is clocked on the rising edge of SCK.

When reading data from the ATmega128, data is clocked on the falling edge of SCK.
See

Figure 144, Figure 145 and Table 145 for timing details.

To program and verify the ATmega128 in the serial programming mode, the following
sequence is recommended (See four byte instruction formats in

Table 144):

1.

Power-up sequence:
Apply power between V

CC

and GND while RESET and SCK are set to “0”. 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
CPU clock cycles duration after SCK has been set to “0”.
As an alternative to using the RESET signal, PEN can be held low during Power-
on Reset while SCK is set to “0”. In this case, only the PEN value at Power-on
Reset is important. If the programmer cannot guarantee that SCK is held low
during power-up, the PEN method cannot be used. The device must be powered
down in order to commence normal operation when using this method.

2.

Wait for at least 20 ms and enable serial programming by sending the Program-
ming Enable serial instruction to pin MOSI.

3.

The serial programming instructions will not work if the communication is out of
synchronization. When in sync. the second byte ($53), will echo back when issu-

VCC

GND

XTAL1

SCK

PDO

PDI

RESET

PE0

PE1

PB1

+2.7 - 5.5V

Advertising