1. EEPROM Introduction
Electrically Erasable Programmable Read Only Memory Electrically Erasable Programmable Read Only Memory
Development process: ROM -> PROM -> EPROM -> EEPROM
2. The difference between EEPROM and FLASH
2.1 Differences in usage
FLASH is used to store programs and cannot be changed during program execution. The programs we write are burned into FLASH;
RAM is used as data storage when the program is running;
EEPROM is used to store data that users do not want to lose after power failure, and parameters used when starting the machine. It can be changed during operation.
FLASH is used to store program code. In some cases, it may also be used to save data. Of course, the premise is that the FLASH process of the microcontroller is self-writable (erasable during operation). However, it should be noted that the number of times FLASH can be erased is usually less than 10,000 times, and FLASH can usually only be erased by block. EEPROM cannot be used to store programs. Usually, the instruction addressing of the microcontroller cannot reach this area. The number of times EEPROM can be erased should be millions, and it can be erased by byte. EEPROM can be written arbitrarily within a PAGE, while FLSAH must be erased to BLANK first and then written. Generally, there is no single-byte erase function, and at least one sector must be erased.
2.2 Structural Differences
Both EEPROM and FLASH are non-volatile memories.
The full name of FLASH is FLASH EEPROM, but its operation method is different from that of conventional EEPROM.
The biggest difference between FLASH and EEPROM is that FLASH operates by sector, while EEPROM operates by byte. The two have different addressing methods and different storage unit structures. FLASH has a simpler circuit structure, and the same capacity occupies a smaller chip area, so the cost is naturally lower than that of EEPROM, so it is suitable for use as a program memory, while EEPROM is more used as a non-volatile data memory. Of course, it is also possible to use FLASH as a data memory, but the operation is much more troublesome than EEPROM, so a more "humanized" MCU design will integrate two non-volatile memories, FLASH and EEPROM, while cheap designs often only have FLASH. Early electrically erasable MCUs all have EEPRM structures, which are now basically discontinued.
3. How to use EEPROM
AVRGCC has built-in EEPROM read and write functions.
The header file #include must be included when using it. Some read and write functions are as follows:
#define eeprom_is_ready() bit_is_clear(EECR, EEWE) //Check if EEPROM is ready. OK returns 1 (return EEWE bit)
#define eeprom_busy_wait() do {} while (!eeprom_is_ready()) //wait for EEPROM operation to complete
extern uint8_t eeprom_read_byte (const uint8_t *addr); //Read one byte of 8-bit EEPROM data at the specified address
extern uint16_t eeprom_read_word (const uint16_t *addr); //Read a word of 16-bit EEPROM data at the specified address
extern void eeprom_read_block (void *buf, const void *addr, size_t n); //Read EEPROM data of specified length starting from specified address
extern void eeprom_write_byte (uint8_t *addr, uint8_t val); //Write a byte of 8-bit EEPROM data to the specified address
extern void eeprom_write_word (uint16_t *addr, uint16_t val); //Write a word of 16-bit EEPROM data to the specified address
The configuration command is sent to the MCU through the serial port. After receiving the command, the MCU uses the function write_EEPROM_config() to store the corresponding configuration information in the EEPROM. When the system is initialized, the function read_EEPROM_config() is used to retrieve the corresponding data from the EEPROM for system initialization.
Previous article:Serial communication between AVR microcontroller USART and PC
Next article:Analysis of the sensing principle of RC capacitive touch in AVR microcontroller
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Start with a Routine
- Share a reference book on servo motor drive
- Is FPGA a big deal in the field of artificial intelligence?
- 【GD32F310G-START】Voltage meter
- C language algorithm to calculate the age of beautiful women
- LOTO virtual oscilloscope about trigger sensitivity function
- [ST60 short-distance test] Part 2: Communication rate test
- PT4115 cannot be completely shut down
- STM32 Linux development board recommendation | PHYTEC development board: Help you reduce development risks and improve product stability
- FAQ|Beineng International's new glass breakage detection solution