Keil Logo

CX51: Locating Code in NXP/Philips MX Internal Code Memory

Information in this article applies to:

  • CX51 Version 7.00 and later


I am using the NXP/Philips MB2 that provides up to 8MB code space. My application requires that the program code reside in on-chip Flash ROM (64KB) and the application constants (in this case fonts and bitmap images) reside in external Flash ROM (256KB).

I have read Application Note 160 that explains programming of the NXP/Philips 80C51MX devices. The memory class table under 80C51MX Address Space lists that variables defined in memory space far const go to the HCONST memory class. HCONST can be anywhere in the 8MB ROM space. I have also seen that implicit text strings go to far const when the CX51 directive STRING (far) is used (this directive can be specified in µVision under Project - Options for Target - CX51 - Misc Controls). Therefore, I have defined all fonts and bitmaps with the memory type far const.

I have entered all available memory in µVision under Project - Options for Target - Target and have selected Code ROM Size: Large: 64KB program. However, the linker MAP file tells me that the tools still locate far const into the on-chip Flash ROM space. How can I ensure that on-chip ROM is not used for far const variables?


In this case you cannot use the µVision Memory Wizard that converts the available memory ranges specified under Project - Options for Target - Target into Linker/Locater Memory Classes. This wizard defines all available ROM space for far const including the on-chip Flash ROM.

Instead, specify the memory regions of your application directly as memory classes in the µVision dialog page Project - Options for Target - LX51 Locate as described below:

Disable:  Use Memory Layout from Target Dialog

User Classes:
EDATA  (0x7F0000-0x7F04FF),          /* on-chip RAM */
HCONST (0x810000-0x84FFFF)         /* off-chip Flash for 'const far' */

Tip: You may copy the C classes created by the memory wizard as User classes and modify the address ranges.



Last Reviewed: Thursday, February 25, 2021

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.