Keil™, An ARM® Company

Technical Support

CX51: LOCATING VARIABLES IN EDATA


Information in this article applies to:

  • CX51 Version 6.20

QUESTION

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

ANSWER

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.

MORE INFORMATION

SEE ALSO

FORUM THREADS

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?
 
Yes
No
Not Sure