This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Accessing Data RAM in P89LPC931

Hi

I am trying to store data into the EEPROM . I used the sample code available in this website. But the code does not work .Can anyone find out the mistake here . Please give me a sample working code. I am using 89LPC931 running at 11.059Mhz. Thanks



#include <reg31.h>
#include <stdio.h>


void EEPROMwrite(unsigned int adr, unsigned char dat);
unsigned char EEPROMread(unsigned int adr);
unsigned char redat,pus = 0x34;
unsigned int ADR =0x82;

void main(void)
{

EEPROMwrite(ADDR, pus);
redat=EEPROMread(ADDR);


while(1)
{
}
}










void EEPROMwrite(unsigned int adr, unsigned char dat)
{
EA=0; // disable Interrupts during write
DEECON=(unsigned char)((adr>>8)&0x01); // mode: write byte, set address
DEEDAT=dat; // set write data
DEEADR=(unsigned char) adr; // start write
EA=1;
while((DEECON&0x80)==0); // wait until write is complete
}

unsigned char EEPROMread(unsigned int adr)
{
DEECON=(unsigned char)((adr>>8)&0x01); // mode: read byte, set adress
DEEADR=(unsigned char) adr; // start read
while((DEECON&0x80)==0); // wait until read is complete
return DEEDAT; // return data
}

0