Programming I/O ports of 8051 microcontroller

Pinterest icon

Introduction

In this short tutorial we will learn how to control the IO ports of 8051 using embedded C and blink the LED's connected to Port 1 of W78E052DDG.

The 8051 derivative we are using in this tutorial is W78E052DDG from Nuvoton which has 4 ,8bit ports on the 40 pin dip package.It is quite similar to other 8051 derivatives like AT89S52,P89v51RD2 etc.

The 8051 development board used here is the 8052 Robotics Kit

Port's of 8051 derivative W78E052DDG

The below figure shows the ports of 8051 derivative W78E052DDG.The main 4,8 bit ports (P0-P3)are highlighted in Green and their alternate functions are  highlighted in other colour's.

8051 port programming tutorial

In the 8051 development board which we are using ,

  • Port 1 is connected to 8 LED's (D2-D8)through Jumper J5
  • Port 0 is connected to data output of ADC0808(U5).
  • Port 2 is connected to control pins of ADC0808(U5) through Jumper J7.
  • Port 3 is used for controlling the Motor control chip and serial communication through Jumper J4 and J6.

as shown in the below block diagram.

Jumpers are not shown in the Block diagram,Please refer the circuit diagram for that.

You can also view the complete circuit of the 8052 Robotics Kit from here.

 

programming the ports of 8051 using embedded c

 

Blinking a LED using 8051

circuit for 8051 port programming

 

8051 Tutorials Main Page