I got a code, and modified it to run.. But i can't seem to get the code correct. it has to do with XDATA but i can't seem to get it right.
#include <AT898252.H> #include "lcd.c" BYTE ReadEEPROM(int addr) { char EEdata; WMCON |= 0x08; // Enable EEPROM memory space EEdata = addr; // --> how do u write here? WMCON &= 0xF7; // Disable EEPROM memory space return(EEdata); } // To write a single byte to a location in EEPROM. void WriteEEPROM(int addr, char EEdata) { WMCON |= 0x08; // Enable EEPROM memory space WMCON |= 0x10; // Enable EEPROM memory write addr = EEdata; --> how do u write here? msdelay(15); WMCON &= 0xEF; // Disable EEPROM memory write WMCON &= 0xF7; // Disable EEPROM memory space }
WMCON DATA 96h ; watchdog and memory control register EEMEN EQU 00001000b ; EEPROM access enable bit EEMWE EQU 00010000b ; EEPROM write enable bit WDTRST EQU 00000010b ; EEPROM RDY/BSY bit ADDRESS EQU 10H DATAS EQU 0AAH ; EEPROM read example. ;orl WMCON, #EEMEN ; enable EEPROM accesses ;mov dptr, #ADDRESS ; address to read ;movx a, @dptr ; read EEPROM ;xrl WMCON, #EEMEN ; disable EEPROM accesses ; EEPROM write example, utilizing fixed delay for write cycle. ; Delay is worst case (10 ms). Code for delay is not shown. ; Write is followed by verify (read and compare), but code to handle ; verification failure is not shown. orl WMCON, #EEMEN ; enable EEPROM accesses orl WMCON, #EEMWE ; enable EEPROM writes mov dptr, #ADDRESS ; address to write mov a, #DATAS ; data to write movx @dptr, a ; write EEPROM xrl WMCON, #EEMWE ; disable EEPROM writes xrl WMCON, #EEMEN ; disable EEPROM accesses