8051 Tutorial 3: I/O Port Programming in C

This tutorial will introduce you the basics about programming the input and output ports on an 8051 microcontroller using C language. Therefore, it is recommended that the reader is familiar or has basic knowledge about C programming language and electronics circuit analysis. I am going to use Atmel‘s AT89C2051 as an example for the 8051 microcontroller and the C compiler that I am going to use is the RC-51 which is included with the Free Evaluation 8051 Software Toolset of Raisonance. You may see this for more info about the toolset or you may download the free evaluation 8051 Software Toolset  here(RKit-Eval51). See this tutorial for a quick start guide with this software.

For an introduction about AT89C2051, see this.

AT89C2051 General Input and Output Ports

The original 8051 microcontroller (40 pins)  contains 4 digital input and output ports which are P0, P1, P2, and P3. Its little brother, AT89C2051 (20pins), only contains two bidirectional input and output ports which are P1 and P3. Both ports are one-byte (8-bits) wide and each pin of each port can be accessed externally (see the pin diagram below) except bit 6 of P3 or P3.6.

[Read more...]

Pages: 1 2 3