MCU STC89C52RC Internal EEPROM

Publisher:tyloo820Latest update time:2016-11-21 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The data of the microcontroller when it is running is stored in RAM (Random Access Memory). The data in RAM cannot be retained after power failure. So
how to prevent the data from being lost after power failure? This requires the use of memory such as EEPROM or FLASHROM.

In traditional single-chip microcomputer systems, external memory is usually used for expansion, and data communication between the single-chip microcomputer and the memory is carried out through interfaces such as IIC or SPI.

This will not only increase the development cost, but also require more effort in program development. The STC microcontroller has a built-in EEPROM (actually,
the ISP/IAP technology is used to read and write the internal FLASH to implement the EEPROM), which saves external resources and is more convenient to use. The following
is a detailed introduction to the STC microcontroller's built-in EEPROM and its usage



 

MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog

MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog

 

The built-in EEPROM capacity of each type of STC microcontroller is as small as 2K and as large as 16K, which basically meets the needs of the project very well. What is more
convenient is that it saves peripheral EEPROM devices, achieving the purpose of saving costs, and the speed of the internal EEPROM is
much faster than the external EEPROM. The
built-in EEPROM of each type of STC microcontroller is based on 512 bytes as a sector. The starting address of EEPROM = FALSH capacity value + 1,
so the starting address of STC89C52RC is 0x2000, the starting address and end address of the first sector are 0x2000~0x21FF, the starting address and end address of the second sector are
0x2200~0x23FF, and so on for other sectors.
In-depth focus:


Traditional EEPROM is an electrically erasable programmable read-only memory chip that does not lose data after power failure.
The EEPROM of STC89C52RC is implemented by reading and writing internal FLASH through ISP/IAP technology.
The starting address of the EEPROM of STC89C52RC is 0x2000, with 512 bytes as a sector, and the size of EEPROM is 2K bytes.


There are 6 registers implemented by STC89C52RC and EEPORM, namely ISP_DATA, ISP_ADDRH, ISP_ADDRL
ISP_TRIG, ISP_CMD, and ISP_CONTR.
MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog

 

1. ISP_DATA registerISP_DATA
register: data register for ISP/IAP operation. ISP/IAP reads
data from Flash here, and writes data to Flash here. Example 1: Read single byte UINT8 EEPROMRead(UINT16 addr) { ……         return ISP_DATA; } Example 2: Write single byte void EEPROMWrite(UINT8 byte) { ……        ISP_DATA=byte; }











 

2.ISP_ADDRH, ISP_ADDRL registers
ISP_ADDRH: The high eight bits of the address register during ISP/IAP operation
ISP_ADDRL: The low eight bits of the address register during ISP/IAP operation
Example 1: Set the address
void EEPROMSetAddress(UINT16 Addr)
{
……
     ISP_ADDRH=(UINT8)(Addr>>8);
     ISP_ADDRL=(UINT8) Addr;
}

 

3.ISP_CMD Register
ISP_CMD: Command mode register for ISP/IAP operation, which needs to be triggered by ISP_TRIG command to take effect.


MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog
 
4.ISP_TRIG register
ISP/IAP command must be triggered by ISP_TRIG command trigger register to take effect, that is, the command set by ISP_CMD must take effect.
The triggering process is very special. You only need to assign values ​​to the ISP_TRIG register twice in a row. First write
0x46 to the ISP_TRIG register, and then write 0xB9 to complete the command triggering process.
Example 1: Command trigger
void EEPROMCmdTrig (void)
{
……
      ISP_TRIG = 0x46;
      ISP_TRIG = 0xB9;
}
 
5.ISP_CONTR register
ISP_CONTR: ISP/IAP control register
MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog
ISPEN: ISP/IAP function enable bit. 0: Disable ISP/IAP programming to change Flash.
SWBS: 0: Software selects to start from the user main program area 1: ISP program area starts
SWRST: 0: No operation 1: Generate software system reset, hardware automatically clears
WT2, WT1, WT0: Set waiting time
MCU STC89C52RC Internal EEPROM - Xiaoguaiguai - Xiaoguaiguai's Blog

 

Assuming the operating frequency of STC89C52RC is 12MHz, the machine cycle is 1us. Referring to Table 12-, the time required for reading a single
byte is roughly as follows:
Reading a single byte: 11*1us=11us
Writing a single byte: 60*1us=60us
Sector erasing: 10942*1us=10.942ms
Regardless of the operating frequency of the microcontroller, the time required for the EEPROM read, write, and erase operations is approximately 10us, 60us, and
10ms, respectively.


In-depth focus:


There are 6 registers implemented by STC89C52RC and EEPORM, namely ISP_DATA, ISP_ADDRH,
    ISP_ADDRL ISP_TRIG, ISP_CMD, and ISP_CONTR.
The command trigger of EEPROM must first write 0x46 to the ISP_TRIG register, and then write 0xB9.
Regardless of the operating frequency of the microcontroller, the time required for the read, write, and erase operations of EEPROM is
   approximately 10us, 60us, and 10ms, respectively. Therefore, the waiting time must be set for ISP_CONTR, otherwise the data is prone to problems.


Keywords:MCU Reference address:MCU STC89C52RC Internal EEPROM

Previous article:STC12C5A16S2 internal Flash read and write
Next article:Using HyperTerminal to Realize Communication Between MCU and Computer

Recommended ReadingLatest update time:2024-11-16 18:01

Introduction to PIC microcontroller reset system module
The reset function of the PIC16F87X series microcontrollers is well designed. According to the conditions and reasons that cause the internal reset of the microcontroller , the reset system of the PIC microcontroller can be divided into five modules for introduction: 1. Power-on reset Every t
[Microcontroller]
STC12C2052AD single chip AD conversion program design
#include STC12C2052AD.h //Defined system header files and global variables #include intrins.h #define uchar unsigned char #define uint unsigned int #define DogReset()    WDT_CONTR=0x35 // T1 timing 0.1ms. Used as system timing, #define vT01ms 2 #define vT10ms 10 #define vT100ms 10 #define vT01S 100 // 1 s = 10 ms * 1
[Microcontroller]
Application of HDLC Communication Protocol on 80C152 Single Chip Microcomputer
80C152 is a highly integrated 8-bit microcontroller based on MCS-51, and is also a general communication controller. It is suitable for intelligent management of peripheral systems or devices, as well as low-cost, high-speed serial communication occasions. 80C152 is a derivative of 80C51, retaining all the functions
[Microcontroller]
Application of HDLC Communication Protocol on 80C152 Single Chip Microcomputer
ATmega16A microcontroller UBRRH and UCSRC description
Introduction: There is one thing to note about the ATMEGA16 serial port. The UBRRH and UCSRC registers use the same IO address, so be careful when setting and reading. The UCSRC and UBRRH registers of the microcontroller UART share the same address, and the highest bit URSEL is used to select which data to update. F
[Microcontroller]
ATmega16A microcontroller UBRRH and UCSRC description
#51 MCU #DS18B20 hardware principle and communication working sequence
DS18B20 Hardware Principle - Temperature Memory The temperature measurement range of DS18B20 is -55~+125°C. As shown in the figure above, the DS18B20 temperature memory has two bytes in total. LSB is the low byte, MSB is the high byte. Msb is the high bit, Lsb is the low bit. The S in the figure represents the sign
[Microcontroller]
#51 MCU #DS18B20 hardware principle and communication working sequence
Design of Decoding Algorithm of DTMF Signal Based on Single Chip Microcomputer
In many cases, the data output by the DTMF decoder still needs to be sent to the microcontroller for corresponding calculation and processing, and then control the actions of various other devices. Therefore, if a decoding algorithm for DTMF signals based on a microcontroller can be found, supplemented by a simple s
[Microcontroller]
Design of Decoding Algorithm of DTMF Signal Based on Single Chip Microcomputer
MCU-4 independent buttons control program
1 #include "8051.h" 2 typedef unsigned char u8; 3 typedef unsigned int u16; 4 u8 smgduan = { 5 /*0 1 2 3 4 5 6 7 */ 6 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 7 /*8 9 A B C D E F */ 8 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71}; 9 10 // Port P0 is the 8-bit inp
[Microcontroller]
Six important parts of microcontroller learning and application
1. Bus A circuit is always made up of components connected by wires. In analog circuits, wiring is not a problem because the devices are generally in serial relationship and there are not many wires between the devices. However, computer circuits are different. They are based on microprocessors. All devices must be
[Power Management]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号