In this tutorial we will learn how to write and read operation internal EEPROM  in PIC16F877A. You can watch the video or read the written tutorial below.

 

Internal EEPROM in PIC16F877A

PIC16F877A Microcontroller has three type memory.
 

  1. Flash program memory ( 8kB)
  2. Data Merory(368 Byte)
  3. EEPROM  Memory (256 Byte)

In this tutorial I am describe how to write and read operation of EEPROM Memory. The data EEPROM and Flash Program Memory are readable and writable during mormal operation over the entire Vdd range. EEPROM  abbreviation is Electrically Erasable Programmable Read Only Memory. It is a Non-Volatile and Flash Memory. EEPROM design for high speed and high density at the expense of  large erase blocks and number of write cycles. 

 

MikroC PRO for PIC includes EEPROM library for comfortable work with EEPROM.

 

 

EEPROM Memory Write Opertation

Frist time I am write data, address at 080h to 09Fh and data 0x00 to 0x1F.

char ii = 0;
for(ii=0;ii<32;ii++){                 //  loop for write  EEPROM Memory
       EEPROM_Write(0x80,ii) ;        // 0x80 is EEPROM Address & ii is data variable
}

 

 Second time write data at address 002h and store data 0xAA.

 

MikroC Code

char ii;                                               // loop variable
void main() {
     TRISB = 0X00;                           // PORTB is output
     TRISC = 0X00;                           // PORTC is output
     TRISD = 0X00;                           // PORTD is output
     PORTB = 0X00;                         // Clear PORTB
     PORTC = 0X00;                         // Clear PORTC
     PORTD = 0x00;                          // Clear PORTD
     for(ii=0;ii<32;ii++)                     // Fill data buffer
     EEPROM_Write(0x80+ii,ii);     // Write data to address 0x80+ii
     EEPROM_Write(0x02,0xAA);    // Write data
     EEPROM_Write(0x50,0x55);     // Write me data at address 0x50
     delay_ms(1000);
     PORTB = 0XFF;                          // Blinking PORTB
     PORTC = 0XFF;                          // Blinking PORTC
     delay_ms(1000);
     PORTB = 0X00;
     PORTC = 0X00;
     delay_ms(1000);
     PORTB = EEPROM_Read(0x02);  // read data from address 0x02 and display it on PORTB
     PORTC = EEPROM_Read(0x50);   // read data from address 0x50 and display it on PORTB
     delay_ms(1000);
     for(ii=0;ii<32;ii++){                                         // Read 32 bytes block from address0x80
            PORTD = EEPROM_Read(0x80+ii);        // and display data on PORTD
            delay_ms(250);
            }

}

 

 

Download free source code

 

download