Interfacing Internal EEPROM with PIC Microcontroller

By | February 15, 2014

Here we come with a new project that is “ Interfacing internal EEPROM with PIC Microcontroller ”. In this project we will see how we can easily interface EEPROM. And from EEPROM how we send data from microcontroller, store data in EEPROM and read data from EEPROM. In many time we feel that we need to store some data for long time permanently. For this case we need some additional memory device where we can store data for long time. We can use EEPROM for this purpose. EEPROM stands for Electrically Erasable Programming Read Only Memory. And store data inside EEPROM will live until rewrite the memory place again.

Project description:

Lets start the project description of “ Interfacing internal EEPROM with PIC Microcontroller ”. Here I used internal EEPROM of pic microcontroller and UARTInterfacing Internal EEPROM with PIC Microcontroller Port to receive data which have to be store. For interfacing EEPROM with PIC , see in figure that the internal block diagram of microcontroller. Here we can see how internal EEPROM connected with processor. Data from microcontroller is being send serially and store accordingly with given address. So for storing data to EEPROM, we should send the address before to store the data. The command for sending/writing data in EEPROM for Mikroc for PIC is given bellow.

EEPROM_Write(“address of EEPROM”, Data);

In above we see command of sending or writing data in EEPROM. Now we see the command for reading data from microcontroller.

Take (Unsigned Variable) = EEPROM_Read(“address of EEPROM”);

In my project I used UART port to getting data to be store in EEPROM. It means through UART port we can attach Keyboard and store the data as we want. For getting knowledge on How to interface UART port with PIC Micrcotroller? See my previous post  Interfacing Proteus with Matlab

It will be very useful if we get the circuit diagram of complete project. So in bellow we can see the simulation circuit diagram of my project where I take input from UART port then store it to EEPROM. After that it read the data from EEPROM and finally display it through LED attached with port B.

Interfacing Internal EEPROM with PIC MicrocontrollerIn bellow see the embedded C code for Interfacing internal EEPROM with PIC Microcontroller

Embedded C Code
// Name : Automatic street light control by pic microcontroller
// Author : Subham Dutta
// Date : 08-02-14
// Website : www.nbcafe.in
char t;
unsigned int uart_rd=0;
void main()
{ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISB = 0;
PORTB = 0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1)
{
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read();
delay_ms(100);
UART1_Write(uart_rd); // read the received data,}if (uart_rd != 0)
{
EEPROM_Write(0x02,uart_rd); // Write some data at address 2
Delay_ms(500);
t = EEPROM_Read(0x02);
portb = t;
}
}
}

 




Leave a Reply

Your email address will not be published. Required fields are marked *