Keil™, An ARM® Company

Technical Support

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 programa that may be helpful.

Last Reviewed: Friday, July 22, 2005


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