Friday, February 6, 2009

How to Read and Write Data into EEPROM using MikroC

This is an Example program for Demonstrating read and write Data into EEPROM of a PIC Microcontroller (Pic16F877A have 256 Bytes EEPROM),This program first writes 0xAA into the address 0x00 and the reads and displays it in PORTB . You don't need external EEPROM for storing small user datas.

Mikroc Having a EEPROM library .There are only two functions in this library
  • Eeprom_Read
  • Eeprom_Write

First function Eeprom_Read returns an integer value from the specified address. The following is the syntax .

unsigned short Eeprom_Read(unsigned int address);

Second Function Eeprom_Write takes two parameters address and data .

See syntax given below .

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

See the Example program

unsigned short data = 0xAA, address=0x00;

void main() {
PORTB = 0x00;
TRISB = 0x00;

//writes 0xAA into the location 0x00

//insert 20 or 30 ms delay between every read and write cycle

// the following delay is just for making a feel

//reads the data from 0x00 and send it to PORTB

PORTB = Eeprom_Read(address);

1 comment:

Khairul said...

haii, i also use MicroC for my EEPROM programming but the problems is how i want to display EEPROM data in LCD and how to know the data actually in the address? plez help me..