arunbharathi.arasu
Full Member level 2
![Full Member level 2](/styles/images/ranks/elevel2.gif)
- Joined
- Feb 28, 2013
- Messages
- 134
- Helped
- 7
- Reputation
- 14
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Chennai, Tamil Nadu, India
- Activity points
- 2,151
Hi all,
I am using pic18f2320 for my project.
I want to store some value in INTERNAL EEPROM. I tried but could not get right result.
I cannot read data from EEPROM.
Even i dont know whether data is stored in to EEPROM or not.
here is the EEPROM coding for wright and read
I used UART for other purpose, here im using UART for display read data.
main program is below
UART is working fine. i can send some other data by using UART.
Please help me .
Thanks in advance.
I am using pic18f2320 for my project.
I want to store some value in INTERNAL EEPROM. I tried but could not get right result.
I cannot read data from EEPROM.
Even i dont know whether data is stored in to EEPROM or not.
here is the EEPROM coding for wright and read
Code:
#include <htc.h>#include <string.h>
#ifndef EEPROM_H
#define EEPROM_H
unsigned char x,len,i,u;
void EEPROM_Write()
{
EECON1bits.EEPGD = 0; //Points to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.WREN = 1; //EEPROM Write Enable bit
INTCONbits.GIE = 0; //Disable all Interrupts
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1; //WR Control bit initiates Write Operation
INTCONbits.GIE = 1;
// while(!PIR2bits.EEIF);
Nop();
Nop();
Nop();
// PIR2bits.EEIF = 0;
EECON1bits.WREN = 0;
}
void EEPROM_Write_String(unsigned char msg[],unsigned char address)
{
len = strlen(msg);
for(i=0;i<len;i++)
{
EEADR = address + i;
EEDATA = msg[i];
EEPROM_Write();
}
}
unsigned char EEPROM_Read(unsigned int add)
{
EEADR=add;
EECON1bits.EEPGD = 0; //Point to EEPROM
EECON1bits.CFGS = 0; //Points to Flash and EEPROM
EECON1bits.RD = 1; //EEPROM Read Enable Bit
u=EEDATA;
return(u);
}
#endif /* EEPROM_H */
I used UART for other purpose, here im using UART for display read data.
main program is below
Code:
void main()
{
UART_init();
EEPROM_Write_String("Hello",0x500);
x = EEPROM_Read(0x500);
trans_string(x);
while(1);
}
UART is working fine. i can send some other data by using UART.
Please help me .
Thanks in advance.
Last edited: