16 IAP/EEPROM/DATA-FLASH
Large capacity of internal EEPROM is integrated in STC8A8K64D4 series of microcontrollers. The internal Data
Flash can be used as EEPROM by using ISP / IAP technology. And it can be repeatedly erased more than 100,000
times. EEPROM can be divided into several sectors, each sector contains 512 bytes.
Note: The EEPROM write operation can only write the 1 in the byte as 0. When the 0 in the byte needs to be
written as 1, the sector erase operation must be performed. The read/write operation of EEPROM is performed in units
of 1 byte, while the erase operation of EEPROM is performed in units of 1 sector (512 bytes). During the erasing
operation, if there is something that needs to be reserved in the target sector Data, these data must be read into RAM
for temporary storage in advance, and then the saved data and the data to be updated will be written back to
EEPROM/DATA-FLASH after erasing is completed.
When EEPROM is used, it is recommended that the data modified at the same time be stored in the same sector,
and data modified at different time be stored in different sectors, and not necessarily full. Data memory is erased sector
by sector.
EEPROM can be used to save some parameters which need to be modified in the application and need be kept
when power down takes place. In the user program, byte read / byte programming / sector erase can be performed to
the EEPROM. When the operating voltage is low, it is recommended not to carry out EEPROM operation to avoid data
loss.
16.1 EEPROM operation time
◼ Read 1 byte: 4 system clocks (use MOVC instruction to read more convenient and fast)
◼ Programming 1 byte: about 30~40us (the actual programming time is 6~7.5us, but state conversion time
and various control SETUP and HOLD time of the control signal)
⚫ Erase 1 sector (512 bytes): about 4~6ms
The time required for EEPROM operation is automatically controlled by the hardware, and the user only needs to set
the IAP_TPS register correctly.
IAP_TPS=System operating frequency/1000000 (the decimal part is rounded to the nearest whole number)
For example: the operating frequency of the system is 12MHz, then IAP_TPS is set to 12
Another example: the system operating frequency is 22.1184MHz, then IAP_TPS is set to 22
Another example: the system operating frequency is 5.5296MHz, then IAP_TPS is set to 6
16.2 Registers Related to EEPROM