piscaroy
Junior Member level 3
lcd eeprom
hihi, i want to display the data stored in the EEprom but i dont know how come i do there is a error..i not sure whether the codes i written issit correct..can help me asap..i using C18 compiler for pic18f452 below here is the source codes..
***********************************************************
unsigned char ReadEEPROM(unsigned char Adresse)
{
EEADR = Adresse;
EECON1bits.EEPGD = 0; //access DATA EEPROM
EECON1bits.CFGS = 0; //access Flash program/Data EEprom memory
EECON1bits.RD = 1; //enable Read
return EEDATA; //data is stored here
}
void WriteEEPROM(unsigned char Adresse, unsigned char Data)
{
EEADR = Adresse;
EEDATA = Data;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIEH = 0; //disable interrupts
INTCONbits.GIEL = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
EECON1bits.WREN = 0; //disable writes on write complete
}
//main programm
void main(){
int value;
EEpromInit();
LCDinit();
value=0;
AGAIN:
while((value>0) && (value<3))
{
WriteEEPROM(EEADR,value); value++;
}
ReadEEPROM(EEADR);
if((EEDATA=0) && (EEDATA=1))
putrsXLCD("Value= %d",EEDATA); <--- ERROR
else if((EEDATA>1) && (EEDATA<3))
putrsXLCD("Mid Value= %d",EEDATA);<----ERROR
else
putrsXLCD("Value too large");
value=5; //Increase initial value for testing...if next run the LCD should display "value too large"
goto AGAIN;
while(1);
}
**********************************************************
hihi, i want to display the data stored in the EEprom but i dont know how come i do there is a error..i not sure whether the codes i written issit correct..can help me asap..i using C18 compiler for pic18f452 below here is the source codes..
***********************************************************
unsigned char ReadEEPROM(unsigned char Adresse)
{
EEADR = Adresse;
EECON1bits.EEPGD = 0; //access DATA EEPROM
EECON1bits.CFGS = 0; //access Flash program/Data EEprom memory
EECON1bits.RD = 1; //enable Read
return EEDATA; //data is stored here
}
void WriteEEPROM(unsigned char Adresse, unsigned char Data)
{
EEADR = Adresse;
EEDATA = Data;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIEH = 0; //disable interrupts
INTCONbits.GIEL = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
EECON1bits.WREN = 0; //disable writes on write complete
}
//main programm
void main(){
int value;
EEpromInit();
LCDinit();
value=0;
AGAIN:
while((value>0) && (value<3))
{
WriteEEPROM(EEADR,value); value++;
}
ReadEEPROM(EEADR);
if((EEDATA=0) && (EEDATA=1))
putrsXLCD("Value= %d",EEDATA); <--- ERROR
else if((EEDATA>1) && (EEDATA<3))
putrsXLCD("Mid Value= %d",EEDATA);<----ERROR
else
putrsXLCD("Value too large");
value=5; //Increase initial value for testing...if next run the LCD should display "value too large"
goto AGAIN;
while(1);
}
**********************************************************