Easy 24C I2C Serial EEPROM Interfacing with AVR Microcontrollers
Description: An EEPROM is a type of non-volatile memory, which means it is used for permanently storing digital data without any power supply. EEPROM stands for Electrically Erasable Programmable Read-Only Memory. The advantage of this type of ROM is that it can be electrically erased, allowing it to be prepared for storing new data. This differs from CD-R disks, which can only be recorded once. A small amount of EEPROM is also available internally on AVR chips, making it suitable for storing small volumes of data (such as a few usernames and passwords). The internal EEPROM simplifies the design. However, for larger data storage needs, typically in the range of several tens of kilobytes, an external EEPROM chip must be interfaced with the AVR microcontroller. These EEPROMs can store pictures, sounds, and long texts. Many types of EEPROM chips are available from various manufacturers, with the 24C series serial EEPROMs being a common family, offering sizes up to 128KB. They utilize the I2C interface, a widely used serial communication standard. Each storage location in the chip has a unique address ranging from 0 to 8191, which functions as storage cells. When storing and retrieving data, the specific cell location must be indicated. For example, reading location 0003 will return the value 99. Each cell can store 8 bits of data, with a range from 0 to 255 (or -128 to +127). To store larger data types, such as integers, two cells must be used. To connect an ATmega32 with a 24C64 chip, a circuit diagram is provided. Any AVR development board can be utilized for this purpose, or the circuit can be assembled on a breadboard or veroboard. A sample program demonstrates the use of external EEPROM interfacing functions, utilizing the LCD library for AVRs to display information on a 16x2 LCD. The program writes 8 kilobytes of data to a 24C64 EEPROM, filling it with the value '7', and then reads back the data to verify that all locations contain '7'. If the condition is satisfied, the screen displays a "Write Successful" message. The program has been tested on an xBoard - an advanced ATmega32 development board, but any development board with ATmega16 or ATmega32 MCUs can be used. The 24C64 was mounted on a breadboard.
/* A simple delay routine to wait between messages given to the user so that they have time to read them */
void Wait() {
uint8_t i;
for(i = 0; i < 100; i++) _delay_loop_2(0);
}
void main() {
// Variables
uint8_t failed;
unsigned int address;
This sample program serves as a practical demonstration of interfacing with an external EEPROM, providing a foundational understanding for hardware and software interactions in embedded systems. The use of the LCD library enhances user interaction by displaying real-time feedback during the EEPROM operations.An EEPROM is kinds of novalatile memory, that means it is used for storing digital data permanently without any power suply. EEPROM stands for Electrically Erasable Programmable Read Only Memory. The advantage of these kind of ROMs is that they can be erased Electrically to make them ready for storing new data.
Compare this with a CD R disks they can be recorded only once. A small amount of EEPROM is also available internally on the AVR chips. So if the volume of data you want to store is small (say few user names and password) then you can use it. The internal eeprom makes design small and simple. But if the amount of data you want to store is large, say in order of few tens of kilobytes then you have to interface a External EEPROM chip with your AVR MCU.
You can store pictures, sound and long texts in these eeproms. Their are many kinds of EEPROM chip available from many manufactures. One very common family is 24C series serial EEPROMs. They are available upto 128KB in size. They uses I2C interface with host controller (MCU) which is a very popular serial communication standard. I will write more indept tutorial on I2C in comming days and in this tutorial I will give you easy to use function that you can use without any knowledge of I2C interface.
The chip has storage location which have their unique address ranging from 0-8191. Consider these as storage cells so while storing and retriving data you have to tell the chip which cell location you want to read. For exaple if you read location 0003 you will get 99 (see image above). Note each cell can store 8BITs of data so range you can store is 0-255 (-128 to +127). So if you want to store bigget data like int you have to store them in two cells. Connect your ATmega32 with 24C64 chip as shown in the circuit diagram. You can use any avr development board for the purpose or assemble the whole circuit in a Breadboard or Veroboard.
The following sample program demonstrate the use of external EEPROM interfaing functions. The program makes use of the LCD library for AVRs to display information in a 16x2 LCD display. The program first writes 8Kbytes of data to a 24c64 eeprom to fill the whole eeprom with `7` and then it reads back to see if all the location has 7. If the condition is met the screen shows "Write Successfull" message. I have used my xBoard - An Advance ATmega32 development board to test the routines. You can use any devboard with ATmega16 or ATmega32 MCUs. The 24C64 was mounted on a Breadboard. /* A sample program to test the Extrenal EEPROM interfacing routines. The program fills the whole EEPROM with 7 and then reads the whole EEPROM memory to see if all of them contains 7.
This helps in quick testing of you hardware /software before using these routines in your own programs. The target for this program is ATmega8, ATmega16, or ATmega32 running at 16MHz. If you use slower crystal the program will simply run slow but without any problems. This program also makes use of eXtreme Electronics 16x2 LCD Interfacing routines. See the related page for more info Author : Avinash Gupta Date : 16 March 2009 Mail : me@avinashgupta.
com Web : NOTE: IF YOU USE THIS LIBRARY IN YOUR PROGRAMS AND FINDS IT USEFUL PLEASE MENTION US IN CREDIT AND RECOMEND OTHERS. */ #include #include "util/delay. h" #include "24c64. h" #include "lcd. h" /* A simple delay routine to wait between messages given to user so that he/she gets time to read them */ void Wait() { uint8_t i; for(i=0;i<100;i+) _delay_loop_2(0); } void main() { //Varriables uint8_t failed; unsigned int address; //Initialize LCD LCDInit(LS_BLINK); //Init EEPROM EEOpen(); _delay_loop_2(0); LCDClear(); LCDWriteString("External EEPROM"); LCDWriteStringXY(0, 1, "Test"); Wait(); LCDClear(); LCDWriteString("Writting.
Step-by-step instructions to build an AVR-based versatile camera trigger with functions such as lightning trigger, sound trigger, interval trigger, slave flash trigger, and bulb mode.
The project involves designing a versatile camera trigger utilizing an AVR microcontroller, which can perform multiple...
CodeLock AVR electronic combination lock is realised with Atmel AVR microcontroller AT90S2313 or ATtiny2313. Program in hex code is 2 kB long. User code is consisted of 1 to 4 digits. If you buy the chip than user code is...
A cost-effective I2C bus-controlled stereo decoder, TDA9853H, is utilized for digital mediation in FM radio applications. It operates within a stereo decoding circuit, processing the baseband signal that has been encoded into stereo format. The chip interfaces with the stereo...
The GVI Digital Remote Control for DSLR cameras represents an advancement over previous remote controls for the Canon EOS 450D. This remote utilizes the AVR Microcontroller ATmega328 and is programmed using the Arduino IDE. It serves as a tool for...
Prototype board for 40-pin Atmel ATMega microcontrollers featuring a power supply circuit, an 8MHz crystal oscillator circuit, an RS232 port, a reset IC, a status LED, and a 10-pin STK ICSP port. Constructed from FR-4 material, 1.5 mm thick.
The described...
This is an affordable method for measuring temperature and humidity with a computer interface, designed as an entry-level project for high school students on a limited budget.
The project involves the integration of a temperature and humidity sensor, such as the...
This is a simple AVR programmer designed for Atmel microcontrollers from the AVR family that support serial programming. The programmer connects to a PC via the RS232 serial interface and is compatible with PonyProg or Avrdude software. It is based...
This page describes a color clock that displays the time using two RGB LEDs, one for hours and one for minutes. It uses standard color coding for components, with two additional colors to accommodate the twelve distinct color representations needed....
The Newman MP4 machine features three types of memory: data memory (U7), program memory (U8), and user memory (U9). Data memory is utilized for storing operational data, while program memory holds the machine's work program. User memory is designated for...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more