3.10.12.5 In-System Programming

Both the Flash and EEPROM memory arrays can be programmed using the serial SPI bus while NRESET is pulled to GND. This serial programming mode is called in-system programming (ISP). The interface consists of the pins SCK, MOSI (input) and MISO (output) as depicted in the following figure.

Figure 3-95. ISP Connection
Table 3-113. Pin Mapping in ISP Programming Mode

Symbol

Pins

I/O

Description

MOSI

PB2

I

Serial data in

MISO

PB3

O

Serial data out

SCK

PB1

I

Serial clock

ISP is disabled if either the DWEN or the RSTDISBL fuse is programmed (set to logic ‘0’) or if the SPIEN fuse is unprogrammed (set to logic ‘1’).

Furthermore, the AVR system must run with a valid clock. The maximum frequency of the SCK clock is CLKSYS/4.

When programming the EEPROM, an auto-erase cycle is built into the self-timed programming operation and there is no need to first execute the CHIP ERASE instruction. The CHIP ERASE operation changes the content of every memory location in both the program and EEPROM arrays to 0xFF.

ISP Programming Algorithm

When writing serial data to the ATA8510/15, the data is clocked on the rising edge of SCK. When reading data from the ATA8510/15, the data is clocked on the falling edge of SCK.

To program and verify the ATA8510/15 in the in-system programming mode, the following sequence is recommended (see 4-byte instruction formats in Table 3-115):

  1. Power-up sequence: Apply power between VS and GND while NRESET and SCK are set to ‘0’. In some systems, the programmer cannot ensure that SCK is held LOW during power-up. In this case, NRESET must be given a positive pulse of at least two CPU clock cycles duration after SCK is set to ‘0’.
  2. Wait for at least 400 µs; then, enable ISP by sending the PROGRAMMING ENABLE instruction to pin MOSI.
  3. The ISP instructions do not work if the communication is out of synchronization. While being synchronized, the second byte (0x53) echoes back while the third byte of the PROGRAMMING ENABLE instruction is being issued. Whether the echo is correct or not, all four bytes of the instruction must be transmitted. If the 0x53 did not echo back, give NRESET a positive pulse and issue a new PROGRAMMING ENABLE command.
  4. The Flash is programmed one page at a time. The memory page is loaded one byte at a time by supplying the 4 LSB of the address and data together with the LOAD PROGRAM MEMORY PAGE instruction. To ensure correct loading of the page, the data low byte must be loaded before data high byte is applied for a given address. The Program Memory page is stored by loading the WRITE PROGRAM MEMORY PAGE instruction with the 11 MSB of the address. If polling (nRDY/BSY) is not used, the user must wait at least tWD_FLASH before issuing the next page (see the following table). Accessing the ISP interface before the Flash write operation completes can result in incorrect programming.
  5. Two programming modes are available for the EEPROM:
    1. The EEPROM array is programmed one byte at a time by supplying the address and data together with the WRITE EEPROM MEMORY instruction. An EEPROM memory location is always automatically erased before new data is written. If polling (nRDY/BSY) is not used, the user must wait at least tWD_EEPROM before issuing the next byte (see Table 3-114). In a chip erased device, no 0xFFs in the data file(s) need to be programmed.
    2. The EEPROM array is programmed one page at a time. The memory page is loaded one byte at a time by supplying Table 3-114, the 3 LSB of the address and data together with the LOAD EEPROM MEMORY PAGE instruction. The EEPROM memory page is stored by loading the WRITE EEPROM MEMORY PAGE instruction with the 7 MSB of the address. When using EEPROM page access, only byte locations loaded with the LOAD EEPROM MEMORY PAGE instruction are altered. The remaining locations remain unchanged. If polling (nRDY/BSY) is not used, the user must wait at least tWD_EEPROM before issuing the next page (see Table 3-114). In a chip erased device, no 0xFF in the data file(s) needs to be programmed.
  6. Any memory location can be verified by using the READ instruction, which returns the content of the selected address at the serial output MISO.
  7. At the end of the programming session, NRESET can be set high to commence normal operation.
  8. If a power-off sequence is required, the following procedure is followed:
    • Set NRESET to ‘1’.
    • Turn VCC power off.
Table 3-114. Minimum Wait Delay Prior to Writing Next Flash or EEPROM Location

Symbol

Minimum Wait Delay

tWD_FLASH

5 ms

tWD_EEPROM (including erase time)

10 ms

tWD_ERASE (chip erase)

10 ms

tWD_FUSE

5 ms

ISP Instruction Overview

Table 3-115. ISP Instruction Overview

Instruction/Operation

Instruction Format

Comment

Byte 1

Byte 2

Byte 3

Byte 4

General Instructions

ISP Programming Enable

0xAC

0x53

0x00

0x00

Enable ISP after NRESET goes LOW

Chip Erase

0xAC

0x80

0x00

0x00

Chip erase (program memory/EEPROM/lock bits)

Poll nRDY/BSY

0xF0

0x00

0x00

data_byte_out

If LSB of data_byte_out = 1, the previous programming operation is still pending. Wait until this bit returns to ‘0’ before sending the next instruction.

Load Instructions

Load Program Memory Page High Byte

0x48

adr MSB

adr LSB

high_data_byte_in

Load program memory page buffer (high byte)

Load Program Memory Page Low Byte

0x40

adr MSB

adr LSB

low_data_byte_in

Load program memory page buffer (low byte)

Load EEPROM Memory Page (page access)

0xC1

0x00

0000

aaaa (1)

data_byte_in

Load EEPROM data memory page buffer

Write Instructions

Write Program Memory Page

0x4C

adr MSB

adr LSB

0x00

Writes program memory page

(with values loaded into the program memory page buffer)

Write EEPROM Memory

0xC0

0000

0aaa (1)

aaaa aaaa (1)

data_byte_in

Write data to EEPROM memory address (no page access)

Write EEPROM Memory Page (page access)

0xC2

0000

0aaa (1)

aaaa

0000 (1)

0x00

Write EEPROM memory page

(with values loaded into the EEPROM data memory page buffer)

Write Lock Bits

0xAC

0xE0

0x00

data_byte_in

Write lock bits (‘0’ means programmed)

Write Fuse Low Byte

0xAC

0xA0

0x00

data_byte_in

Write fuse low byte (‘0’ means programmed)

Read Instructions

Read Program Memory, High Byte

0x28

adr MSB

adr LSB

high_data_byte _out

Read high byte from program memory at address

Read Program Memory, Low Byte

0x20

adr MSB

adr LSB

low_data_byte _out

Read low byte from program memory at address

Read EEPROM Memory

0xA0

0000

0aaa (1)

aaaa aaaa (1)

data_byte_out

Read data from EEPROM data memory

Read Lock Bits

0x58

0x00

0x00

data_byte_out

Read lock bits

0 = programmed

1 = unprogrammed

Read Fuse Low Byte

0x50

0x00

0x00

data_byte_out

Read fuse low byte

0 = programmed

1 = unprogrammed

Read Signature Byte

0x30

0x00

0000

00aa (1)

data_byte_out

Read signature byte no. aa (signature address 0, 1, 2)

Note: a = Address
Figure 3-96. ISP Programming Instruction Example