Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

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
EEprom_Write(address,data);

//insert 20 or 30 ms delay between every read and write cycle
Delay_ms(20);

// the following delay is just for making a feel
Delay_ms(1000);


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

PORTB = Eeprom_Read(address);
Delay_ms(1000);
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews