Keil Logo


Information in this article applies to:

  • CX51 Version 6.20


I'm using the Philips 80C51MX devices. How can I declare a variable in EDATA space?


The MX does not provide any new instructions to access the EDATA space. So, this memory area may be viewed as another HDATA memory area. Typically, it is used as extended stack space. However, you may create an HDATA user class that allows you to place variables there. For example:

#pragma userclass (HDATA=ERAM)

unsigned char far i;  // placed in class HDATA_ERAM

void main (void)  {
  i = 0;              // accesses variables in HDATA_EDATA

You may use the LX51 linker CLASSES directive to locate the HDATA_ERAM class to address 0x7F0000.

In µVision, enter this class under Options — LX51 Locate — User Classes as:

HDATA_ERAM (0x7F0000-0x7F03FF)

If you use the LX51 on the command line, you must add this in the CLASSES directive as follows:

LX51 ... CLASSES (HDATA_ERAM (0x7F0000-0x7F03FF))

The #pragma userclass (HDATA=ERAM) directive affects the whole source file. If you need to declare variables in HDATA using an address range different than HDATA_ERAM (0x7F0000-0x7F03FF), you need to create another source file to work with those variables. In the current source file, all the far variables are placed in the user's HDATA_ERAM class.




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

Last Reviewed: Monday, October 23, 2006

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.