Programming the flash – Rainbow Electronics ATmega103L User Manual

Page 96

Advertising
background image

ATmega603/103

96

Programming The Flash

The Flash is organized as 256/512 pages of 256 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)

4.

Give XTAL1 a positive pulse. This loads the address low byte.

C: Load Data Low Byte

1.

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

2.

Set XA1, XA0 to ‘01’. This enables data loading.

3.

Set DATA = Data low byte ($00 - $FF)

4.

Give XTAL1 a positive pulse. This loads the data byte.

D: Latch Data Low byte

Give PAGEL a positive pulse, This latches the data low byte.

(See Figure 73 for signal waveforms.)

E: Load Data High Byte

1.

Set BS1 to ‘1’. This selects high data.

2.

Set XA1, XA0 to ‘01’. This enables data loading.

3.

Set DATA = Data high byte ($00 - $FF)

4.

Give XTAL1 a positive pulse. This loads the data high byte.

F: Latch Data High Byte

Give PAGEL a positive pulse. This latches the data high byte.

G: Repeat B through F 128 times to fill the page buffer

H: Load Address High Byte

1.

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

2.

Set BS1 to ‘1’. This selects high address.

3.

Set DATA = Address high byte ($00-$7F/$FF).

4.

Give XTAL1 a positive pulse. This loads the address high byte.

I: Program Page

1.

Give WR a negative pulse. This starts programming of the entire page of data. RDY/BSY goes low.

2.

Wait until RDY/BSY goes high.

(See Figure 74 for signal waveforms.)

J: End Page Programming

1.

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

2.

Set DATA = ‘0000 0000’. This is the command for No Operation.

3.

Give XTAL1 a positive pulse. This loads the command and the internal write signals are reset.

Advertising