Technical Support

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: Saturday, May 08, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure