Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ATmega128 datasheet.pdf
Скачиваний:
12
Добавлен:
09.02.2015
Размер:
6.34 Mб
Скачать

ATmega128

Virtual Flash Page

Read Register

Programming

Algorithm

Figure 150. Virtual Flash Page Load Register

STROBES

State

machine

TDI

ADDRESS

Flash

EEPROM

Fuses

Lock Bits

D

A

T

A

TDO

The Virtual Flash Page Read Register is a virtual scan chain with length equal to the number of bits in one Flash page plus 8. Internally the Shift Register is 8-bit, and the data are automatically transferred from the Flash data page byte by byte. The first eight cycles are used to transfer the first byte to the internal Shift Register, and the bits that are shifted out during these 8 cycles should be ignored. Following this initialization, data are shifted out starting with the LSB of the first instruction in the page and ending with the MSB of the last instruction in the page. This provides an efficient way to read one full Flash page to verify programming.

Figure 151. Virtual Flash Page Read Register

STROBES

State

machine

TDI

ADDRESS

Flash

EEPROM

Fuses

Lock Bits

D

A

T

A

TDO

All references below of type “1a”, “1b”, and so on, refer to Table 130.

314

2467X–AVR–06/11

ATmega128

Entering Programming 1. Enter JTAG instruction AVR_RESET and shift 1 in the Reset Register.

Mode

2.

Enter instruction PROG_ENABLE and shift 1010_0011_0111_0000 in the Programming

 

 

 

Enable Register.

Leaving Programming 1. Enter JTAG instruction PROG_COMMANDS.

Mode

2.

Disable all programming instructions by using no operation instruction 11a.

 

 

3.

Enter instruction PROG_ENABLE and shift 0000_0000_0000_0000 in the programming

 

 

Enable Register.

 

4.

Enter JTAG instruction AVR_RESET and shift 0 in the Reset Register.

Performing Chip Erase 1. Enter JTAG instruction PROG_COMMANDS.

2.Start chip erase using programming instruction 1a.

3.Poll for chip erase complete using programming instruction 1b, or wait for tWLRH_CE (refer to Table Note: on page 299).

Programming the

Before programming the Flash a Chip Erase must be performed. See “Performing Chip Erase”

Flash

on page 315.

 

1.

Enter JTAG instruction PROG_COMMANDS.

 

2.

Enable Flash write using programming instruction 2a.

 

3.

Load address high byte using programming instruction 2b.

 

4.

Load address low byte using programming instruction 2c.

 

5.

Load data using programming instructions 2d, 2e and 2f.

 

6.

Repeat steps 4 and 5 for all instruction words in the page.

 

7.

Write the page using programming instruction 2g.

 

8.

Poll for Flash write complete using programming instruction 2h, or wait for tWLRH (refer to

 

 

Table Note: on page 299).

 

9.

Repeat steps 3 to 7 until all data have been programmed.

A more efficient data transfer can be achieved using the PROG_PAGELOAD instruction:

1.Enter JTAG instruction PROG_COMMANDS.

2.Enable Flash write using programming instruction 2a.

3.Load the page address using programming instructions 2b and 2c. PCWORD (refer to Table 123 on page 291) is used to address within one page and must be written as 0.

4.Enter JTAG instruction PROG_PAGELOAD.

5.Load the entire page by shifting in all instruction words in the page, starting with the LSB of the first instruction in the page and ending with the MSB of the last instruction in the page.

6.Enter JTAG instruction PROG_COMMANDS.

7.Write the page using programming instruction 2g.

8.Poll for Flash write complete using programming instruction 2h, or wait for tWLRH (refer to Table Note: on page 299).

9.Repeat steps 3 to 8 until all data have been programmed.

315

2467X–AVR–06/11

ATmega128

Reading the Flash 1. Enter JTAG instruction PROG_COMMANDS.

2.Enable Flash read using programming instruction 3a.

3.Load address using programming instructions 3b and 3c.

4.Read data using programming instruction 3d.

5.Repeat steps 3 and 4 until all data have been read.

A more efficient data transfer can be achieved using the PROG_PAGEREAD instruction:

1.Enter JTAG instruction PROG_COMMANDS.

2.Enable Flash read using programming instruction 3a.

3.Load the page address using programming instructions 3b and 3c. PCWORD (refer to Table 123 on page 291) is used to address within one page and must be written as 0.

4.Enter JTAG instruction PROG_PAGEREAD.

5.Read the entire page by shifting out all instruction words in the page, starting with the LSB of the first instruction in the page and ending with the MSB of the last instruction in the page. Remember that the first 8 bits shifted out should be ignored.

6.Enter JTAG instruction PROG_COMMANDS.

7.Repeat steps 3 to 6 until all data have been read.

Programming the

Before programming the EEPROM a Chip Erase must be performed. See “Performing Chip

EEPROM

Erase” on page 315.

 

1.

Enter JTAG instruction PROG_COMMANDS.

 

2.

Enable EEPROM write using programming instruction 4a.

 

3.

Load address high byte using programming instruction 4b.

 

4.

Load address low byte using programming instruction 4c.

 

5.

Load data using programming instructions 4d and 4e.

 

6.

Repeat steps 4 and 5 for all data bytes in the page.

 

7.

Write the data using programming instruction 4f.

 

8.

Poll for EEPROM write complete using programming instruction 4g, or wait for tWLRH

 

 

(refer to Table Note: on page 299).

 

9.

Repeat steps 3 to 8 until all data have been programmed.

Note that the PROG_PAGELOAD instruction can not be used when programming the EEPROM

Reading the EEPROM 1. Enter JTAG instruction PROG_COMMANDS.

2.Enable EEPROM read using programming instruction 5a.

3.Load address using programming instructions 5b and 5c.

4.Read data using programming instruction 5d.

5.Repeat steps 3 and 4 until all data have been read.

Note that the PROG_PAGEREAD instruction can not be used when reading the EEPROM

316

2467X–AVR–06/11

ATmega128

Programming the

1.

Enter JTAG instruction PROG_COMMANDS.

Fuses

2.

Enable Fuse write using programming instruction 6a.

 

 

3.

Load data byte using programming instructions 6b. A bit value of “0” will program the cor-

 

 

responding fuse, a “1” will unprogram the fuse.

 

4.

Write Extended Fuse byte using programming instruction 6c.

 

5.

Poll for Fuse write complete using programming instruction 6d, or wait for tWLRH (refer to

 

 

Table Note: on page 299).

 

6.

Load data byte using programming instructions 6e. A bit value of “0” will program the cor-

 

 

responding fuse, a “1” will unprogram the fuse.

 

7.

Write Fuse high byte using programming instruction 6f.

 

8.

Poll for Fuse write complete using programming instruction 6g, or wait for tWLRH (refer to

 

 

Table Note: on page 299).

 

9.

Load data byte using programming instructions 6h. A “0” will program the fuse, a “1” will

 

 

unprogram the fuse.

 

10.

Write Fuse low byte using programming instruction 6i.

 

11.

Poll for Fuse write complete using programming instruction 6j, or wait for tWLRH (refer to

 

 

Table Note: on page 299).

Programming the Lock

1.

Enter JTAG instruction PROG_COMMANDS.

Bits

2.

Enable Lock bit write using programming instruction 7a.

 

 

3.

Load data using programming instructions 7b. A bit value of “0” will program the corre-

 

 

sponding lock bit, a “1” will leave the lock bit unchanged.

 

4.

Write Lock bits using programming instruction 7c.

 

5.

Poll for Lock bit write complete using programming instruction 7d, or wait for tWLRH (refer

 

 

to Table Note: on page 299).

Reading the Fuses

1.

Enter JTAG instruction PROG_COMMANDS.

and Lock Bits

2.

Enable Fuse/Lock bit read using programming instruction 8a.

 

 

3.

To read all Fuses and Lock bits, use programming instruction 8f.

 

 

To only read Extended Fuse byte, use programming instruction 8b.

 

 

To only read Fuse high byte, use programming instruction 8c.

 

 

To only read Fuse low byte, use programming instruction 8d.

 

 

To only read Lock bits, use programming instruction 8e.

Reading the Signature

1.

Enter JTAG instruction PROG_COMMANDS.

Bytes

2.

Enable Signature byte read using programming instruction 9a.

 

 

3.

Load address $00 using programming instruction 9b.

 

4.

Read first signature byte using programming instruction 9c.

 

5.

Repeat steps 3 and 4 with address $01 and address $02 to read the second and third

 

 

signature bytes, respectively.

Reading the

1.

Enter JTAG instruction PROG_COMMANDS.

Calibration Byte

2.

Enable Calibration byte read using programming instruction 10a.

 

 

3.

Load address $00 using programming instruction 10b.

 

4.

Read the calibration byte using programming instruction 10c.

317

2467X–AVR–06/11

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]