Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ATtiny104_Datasheet.pdf
Скачиваний:
0
Добавлен:
12.02.2026
Размер:
3.8 Mб
Скачать

SRAM Data Memory on page 27

NVMCSR on page 196

NVMCMD on page 197

20.4.1.Addressing the Flash

The data space uses byte accessing but since the Flash sections are accessed as words and organized in pages, the byte-address of the data space must be converted to the word-address of the Flash section.

The most significant bits of the data space address select the NVM Lock bits or the Flash section mapped to the data memory. The word address within a page (WADDR) is held by bits [WADDRMSB:1], and the page address (PADDR) by bits [PADDRMSB:WADDRMSB+1]. Together, PADDR and WADDR form the absolute address of a word in the Flash section.

The least significant bit of the Flash section address is used to select the low or high byte of the word.

Figure 20-1. Addressing the Flash Memory

16

PADDRMSB

WADDRMSB+1 WADDRMSB

1

 

 

PADDR

 

WADDR

 

0/1

 

 

 

 

 

 

ADDRESS POINTER

LOW/HIGH

BYTE SELECT

 

FLASH

 

 

 

 

FLASH

 

 

 

SECTION

 

 

 

 

PAGE

 

 

00

 

00

 

 

 

 

 

 

 

 

 

01

 

01

 

 

 

WORD ADDRESS

 

 

 

 

 

 

 

 

WITHIN A FLASH

 

 

 

 

 

 

 

 

 

02

 

...

WORD

 

PAGE

 

 

 

 

 

 

 

 

 

 

 

 

 

...

PAGE

 

 

...

 

 

 

 

 

 

 

 

 

 

 

 

 

PAGE ADDRESS

 

 

 

 

...

 

 

 

WITHIN A FLASH ...

 

 

 

 

...

 

 

 

SECTION

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PAGEEND

SECTIONEND

20.4.2.Reading the Flash

The Flash can be read from the data memory mapped locations one byte at a time. For read operations, the least significant bit (bit 0) is used to select the low or high byte in the word address. If this bit is zero, the low byte is read, and if it is one, the high byte is read.

20.4.3.Programming the Flash

The Flash can be written word-by-word. Before writing a Flash word, the Flash target location must be erased. Writing to an un-erased Flash word will corrupt its content.

The Flash is word-accessed for writing, and the data space uses byte-addressing to access Flash that has been mapped to data memory. It is therefore important to write the word in the correct order to the Flash, namely low bytes before high bytes. First, the low byte is written to the temporary buffer. Then, writing the high byte latches both the high byte and the low byte into the Flash word buffer, starting the write operation to Flash.

The Flash erase operations can only performed for the entire Flash sections. The Flash programming sequence is as follows:

1.Perform a Flash section erase or perform a Chip erase

Atmel ATtiny102 / ATtiny104 [DATASHEET] 192

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016