Sunday, December 14, 2008

PIC16F877A EEPROM Tutorials

There is a inbuilt EEPROM in most of the PIC microcontroller series .PIC16F877A has 256 bytes of EEPROM inside it .So you can use it to store data that you might need on a permanent basis and you can read it back from it .The picture below shows the representation of the memory in the EEPROM .



For instance in the above picture I have entered 0x01 in the location 0x88 .
0x01 is the data and 0x88 is the address where the data is stored .I guess you
got the system .

Now let is look at the mikroc specifics of the EEPROM library .There are two functions in this library to accomplish the task

  • Eeprom_Read
  • Eeprom_Write

Eeprom_Read function returns an integer and takes a parameter of the address from which the data has to be fetched .The following is the syntax .

unsigned short Eeprom_Read(unsigned int address);

Eeprom_Write takes two parameters the first one is the address and the second one is the data .The syntax is given below .

void Eeprom_Write(unsigned int address, unsigned short data);

You can use these two functions to read and write data from the pic EEPROM .I will show you the actual working code in the next post .

Next Post ---->

1 comment:

ankon said...

kisui bujhinai... didnt understand how to store data in eeprom. in 256 byte, i am making electronic voting machine and have to store the total number of votes of 10 different candidates in eeprom... can u show me the way or give me a sample program?