beautypg.com

Enter programming mode, Chip erase, Programming the flash – Rainbow Electronics ATmega163L User Manual

Page 126: Table 57, Atmega163(l)

background image

ATmega163(L)

126

Enter Programming Mode

The following algorithm puts the device in parallel programming mode:

1.

Apply 4.5 - 5.5V between V

CC

and GND.

2.

Set RESET and BS pins to ‘0’ and wait at least 100 ns.

3.

Apply 11.5 - 12.5V to RESET. Any activity on BS1 within 100 ns after +12V has been applied to RESET, will cause
the device to fail entering programming mode.

Chip Erase

The Chip Erase command will erase the Flash and EEPROM memories and the Lock bits. The Lock bits are not reset until
the program memory has been completely erased. The Fuse bits are not changed. A Chip Erase must be performed before
the Flash is reprogrammed.

Load Command “Chip Erase”

1.

Set XA1, XA0 to ‘10’. This enables command loading.

2.

Set BS1 to ‘0’.

3.

Set DATA to ‘1000 0000’. This is the command for Chip Erase.

4.

Give WR a negative pulse. This starts the Chip Erase. RDY/BSY goes low.

5.

Wait until RDY/BSY goes high before loading a new command.

Programming the Flash

The Flash is organized as 128 pages of 128 bytes each. When programming the Flash, the program data is latched into a
page buffer. This allows one page of program data to be programmed simultaneously. The following procedure describes
how to program the entire Flash memory:

A. Load Command “Write Flash”

1.

Set XA1, XA0 to ‘10’. This enables command loading.

2.

Set BS1 to ‘0’.

3.

Set DATA to ‘0001 0000’. This is the command for Write Flash.

4.

Give XTAL1 a positive pulse. This loads the command.

B. Load Address Low byte

1.

Set XA1, XA0 to ‘00’. This enables address loading.

2.

Set BS1 to ‘0’. This selects low address.

3.

Set DATA = Address low byte ($00 - $FF).

Table 57. Command Byte Bit Coding

Command Byte

Command Executed

1000 0000

Chip Erase

0100 0000

Write Fuse Bits

0010 0000

Write Lock Bits

0001 0000

Write Flash

0001 0001

Write EEPROM

0000 1000

Read Signature Bytes

0000 0100

Read Fuse and Lock Bits

0000 0010

Read Flash

0000 0011

Read EEPROM