Keil Logo

C51: Accessing I/O Ports in C


Information in this article applies to:

  • C51 All Versions

QUESTION

How can I access the I/O ports on the 8051 using C? Is there an include file that is needed?

ANSWER

Yes.

You must include the SFR register definition include files. These are found in the \C51\INC folder and usually have names like REG51.H (for the standard 8051), REG52.H (for the 8052), and so on. There are include files for most of the derivatives currently available.

In µVision, you can right click the mouse in the Edit Window. An option to automatically insert the #include for the correct header file is available there.

There are several example programs that may be helpful.


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.