Quantcast
Channel: EngineersGarage - eeprom
Viewing all articles
Browse latest Browse all 20

How to Test the Built-In EEPROM of the Arduino

$
0
0

This Code is only visible to Registered users. Please Login/Register

 

How To Test The Built-In EEPROM Of The Arduino

Developed By: 

Ajish Alfred

The EEPROM stands for Electrically Erasable Programmable Read Only Memory. In an EEPROM the data can be written with the help of electrically programming the chip. Once programmed the data it will remain in the memory for a very long time even if there is no power applied to it. Hence the EEPROM memory is widely used in microcontroller systems where some particular data need to be retained each time the system is turned on.

The EEPROM memory chips can be interfaced in a microcontroller chip usually with the help of serial communication protocols. Their applications can be found in sensor based system where the sensor data can be stored, display systems where the image data can be stored and in electronic voting machines where the count of the votes can be stored etc.

In case of small applications where only a few bytes needs to be stored the extra EEPROM chips are not preferred since it add extra complexity in the hardware, coding and increase the cost of the system. Hence most of the microcontrollers are provided with small sized built-in EEPROM chip which can be used to store data in small applications.

The Arduino board has an AVR microcontroller in it which also has a built-in EEPROM memory. The memory size varies with the Arduino boards and the microcontroller used in them. Before writing the data to the EEPROM memory it is always recommended to check each and every memory locations of so that there won’t be any data error when the microcontroller tries to retain the data. This particular project explains how to perform a test on the built-in EEPROM of an Arduino microcontroller. 

How To Test The Built-In EEPROM Of The Arduino
The AVR microcontroller boards which are provided with all the basic circuitry for the operation of the microcontroller which has been flashed with the arduino boot-loader are called arduino boards. The arduino can communicate with the other devices using its digital I/O, serial port, I2C port, SPI port etc.The arduino IDE is so simple to use that anyone who has basic knowledge of c programming can quickly get started with it. The project on how to get started with the arduino explains about the steps required to get start with an arduino board.The arduino board used in this project is the arduino pro-mini board and the IDE version of the arduino is 1.0.3 for windows. The Arduino pro-mini board has ATMEGA328 microcontroller inside it which has an internal EEPROM memory of 1Kb. The image of the arduino pro-mini board and the arduino IDE are shown below;
 
Arduino
 
Arduino
Since the arduino pro-mini board has no circuitary for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the arduino board and also helps in the serial communication with the USB port of the PC.
Arduino
It is assumed that the reader has gone through the project how to get started with the arduino and tried out all the things discussed there.The Arduino IDE provides some functions to access the built-in EEPROM using with the EEPROM read and write can be performed very easily. The functions are available from the library called <EEPROM.h>. The library provides functions for write a data into the EEPROM and read data from the EEPROM. The functions used in the code written for this projects are EEPROM.write() and EEPROM.read() from the library <EEPROM.h> which can be used for writing a data into the EEPROM memory and reading a data from the EEPROM memory. The details of the functions are discussed in the following section
 
 
EEPROM.write()
The function EEPROM.write() is used to write a data byte into a particular address of the EEPROM memory mentioned by the parameters passed to the function. The function has two parameters where the first one should be provided with the address of the EEPROM location into which the data need to be written into and the second parameter should be provided with actual data byte. For example if the data ‘A’ need to be written into the address mentioned by the variable ‘addr’ the following statement can be used.
EEPROM.write(addr, ‘A’);
 
EEPROM.read()
The function EEPROM.read() is used to read a particular data byte from the internal EEPROM of the Arduino’s microcontroller. The function has a single parameter which is the address from which the data should be read from. The function has a return value which is the actual data byte which it read from the address mentioned by the parameter passed into it. For example if the data byte is to be read from the location mentioned by the variable ‘addr’ the following statement can be used.
EEPROM.read(addr);
 
THE CODE
The ATMEGA328 microcontroller in the Arduino pro-mini board has a built-in EEPROM memory of 1Kb. This project checks all the memory locations of the EEPROM memory starting from 0th location till the 1023th location. Even though there are lot of standard algorithms to perform memory check, in this particular project the checking is performed by simply writing a data into each and every memory location and reading back the same data and verifies whether they are same.
The code writes a particular data into a memory location with the help of EEPROM.write() function and reads back the data from the same memory location using the function EEPROM.read() both provided by the library <EEPROM.h> and then advances to the next memory location.
Both the value written into the location and read from the location is shown in a 16*2 LCD with the help of functions from the library <LiquidCrystal.h>. Few functions from the library <LiquidCrystal.h> including those which are used in this particular project are already discussed in the previous projects on how to interface an LCD, how to display sensor value on LCD, how to connect the LCD with the PC and how to make an LCD scrolling display.
The code displays the data which is written into the EEPROM in the first line of the 16*2 LCD and the data which is read back from the same location in the second line of the LCD. Once the display on the second line of the 16*2 LCD is done the code starts blinking an LED connected to the pin number 6 continuously with the help of pinMode(), delay() and digitalWrite() functions explained in the previous projects on how to start with Arduino and how to use digital input and output of arduino.
When the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino and the test result will be updated in the 16*2 LCD. If there is no problems found in the entire EEPROM memory locations the LCD reads “EEPROM [ OK ]” otherwise “ERROR OCCURED”.
 
 
 

 

16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are...

LEDs | Light Emitting Diode
LED
 
Light emitting diodes...
Arduino Pro Mini
Arduino Pro Mini

The Arduino Pro Mini is an ATmega168 based microcontroller board. The board comes with built-in arduino bootloader. It has 14 digital input/output pins (of which 6 can be used as PWM...

Resistor Image
Resistor

Resistor is a passive component used to control current in a circuit. Its resistance is given by the ratio of voltage applied across its terminals to the current passing through it. Thus a particular value of resistor, for fixed voltage, limits the current through it. They are omnipresent in...


 
Pick the right product for your next design project with "Mouser Store". Mouser Electronics brings broadest range of semiconductors and electronic components from over 500 industry leading suppliers. 
 
Mouser specializes in the rapid introduction of new products and technologies for design engineers and buyers that includes semiconductors, interconnects, passives, and electro-mechanical components. Providing the best possible service with the flexibility of not requiring a minimum order and same-day shipping, Mouser has it all.
 
 
 
 
When you need the right part right now, think of Mouser
 
Thank you
Team EG

 


Viewing all articles
Browse latest Browse all 20

Trending Articles