How to use keil software for 8051

When you first download and install, Keil will try to enter the serial number you have entered in the previous step. After that, simply fill out the registration code with the serial number provided on your purchase receipt and we’ll take care of the rest! We know you want to get started ASAP so we won’t take up any more of your time. Thanks for choosing Keil.

The Keil software has been designed to run on Microsoft Windows. All the used commands contain a path and file name so they should be copied to the same folder where the Keil executable files are located. Using a different folder might lead the compiler to produce unexpected errors during the compilation process. The best way is to create a dedicated folder and extract all the files inside this folder: http://downportableapps.blogspot.com

How to use Keil Software for 8051

It is recommended first to install the development kit and then start working on the project. The 8051 family offers many features, but it also has some limitations. However, these can be overcome by using special instructions and instructions that are provided in this guide.

It should be noted that there are three types of memory: RAM (Random Access Memory), ROM (Read Only Memory), and EEPROM (Electronically Erasable Programmable Read Only Memory). ROM is used to store data permanently while RAM stores data temporarily; EEPROM can only be written once and then erased.

The 8051 family uses two types of instructions: machine language and assembly language. Machine language instructions are elementary operations that tell the CPU how to run a program whereas assembly language instructions tell the CPU what operation needs to be performed based on its input

Keil software is a compiler and IDE for microcontrollers. It can be used to program the 8051 microcontroller, which is a common choice for hobbyists and hobbyists-in-training. It has a number of features that make it easy to program the 8051, including:

  • A wide variety of built-in functions
  • An easy-to-use interface
  • Support for multiple compilers (including IAR)

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/

Use Keil to write programs for 8051 Microcontroller

  • Start the Keil software. Go to the Project > New Project then choose a location to store your program, and give a name and Save.
  • 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.
  • 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.
  • 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.

Example

Here we have used the following code −

#include<reg51.h>
sbit LED_pin = P2^0; //set the LED pin as P2.0
void delay(int ms){
   unsigned int i, j;
   for(i = 0; i< ms; i++){
      // Outer for loop for given milliseconds value
      for(j = 0; j < 1275; j++){
         //execute in each milliseconds;
      }
   }
}
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
   }
}

Output

The connection is like below

Leave a Comment