Keil Logo

C51: Indirectly Accessing 8051 SFRs

QUESTION

Why can't I create a C pointer to the SFRs on the 8051?

ANSWER

C pointers cannot be used to access the 8051's SFRs (special function registers).

The reason is because the 8051's SFRs are mapped into the upper 128 bytes of the Directly Addressable On-chip Memory. This area cannot be accessed indirectly, so you cannot use pointers to indirectly access the SFRs. If you attempt to indirectly access address 0x90 (normally port 1), you will access idata byte 0x90 instead of P1.

Refer to the Intel 8-bit Microcontrollers User's Manual or the manual specific to your 8051 derivative for more information on how the internal data area and the special function register memory is used.

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


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.