EEPROM (Electrically Erasable Programmable Read Only Memory)
is the abbreviation for electrically erasable programmable read-only memory. As suggested by the name, it’s content can be programmed and erased with the help of suitable electric pulses. A non-volatile memory used to store a relatively small amount of data in computers and other electronic devices but allows individual bytes to be erased and reprogrammed, EEPROM retains its data even when the power is off. This type of memory is used in microcontroller based systems in which data need to be stored when the power is turned off, also when a particular data need to be retained when the power is switched on. The serial communication protocols such as I2C, SPI, and UART are used by EEPROM ICs to communicate with the microcontroller.
EEPROM Pinout
OpenLab EEPROM IC, AT24C16A, is interfaced with the microcontroller through an I2C protocol. The pinout of AT24C16A is shown in the diagram below. Processes such as data writing, reading and initialization are carried out through an I2C interface.
A0, A1, A2 are address lines, VCC and GND are power supply lines, SCL and SDA are clock and data lines respectively for an I2C protocol. A0, A1 and A2 lines are used for memory page addressing in the case of 16K EEPROM while they are used for device addressing in another case. WP is written protect pin which provides hardware write protection.
I2C Protocol
A serial communication protocol developed by Philips, I2C involves half duplex synchronous serial communication. Unlike other communication protocols, I2C can be connected with more number of devices. In I2C protocol, the device which generates the clock frequency is termed as master and all other devices which receive the clock are called slaves. The clock is supplied by the master device through SCL line and SDA line carries out the data transfer.
The above block diagram shows a typical I2C network in which A, B, and C are slave devices connected to an I2C bus. SCL and SDA lines need to be pulled up to VCC because both lines are in open drain state.
Each I2C slave device has a unique 7-bit address. The master device initiates the communication process. Master generates a start condition and sends the 7-bit slave address with last bit 0 or 1. All the devices in the I2C bus will compare the received address with its device address. The slave which matches the address will generate an acknowledgment. If the last bit of the data is 0, then it will be written to the device and if the last bit is 1 slave will send data to the master which is in a read operation. When 7-bit addressing scheme is employed, a total of 128 devices can be connected to the same I2C device. Acknowledgement needs to be sent after each data transfer by the receiving device in the I2C network whether it is a master or a slave.
If data is continuously fed into the master by the slave, then the master should send a non-acknowledgment before the last byte. The whole communication between the master and slave is terminated when the master sends a stop condition.
OpenLab Hardware Setup for Configuring AT24C16A
OpenLab supports 8 pins I2C compatible EEPROM. AT24C16A can be used with the openLab. The pull-up resistors which have to be connected to the open drain SCL and SDA lines are available with the OpenLab. All we have to do is to connect J23 and J24 jumpers with EEPROM and I2C of the controller.
Interfacing AT24C16A with Atmel microcontroller, AT89S8253
Set up any user interface for read/ write operation of EEPROM. Select PC serial terminal or the LCD or GLCD available on OpenLab for this user interface. We describe here an example of read/ write operation of EEPROM using IO through PC serial terminal (visualized using RealTerm software).
Now, configure USART module of the microcontroller ATmega32. See the section, hardware setup & wiring guide for serial communication. This will allow a serial terminal at your personal computer or laptop, to communicate with a microcontroller for sending data to be written in EEPROM data memory and receiving data from memory.