|
|||||||||||
|
Technical Support Support Resources
Product Information |
C51: Accessing Special Function Registers in CInformation in this article applies to:
QUESTIONHow do I access the 8051's Special Function Registers (SFRs) in my C programs? ANSWERThe C51 Compiler offers 3 extensions to the C programming language that allow you to access the SFRs of the 8051. These keywords are:
You use these keywords to define the name and address for an SFR. The name may be any valid C variable name. The address must be the address that is associated with the desired SFR. Refer to your databook for the SFR addresses. The following example defines the SFR for Port 1. P1 is used as the name and 0x90 is the address.
The following example defines the SFR bit for Port 1.1. P1_1 is the name and 0x91 is the address of P1.1.
The following example defines the 16-bit SFR for Timer 2. T2 is the name and 0xCC - 0xCD is the address.
MORE INFORMATION
SEE ALSOLast Reviewed: Thursday, February 25, 2021 | ||||||||||
|
|||||||||||
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.