How to Data Read from Internal EEPROM of PIC16F877A
The following code demonstrate how to write data on internal EEPROM. The built-in library function is used. The code is written in “mikroC PRO for PIC v.6.6.3” IDE and simulation is done with Proteus 8.0 SP0. At the end of code, you can find complete project files for download.
Note: Pause the simulation, and click on the following option.
Code in mikroC
sbit LED_Dir at TRISC.B0;
sbit LED at PORTC.B0;
void main()
{
char read_buffer[64] = {0};
unsigned short addr = 0;
LED_Dir = 0;
LED = 0;
// initialize hardware UART1
// establish communication at 9600 bps
UART1_Init(9600);
// read data untill 0xFF is received
do
{
read_buffer[addr++] = EEPROM_Read(addr);
}
// addr-1 as addr incremented+1 before to reach here
while(read_buffer[addr-1] != 0xFF);
// data display on uart
UART1_Write_Text(read_buffer);
sbit LED at PORTC.B0;
void main()
{
char read_buffer[64] = {0};
unsigned short addr = 0;
LED_Dir = 0;
LED = 0;
// initialize hardware UART1
// establish communication at 9600 bps
UART1_Init(9600);
// read data untill 0xFF is received
do
{
read_buffer[addr++] = EEPROM_Read(addr);
}
// addr-1 as addr incremented+1 before to reach here
while(read_buffer[addr-1] != 0xFF);
// data display on uart
UART1_Write_Text(read_buffer);
LED = 1;
while(1)
{
}
}
while(1)
{
}
}
Download Files
For download “mikroC PRO for PIC” project and “Proteus 8.0” simulation files, click here.
Comments
Post a Comment