Tutorial: Using the C51 compiler and the MP-51 Programmer
I. Introduction
The goal of this tutorial is to blink an LED using the 8051. Steps are given on how to compile the program using the c51 compiler, burn the program unto an 8051 chip, and run the program.
II. Schematic
Wire the circuit as shown by the schematic below. It may be
useful to used the 8051
pinout. Make sure the LED is connected correctly or it will
not blink when you run your program. Below is another schematic
which shows how the LED corresponds to it's symbol.
III. Apparatus Required
IV. Program
/* main.c */
#pragma SMALL DB OE
#include <reg51.h>
sbit light = P2^0;
/* Delay Function */
void delay(void){
int i, j;
for(i=0; i<1000; i++){
for(j=0; j<100; j++){
i=i+0;
}
}
}
void main(void){
while(1){
light=0; /* turns light on */
delay(); /* without the delay function the light
would blink to quickly for us to see */
light=1; /* turns light off */
delay();
}
}
V. Procedure
Hardware
Creating The Program File
Burning A Chip - Programmer: MP-51
If there are any warnings or errors, check the code
you typed against the code provided.
If you have multiple object files you can link them with
the following command:
Testing Your Program
Note: there is a picture
on the burner which shows which way to insert the chip.