Header Ads

How to Interfacing EEPROM with PIC Micrcocontroller

Welcome to MINA TECHNOLOGY.

In this tutorial we will learn how to interfacing EEPROM with PIC Microcontroller. EEPROM means Electrically Erasable Programmable Read-Only Memory. Here I am use ATMEL 24C08N EEPROM and Mikro C pro for PIC compiler for code editing. You can watch the video or read the written tutorial below.






In this program I am use I2C Library for data communication. The I²C full master MSSP module is available with a number of PIC MCU models. mikroC PRO for PIC provides library which supports the master I²C mode.

 I2C DATA BUS 2 The slave supports the I2C protocol. A device that sends data onto the bus is defined as a transmitter and a device receiving data as a receiver. The device that controls the message is called a master. The devices that are controlled by the master are referred to as slaves. The bus must be controlled by a master device that generates the serial clock (SCL), controls the bus access, and generates the START and STOP conditions.


I2C Data Bus






EEPROM 24C08N






PIN DIAGRAM


Circuit diagram





Micro C Code:



void EEPROM_Write(){

     I2C1_Init(100000);
     I2C1_Start();
     I2C1_Wr(0xA2);               // send byte via I2C (device address + w)
     I2C1_Wr(10);                   // address byte (EEPROM Location)
     I2C1_Wr(0XAA);             // send data(data to be written)
     I2C1_Stop();                     // stop the i2c1
}
void EEPROM_Read(){
     I2C1_Start();
     I2C1_Wr( 0xA3);                 // send byte via I2C ( device address + w)
     I2C1_Wr(10);
     I2C1_Repeated_Start();
     I2C1_Wr(0xAB);                // send byte(device address+R)
     PORTB = I2C1_Rd(0u);     // read the data (no acknowladge)
     I2C1_Stop();
     }

void main() {
     TRISB = 0X00;
     PORTB = 0X00;
     EEPROM_Write();

     while(1){
              EEPROM_Read();
              delay_ms(500);
              PORTB = 0X00;
              Delay_ms(500);
              }

   
   
}


Click the download button for program file.
download


















No comments

Theme images by 5ugarless. Powered by Blogger.