Keil Setup For 8051

In this tutorial we see how to setup Keil4 for generating .hex file.
Keil software can be downloaded from this link.
Download and install the Keil C51 for 8051.
01Kiel.PNG

Keil Setup Steps

Step1: Open the Keil software and select the New Microvision project from Project Menu as shown below.
8051 Keil 01.png
Step2: Browse to your project folder and provide the project name and save it.
8051 Keil 02.png
Step3: Once the project is saved a new pop up “Select Device for Target” opens, Select the required 8051 series controller and click on OK.
  1. Atmel->AT89s52
  2. NXP->P89V51RD2
  3. Nuvoton-> W78E052D
Since all the controller follow the same 8051 architecture, any of the above mentioned controller can be selected.8051 Keil 03.png
Step4:Select Atmel->At89s52 and click OK.
8051 Keil 04.png

Step5:8051 doesn't need the startup code, click on NO option to proceed.
8051 Keil 05.png

Step6: Create a new file to write the program.
8051 Keil 06.png

Step7: Type the code or Copy paste the below code snippet and save the file as main.c
8051 Keil 07.png

// Program by UdayaPrakashJayaraman

#include <reg51.h>

void DELAY_ms(unsigned int ms_Count)

{

unsigned int i,j;

for(i=0;i<ms_Count;i++)

{

for(j=0;j<100;j++);

}

}

int main()

{


while(1)

{

P0 = 0xff; /* Turn ON all the leds connected to Ports */

P1 = 0xff;

P2 = 0xff;

P3 = 0xff;

DELAY_ms(500);


P0 = 0x00; /* Turn OFF all the leds connected to Ports */

P1 = 0x00;

P2 = 0x00;

P3 = 0x00;

DELAY_ms(500);

}


return (0); 

}    


Step8:Save the file as main.c
8051 Keil 08.png
Step9:Add the file to the project using the option Add files to Source Group.
8051 Keil 09.png
Step10: Add the recently saved file to the project.
8051 Keil 10.png
Step11:Now the main.c file should appear in Project Source Group.
8051 Keil 11.png
Step12:Build the project and fix the compiler errors/warnings if any.8051 Keil 12.png
Step13:Code gets compiled with no errors and .hex file is still not generated.
8051 Keil 13.png

Enable Hex File Generation

Step14:Click on Target Options to select the option for generating .hex file.
8051 Keil 14.png
Step15: Rebuild the target to generate the .hex file. 
8051 Keil 15.png
Step16: Check teh project folder for generated .hex file.8051 Keil 16.png

Uploading the Hex file

After generating the .hex file check the below tutorials for uploading it.
  1.  Uploading Hex File Using USBasp Programmer Progisp


Have a opinion, suggestion , question or feedback about the article let it out here!

Related Posts:

  • 8051 Led Blinking 8051 Ports 8051 has 32-gpio's grouped into 4-Ports namely P0-P3 as shown in the below table. PORTNumber of PinsAlternative Function P08 (P0.0-P0.7)AD0-AD7 (Address and Data bus) P18 (P1.0-P1.7)None P28 (P2.0-P2.7)A8-A15… Read More
  • Microcontrollers 8051 Input Output Ports 8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or output. Hence, total 32 input/output pins allow the microcontroller to be connected with the peripheral devices. Pin configuration,… Read More
  • Keil Setup For 8051 In this tutorial we see how to setup Keil4 for generating .hex file.Keil software can be downloaded from this link.Download and install the Keil C51 for 8051. Keil Setup Steps Step1: Open the Keil software and… Read More
  • 8051 LED On OFF control with Pushbutton Hardware Connections: Push button switch is connected to the first bit of PORT 0 (P0.0) which is configured as an input pin. Which is connected to a pull up resistor as there is NO INTERNAL PULL UP RESISTORS FOR PORT… Read More
  • Microcontrollers - 8051 Interrupts Interrupts are the events that temporarily suspend the main program, pass the control to the external sources and execute their task. It then passes the control to the main program where it had left off. 8051 has 5 interru… Read More