beautypg.com

Serial programming algorithm, Atmega163(l) – Rainbow Electronics ATmega163L User Manual

Page 133

background image

ATmega163(L)

133

Figure 86. Serial Programming and Verify

When programming the EEPROM, an auto-erase cycle is built into the self-timed programming 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 $1FFF for Program memory and $0000 to $01FF for EEPROM memory.

Either an external system clock is supplied at pin XTAL1 or a crystal needs to be connected across pins XTAL1 and
XTAL2.The minimum low and high periods for the serial clock (SCK) input are defined as follows:

Low: > 2 XTAL1 clock cycle

High: > 2 XTAL1 clock cycles

Serial Programming Algorithm

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

When reading data from the ATmega163, data is clocked on the falling edge of SCK. See Figure 87, Figure 88 and Table
61
for timing details.

To program and verify the ATmega163 in the serial programming mode, the following sequence is recommended (See four
byte instruction formats in Table 60):

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’. If a crys-

tal is not connected across pins XTAL1 and XTAL2, apply a clock signal to the XTAL1 pin. In some systems, the
programmer can not guarantee that SCK is held low during power-up. In this case, wait for 100 ms after SCK has been
set to ‘0’. RESET must be then given a positive pulse of at least two XTAL1 cycles duration and then set to ‘0’.

2.

Wait for at least 20 ms and enable serial programming by sending the Programming Enable serial instruction to pin
MOSI/PB5.

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 issuing the third byte of the Programming Enable instruction. Whether the
echo is correct or not, all 4 bytes of the instruction must be transmitted. If the $53 did not echo back, give SCK a

ATmega163

VCC

+5V

GND

XTAL1

PB6

PB7

PB5

SCK

MISO

MOSI

RESET