GPIO as Output Programming of AT89C1051

The following code demonstrate, how to make port-1 of AT89C1051 as output port for up-counter. The code is written in Keil uVision2 IDE and simulation is done with Proteus 8.0. At the end of code, you can find complete project files for download.

Code Using Keil uVision2

#include
// proto-types
void Delayms(unsigned int x_time);
// port-1 labling, 0x90 is the SFR address of port-1
sfr LED_PORT = 0x90;
void main(void)
{
unsigned char count = 0x00;
// make port as output
LED_PORT = 0x00;
while(1)
{
LED_PORT = count++;
Delayms(200);
}
}
void Delayms(unsigned int x_time)
{
unsigned int x,y;
for(x=0;x<x_time;x++)
for(y=0;y<122;y++);
}

Download Files

For download Keil project and Proteus 8.0 simulation files, click here.

Comments

Popular posts from this blog

How to Program Parallel Slave Port (PSP) in PIC16F877A

How to Program Interrupts in PIC16F877A

How to Program SPI in PIC16F877A (Slave Mode)