We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Assembly code for reading internal EEPROM of AT89S8252: 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 orl WMCON, #EEMEN ; enable EEPROM accesses mov dptr, #ADDRESS ; address to read movx a, @dptr ; read EEPROM xrl WMCON, #EEMEN ; disable EEPROM accesses I want to convert this code to a C function like this: unsigned char eepromread(unsigned int address); Address of data byte in EEPROM (content of DPTR register) can be set easily. Please tell me how to convert the following instructions to Keil C. mov dptr, #ADDRESS ; address to read movx a, @dptr ; read EEPROM Suppose that the result is saved to a unsigned char variable.
unsigned char eepromread ( unsigned int address) { unsigned char retval; WMCON |= EEMEN; retval = XBYTE[address]; WMCON &= ~EEMEN; return (retval); }