
151
ATtiny40 [DATASHEET]
8263B–AVR–01/2013
The Non-Volatile Memories can be externally programmed via the Tiny Programming Interface (TPI). For details
NVM control and status registers mapped to I/O space and the NVM memory mapped to data memory space.
19.6.1
Entering External Programming Mode
The TPI must be enabled before external programming mode can be entered. The following procedure describes,
how to enter the external programming mode after the TPI has been enabled:
1.
Make a request for enabling NVM programming by sending the NVM memory access key with the SKEY
instruction.
2.
Poll the status of the NVMEN bit in TPISR until it has been set.
Refer to the Tiny Programming Interface description on
page 134 for more detailed information of enabling the TPI
and programming the NVM.
19.6.2
Exiting External Programming Mode
Clear the NVM enable bit to disable NVM programming, then release the RESET pin.
19.7
Register Description
19.7.1
NVMCMD – Non-Volatile Memory Command Register
Bits 7:6 – Res: Reserved Bits
These bits are reserved and will always read as zero.
Bits 5:0 – NVMCMD[5:0]: Non-Volatile Memory Command
These bits define the programming commands for the flash, as shown in
Table 19-9.19.7.2
NVMCSR – Non-Volatile Memory Control and Status Register
Bit 7 – NVMBSY: Non-Volatile Memory Busy
This bit indicates the NVM memory (Flash memory and Lock Bits) is busy, being programmed. This bit is set when
a program operation is started, and it remains set until the operation has been completed.
Bits 6:0 – Res: Reserved Bits
These bits are reserved and will always read as zero.
Table 19-9.
NVM Programming commands
Operation Type
NVMCMD
Mnemonic
Description
Binary
Hex
General
0b000000
0x00
NO_OPERATION
No operation
0b010000
0x10
CHIP_ERASE
Chip erase
Section
0b010100
0x14
SECTION_ERASE
Section erase
Flash Words
0b011101
0x1D
CODE_WRITE
Write Flash words