Datasheet

ADE5166/ADE5169/ADE5566/ADE5569 Data Sheet
Rev. D | Page 108 of 156
The lower 62 bytes are available to the user for program storage
or as nonvolatile data memory. They are segmented into 124 pages
of 512 bytes each. It is up to the user to decide which flash memory
pages are to be used for data memory. It is recommended that
each page be dedicated solely to program or data memory so
that an instance does not arise where the program counter is
loaded with data memory instead of an opcode from the
program memory or where program memory is erased to
update a byte of data memory.
The flash memory can be protected from read or write/erase access.
The protection is implemented in the upper page of user program
memory. The last sixteen bytes from this page are used to confi-
gure the write/erase protection for each of the pages. The four
bytes that remain are used for configuring read protection of
the flash memory. The read protection is selected in groups of
four pages. Finally, there is a byte used to store the key required
for modifying the protection scheme. If any code protection is
required, the page of information memory must be write/erase
protected at a minimum.
Thus, it is recommended that if code protection is enabled, the
last page of user accessible flash memory be used only to store
data that does not need modification in the field. If the firmware
requires protection and may need updating in the future, the
last page should be reserved for constants used by the user code
that do not require modification during emulation or debug.
Page 0 through Page 122 are, therefore, available for general
program and data memory use. It is recommended that Page 123
be used for constants or code that do not require future modifica-
tions. Note that the last 20 bytes of Page 123 are reserved for the
flash memory protection and are, therefore, unavailable to the user.
USING THE FLASH MEMORY
The 62 bytes of flash memory are configured as 124 pages, each
comprising 512 bytes. As with the other ADE5166/ADE5169/
ADE5566/ADE5569 peripherals, the interface to this memory
space is via a group of registers mapped in the SFR space. The flash
data SFR (EDATA, Address 0xBC), holds the byte of data to be
accessed. The byte of flash memory is addressed via the flash high
byte address SFR (EADRH, Address 0xC7) and the flash low
byte address SFR (EADRL, Address 0xC6).
Table 104. Flash SFRs
SFR Address Default
Bit
Addressable Description
ECON 0xB9 0x00 No Flash control
FLSHKY 0xBA 0xFF No Flash key
PROTKY 0xBB 0xFF No Flash
protection key
EDATA 0xBC 0x00 No Flash data
EADRL 0xC6 0x00 No Flash low byte
address
EADRH 0xC7 0x00 No Flash high byte
address
ECON is an 8-bit flash control SFR (Address 0xB9) that can be
written to with one of five flash memory access commands to
trigger various read, write, erase, and verify functions. Figure 94
demonstrates the steps required for access to the flash memory.
EADRH
FLSHKY
EADRL
ADDRESS ADDRESS
DECODER
FLSHKY = 0x3B?
PROTECTION
DECODER
ECON
COMMAND
ACCESS
ALLOWED?
FLASH
PROTECTION KEY
TRUE: ACCESS
ALLOWED
ECON = 0
FALSE: ACCESS
DENIED
ECON = 1
07411-069
Figure 94. Flash Memory Read/Write/Erase Protection Block Diagram