Keil Logo


Information in this article applies to:

  • C51 Version 7
  • µVision Version 2 and Later


Does the µVision Debugger simulate the on-chip EEPROM of the various 8051 Devices? I'm using an Atmel AT89C8252 and need to simulate EEPROM programming and review and modify the contents of the on-chip EEPROM.


Yes. The µVision Simulator includes simulation for almost all 8051 devices with on-chip EEPROM. This includes Atmel variants like the AT89C8252, T89C51RD2, T89C51CC01, and Analog Devices variants like the ADuC812, ADuC824, and so on.

The EEPROM space of the various devices is simulated in µVision using the V: memory type prefix. This memory space can be manipulated using standard µVision debugging commands. For example:

D V:0                            // displays the EEPROM memory space
SAVE EEPROM.HEX V:0, V:0x7FF     // saves the EEPROM memory space
LOAD EEPROM.HEX                  // loads the EEPROM contents

It is possible to display variables in the EEPROM space using standard µVision features like the Watch Window or the Memory Window.

You may modify the contents of any memory area using the Memory Window. Simply open the Memory Window and enter V:0000 in the Address input line. Right-click on the byte you want to modify and select Modify Memory from the context menu.

Implementing EEPROM programming routines for the AT89C8252 is easy. The following example code accesses the EEPROM of the AT89C8252.

#include <AT898252.H>
#include <absacc.h>

 * Return EEPROM Byte at address 'adr'
unsigned char ReadEEPROM (unsigned int adr)  {
  unsigned char v;

  WMCON |= EEMEN_;   //  enable EEPROM
  v = XBYTE[adr];    //  read value
  WMCON &= ~EEMEN_;  //  disable EEPROM
  return (v);

 * Write EEPROM Byte 'val' at address 'adr'
void WriteEEPROM (unsigned int adr, unsigned char val)  {
  WMCON |= (EEMEN_ | EEMWE_);     // enable EEPROM and set write bit
  XBYTE[adr] = val;               // write value
  while ((WMCON & EERDY_) == 0);  // wait until value programmed
  WMCON &= ~(EEMWE_ | EEMEN_);    // disable EEPROM and write strobe

unsigned char v;

void main (void)  {
  v = ReadEEPROM (0x200);         // read EEPROM address 0x200
  WriteEEPROM (0x200, 6);         // write 6 to EEPROM address 0x200
  while (1);


Refer to the sample program provided in the \KEIL\C51\EXAMPLES\FARMEMORY\E2PROM\ folder. This example program access the EEPROM memory of the Atmel T89C51RD2 using the far memory type supported by the LX51 Linker/Locater that is part of the PK51 Professional Developers Kit. This example allows you to declare far variables that reside in the on-chip EEPROM. You may adapt the programming routine in the XBANKING.A51 file to the chip that you use.



The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, May 10, 2004

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.