8051 microcontroller can be programmed in two languages
8051 microcontroller popular development IDE is MCU 8051 IDE and µVision to develop code.
Keil µVision IDE consists,
Let’s develop simple LED blinking program using Keil µVision IDE with C51 compiler. here we are using AT89S52 microcontroller from 8051 family.
Now open Keil µVision
Click on Project menu and select New µVision Project…
“Create New Project” window will pop up, type a project name and location for project and save.
“Select Device for Target” window will pop up, select your device (here we selecting AT89S52)
“µVision” window will ask for copy STARTUP.A51 to project folder and add file to project (here it not necessary so we have selected No)
Now select New file from File menu and type your program code (here we have typed LED blinking program)
#include<reg52.h> /* Include header file */
void delay(k) /* Delay for msec. (here Xtal freq. is 11.0592 MHz) */
{
int i,j;
for (i=0;i<k;i++)
for (j=0;j<112;j++);
}
void main()
{
while(1)
{
P1 = 0x00; /* Make Port 1 (P1) Low for 200 msec.*/
delay(200);
P1 = 0xFF; /* Make Port 1 (P1) High for 200 msec.*/
delay(200);
}
}
Save program code with “ .c “ extension (In case if you are using assembly language then save program code with “ .asm “ extension)
Right click on Source Group 1 folder from Target 1 and select “Add existing files to Group ‘Source Group 1’”
Select program file saved with “.c “or “.asm” (in case of assembly language) and add it. Then close that window. You can see added file in “Source Group 1” folder in left project window
Now select Project menu and click on “Build target”, it will build project and give status in Build output window with Error and Warning count if any.
To create Hex file right click on Target 1 and select Option for Target ‘Target 1’
Target window will pop up, enter Xtal (MHz) frequency (here we used 11.0592 MHz) and tick mark in front of “Use On-chip ROM” tag.
Within same window select “Output” option and tick mark in front of “Create Hex File” tag and click on OK.
Now again select build target from Project menu or simply hit F7 shortcut key for same, it will build target and also create Hex file. You can see creating Hex file in Build output window
Created Hex file is burned into microcontroller flash memory using various programming method based on programmer or programmer developed by manufacturer itself.
For example, Flash magic is used for NXP Philips microcontrollers only and is developed by NXP itself. Other manufacturers use serial programmer like ISP programmer to flash their controllers.
Now load generated Hex file in one of any programmer available and flash it in your 8051 Microcontroller.
Find below hex file snap.