Friday, April 17, 2020

How to program microcontroller




Programming languages and software for 8051 microcontroller

By  on March 10, 2016
c language software programming









In this article I will explain to you the programming languages used in microcontroller, software used to simulate the circuit and burner used to write the code in microcontroller ROM.
1: Programming Languages:  Assembly, C++ and C Programming languages are used for the Microcontrollers. We can write code only in assembly language, only in C language or it can be mix of Assembly and C Language. Assembly Language is more close to the machine language but little bit difficult to use for the human. But C language is more easy for human. As Processors only know 0 or 1 so the code we write should be converted to the Hex file. Most famous software that is used for programming is KEIL. It’s a freeware software can be downloaded from the official website: www.keil.com
Download and install this software. Now check how to take start with this software.
Open the software and click on project and select “new µvision project”
new project software
Now select your folder where you want to save file and then choose the project name and click on “save”
2
Now a new window will open. Here you have to choose your controller’s Brand and model. 8051 microcontrollers are made by Atmel and in this example we are using the Atmel 89c51. After choose the controller click on “OK”. After click on OK it will ask to start with file.a51 just select here NO.
programming language
Now just click on the “+” Button on Target and right click on source group and select “add new file to the group”
programming language software
Here it will ask to select the file type that you have to create and file name. If you want to make program in Assembly Language you have to choose “Asm File”, for C Language “C File” and for C++ Language “C++ File”. First we start with Assembly Language. So select “Asm File” and click on “Add” button.
5
In default software is not selected to create “Hex” file. As we required “Hex” file so we have to configure it. See in figure below.
newvision software
From this we have configured the target file. Now we write the simple code for microcontroller in Assembly Language.
7
8
By clicking on translate button you can check if there is any error in code. If there is not error, then click on “build” button it will create “hex” file.
hex file
For C language programming in box where we were select “Asm File” just select “C File” and write code. Lets write code in C Language.
c language
=======================================
#include<reg51.h> // include registers header file of 8051.
void main()
{
while(1){ // while(1) used to run this program unlimited time.
int x,y,z;
x=0; y=1; z=2;
}
}
====================================
Now have a look of “hex file” that will be upload in the microcontroller’s ROM
c language programming
Thank you.
hafiz Abdul Haseeb Tariq
This article was prepared for you by Hafiz Abdul Haseeb Tariq from FAST-National University of Computer and Emerging Sciences-Pakistan. He’s an Electronics & Embedded system engineer and has practical experience in circuit designing, networking, assembling, PCB making, 8051 & Arduino programming.



Programming languages and software for 8051 microcontroller

By  on March 10, 2016
c language software programming









In this article I will explain to you the programming languages used in microcontroller, software used to simulate the circuit and burner used to write the code in microcontroller ROM.
1: Programming Languages:  Assembly, C++ and C Programming languages are used for the Microcontrollers. We can write code only in assembly language, only in C language or it can be mix of Assembly and C Language. Assembly Language is more close to the machine language but little bit difficult to use for the human. But C language is more easy for human. As Processors only know 0 or 1 so the code we write should be converted to the Hex file. Most famous software that is used for programming is KEIL. It’s a freeware software can be downloaded from the official website: www.keil.com
Download and install this software. Now check how to take start with this software.
Open the software and click on project and select “new µvision project”
new project software
Now select your folder where you want to save file and then choose the project name and click on “save”
2
Now a new window will open. Here you have to choose your controller’s Brand and model. 8051 microcontrollers are made by Atmel and in this example we are using the Atmel 89c51. After choose the controller click on “OK”. After click on OK it will ask to start with file.a51 just select here NO.
programming language
Now just click on the “+” Button on Target and right click on source group and select “add new file to the group”
programming language software
Here it will ask to select the file type that you have to create and file name. If you want to make program in Assembly Language you have to choose “Asm File”, for C Language “C File” and for C++ Language “C++ File”. First we start with Assembly Language. So select “Asm File” and click on “Add” button.
5
In default software is not selected to create “Hex” file. As we required “Hex” file so we have to configure it. See in figure below.
newvision software
From this we have configured the target file. Now we write the simple code for microcontroller in Assembly Language.
7
8
By clicking on translate button you can check if there is any error in code. If there is not error, then click on “build” button it will create “hex” file.
hex file
For C language programming in box where we were select “Asm File” just select “C File” and write code. Lets write code in C Language.
c language
=======================================
#include<reg51.h> // include registers header file of 8051.
void main()
{
while(1){ // while(1) used to run this program unlimited time.
int x,y,z;
x=0; y=1; z=2;
}
}
====================================
Now have a look of “hex file” that will be upload in the microcontroller’s ROM
c language programming
Thank you.
hafiz Abdul Haseeb Tariq
This article was prepared for you by Hafiz Abdul Haseeb Tariq from FAST-National University of Computer and Emerging Sciences-Pakistan. He’s an Electronics & Embedded system engineer and has practical experience in circuit designing, networking, assembling, PCB making, 8051 & Arduino programming.