EEPROM Introduction
Preface
EEPROM is a type of semiconductor storage device that can be repeatedly overwritten electronically. Compared to EPROM, EEPROM does not require ultraviolet light exposure or removal, and can be erased by applying a specific voltage to the chip in order to write new data. In this section, we will introduce the advantages and disadvantages of various brands, as well as the I2C writing method.
EEPROM Types explanation
I2C
- Advantages: Only 2 wires are needed for communication, which can reduce the number of ports required for the microcontroller. Multiple EEPROMs can be connected to the same bus.
- Disadvantages: Slow transmission rate, typically 400K~1Mbit/s
SPI
- Advantages: High operating frequency and fast transmission speed.
- Disadvantages: Requires multiple interfaces.
Microwire
- Compared to SPI, the transmission speed is slower and the capacity is lower.
Comparison of various brands:
Currently, ATMEL is less commonly used with the following market share comparison. On the right side is a rough comparison, which shows that ST is currently the main provider with M25 (SPI) and M24 (I2C) as the main EEPROM products.
EEPROM Read/Write Control (I2C communication)
- The first step is to confirm the expected frequency, which is related to the control voltage
- The second step is to strictly follow the timing specifications in the IC datasheet (this is very important as it affects the reliability of the operation).
- The third step is to confirm the address (taking M24256-BRMN6TP as an example in the figure below)
As shown, three hardware pins need to be set to define the address. For M24256E-F, a special EEPROM model, all hardware pins need to be removed and software writing is required
EEPROM Write Process
- Send access address. 24C02 has a total of 256-bit storage space, with addresses ranging from 0x00 to 0xFF. Write data to the desired address.
- Send the first byte of the data to be stored………..Note that during the data writing process, the EEPROM responds with “0” for each byte to confirm the successful storage of the data. If there is no response, the write operation is unsuccessful.
uint8_t I2C_EE_ByetsWrite(uint8_t* pBuffer,uint8_t WriteAddr,
uint16_t NumByteToWrite)
{
uint16_t i;
uint8_t res;
/*每寫一個bit調整一次I2C_EE_ByteWrite函数*/
for (i=0; i<NumByteToWrite; i++)
{
/*等待EEPROM準備*/
I2C_EE_WaitEepromStandbyState();
/*按字節寫入數據*/
res = I2C_EE_ByteWrite(pBuffer++,WriteAddr++);
}
return res;
}