![CMOSTEK CMT2189C User Manualline Download Page 58](http://html1.mh-extra.com/html/cmostek/cmt2189c/cmt2189c_user-manualline_2627489058.webp)
AN202
V1.0 | Page 58/73
www.cmostek.com
12 Data EEPROM
The chip is integrated with 256 bytes of EEPROM, which is accessed through the EEADR. The software can
program EEPROM through EECON1 and EECON2.The hardware implements its own timing function of
erasing and programming without software query, and saves the limited code space.At the same time, using
this feature, after starting the programming cycle, the chip can enter the sleep mode to reduce the power
consumption.
The following initialization operations must be performed before the data EEPROM is used (either read or
write): Two times 0xAA is written for a certain unit of EEPROM that is not used, and the subsequent program
no longer operates on this unit. Such as:
Programming data EEPROM steps
In order to read the data memory unit, the user must write the address into the EEADR register, and then set
the control bit RD of the EECON1 register to 1. In the next cycle that follows, the user can write the EEPROM
data into the EEDAT register.This data can therefore be read by the next instruction. EEDAT will keep this
value until the user reads or writes data to the unit next time (during the write operation).
BANKSEL EEADR
LDWI dest_addr
STR EEADR
BSR EECON1, RD
LDR EEDAT, W
SYSTEM_INIT
……
……
LDWI 0x55
STR EEROM_ADDR
LDWI 0xAA
STR EEPROM_DATA
LCALL EEPROM_WRITE
LCALL EEPROM_WRITE