Programming 8051 Using Keil Software
Programming 8051 Using Keil Software
In this section we will see how to write and execute programs for 8051 microcontroller using the Keil
Software.
Download Keil
Here is the download link of Keil. You can download it and install it very easily. We are using C51 version
for 8051 devices.
https://www.keil.com/download/product/
Now in the next window select the device from different manufacturers. We are selecting
Microchip, and then by expanding we are selecting AT89C51 device and click ok.
https://www.tutorialspoint.com/programming-8051-using-keil-software 1/4
3/17/2020 Programming 8051 using Keil Software
Now go to the New in the menu and select New. It will open a new editor to write code.
Go to the save option and save the program file with .c extension.
Write the code for 8051 Microcontroller. (Here we are using a code for blinking LED in 500 ms)
Now from the left panel, select Source Group 1, and Add Existing Files to Group ‘Source
Group 1’. Then select the program (c file) then add and close
https://www.tutorialspoint.com/programming-8051-using-keil-software 2/4
3/17/2020 Programming 8051 using Keil Software
Now go to the Project > Build Target to build the project. If there is some error the building will be
failed, after correcting the errors it can be build.
Now click on the Target1 from the left panel and select Options for Target ‘Target1’. Then set the
xtal (MHz) value to 11.0592. Check mark on the Use On Chip ROM. Then go to the output tab. In
this tab check Create Hex File, and click OK. Then build it again.
By uploading this hex file into the 8051 microcontroller the program can be loaded into it. And it will work.
#include<reg51.h>
sbit LED_pin = P2^0; //set the LED pin as P2.0
void main(){
while(1){ //infinite loop for LED blinking
LED_pin = 0;
delay(500); //wait for 500 milliseconds
LED_pin = 1;
delay(500); //wait for 500 milliseconds
}
}
https://www.tutorialspoint.com/programming-8051-using-keil-software 3/4
3/17/2020 Programming 8051 using Keil Software
https://www.tutorialspoint.com/programming-8051-using-keil-software 4/4