Keil Logo

C251: COMPILER APPEARS TO PLACE VARIABLES IN SFR MEMORY


Information in this article applies to:

  • C251 All Versions

QUESTION

I'm using the C251 compiler and there appears to be a problem. The compiler appears to be placing variables in the SFR memory space. Is this a known problem? From the linker MAP file, I get the following information:

0000DDH   0000EAH   00000EH   BYTE   UNIT     EDATA          ?ED?KERNEL
0000EBH   0000ECH   000002H   BYTE   UNIT     EDATA          ?ED?MAIN
0000EDH   0000F0H   000004H   BYTE   UNIT     EDATA          ?ED?ISR
0000F1H   0000F4H   000004H   BYTE   UNIT     EDATA          ?ED?HBEAT

Why are these variables located in the SFR space?

ANSWER

The 251 offers numerous memory spaces that have their own, unique offset addresses that do not necessarily coincide.

The variables referenced in your MAP file are located in the EDATA memory class. SFR's, however, are located in the DATA class between 0x80 and 0xFF inclusive.

To test this, you may create following program:

sfr P1 = 0x90;
unsigned char near edata_var;

void main (void)
{
P1 = 0x55;
edata_var = 0xAA;
while (1);
}

Compile and link specifying that the EDATA class reside from 0x0090-0x00FF. The following excerpt is from the MAP file:

      VALUE       REP       CLASS    TYPE      SYMBOL NAME
      ====================================================
      ---         MODULE    ---      ---       main
      00FF0019H   PUBLIC    CODE     ---       main
      00000090H   PUBLIC    EDATA    BYTE      edata_var
      00000090H   SFRSYM    DATA     BYTE      P1

This shows that P1 is in the DATA class and edata_var is in the EDATA class. Furthermore, when you run this simple program, you will find that P1 is not overwritten with 0xAA (by the write the edata_var).

You may want to take a look at the databook because the NUMEROUS different memory areas of the 251 are very comfusing many of them overlap and do strange things.

Last Reviewed: Tuesday, January 29, 2002


Did this article provide the answer you needed?
 
Yes
No
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.