Don't Miss


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.

Please give a support by clicking on the social buttons below. Your feedback on the post is welcome. Please leave it in the comments.

P.S- If you enjoyed reading this, click here to subscribe to my blog (free subscription). That way, you’ll never miss a post. You can also forward this website link to your friends and colleagues-thanks!

Note: You can check his previous repair articles below:

https://www.jestineyong.com/introduction-to-8051-microcontroller/

 

Likes(36)Dislikes(0)

6 Comments

  1. Gopal Sharma

    March 11, 2016 at 1:28 pm

    Very nice Mr. Hafiz

    Likes(0)Dislikes(0)
  2. Albert van Bemmelen

    March 11, 2016 at 5:04 pm

    Thank you Hafiz.
    I understand that you like the free KEIL software to program in C or C++
    or in Assembly. But you are not at all limited to only these 2 options
    because it is also possible to use the BASCOM-8051 Compiler. It is
    probably much easier to learn for many readers and is also very fast and
    free! (with only some code size limitations in the free edition). See:

    http://www.mcselec.com/index.php?page=shop.product_details&flypage=shop.flypage&product_id=87&option=com_
    phpshop&Itemid=1

    And because - in this line of Jestine's programming articles -
    I previously wrote an intro on programming FPGA's in VHDL, I like to add that there is also a completely new and free program called DEEDS that can be downloaded at this link (not tested yet):

    http://www.esng.dibe.unige.it/deeds/Downloads.htm
    (about 20 MB).
    Cheers!

    Likes(1)Dislikes(0)
  3. Chris

    March 14, 2016 at 5:35 am

    Hi!
    I would have a question for you Mr. Hafiz:
    How can readers use this article for repairing?
    I wont be a party breaker, I'm all-days do uC programming, decoding, hacking, cracking stuff deep in and I understand your learning but I don't understand how could peoples who search for his/her repairing stuff find a solution using this uC tutorial?
    I think you should give as/them a more practical tutorial how to solve a problem in an electronic device even with a uC.
    Sorry for my somehow negative comment.
    Maybe you can write a tutorial how to repair a device if the uC is in trouble, or how to check the functions of the uC or maybe how to get out the data from a protected uC to reuse it on a device with a same defective uC or how to use a logic analyzer or scope to trace some data to see how the uC communicate with the other parts on the PCB or whatever what can be used as a repairing tool/solution...
    You have access to some data maybe on your University what is hard to find, share that if it is legal with as, you also have equipment's what is hard to see in small all-days service centers, share knowledge about them how to use them, compare some of them with a cheaper tool etc...
    C and ASM is a bit hard for peoples who just start to learning uC stuff, show some advice to Bascom ( the good old Basic 🙂 ) programming language, maybe peoples will more love the uC world then.
    Bascom is a very nice tool for beginners who wish to get some experience in the world of uC from Atmel but also a robust tool for making robust applications based on the ATMEL uC's.
    Otherwise, I like your writing and it is nice, step by step organized.
    Well done.
    Please don't hate my comment, I wont be an angry bird here.
    Keep up and we will see what would happen.

    Likes(0)Dislikes(0)
  4. Parasuraman S

    March 18, 2016 at 7:47 pm

    Very nice work and explanation. I do hope that you will come out with a write up on how to program uController ICs used on audio/video systems, especially when these are no longer available from the manufacturers, but ICs are available for purchase. Thanks for sharing! Please keep it up!

    Likes(0)Dislikes(0)
  5. Albert van Bemmelen

    April 29, 2016 at 3:01 pm

    I like to add that the long awaited "Quite Universal Circuit Simulator"
    with graphical user interface (GUI) or also known as Qucs is now on
    internet downloadable in its newest version 0.0.19.
    You can use it to test Digital and Analog Electronic circuits complete
    with VHDL programming capbilities!
    I haven't tested it yet but according to the User reviews it recieved all
    5 stars !!!
    https://sourceforge.net/projects/qucs/?source=typ_redirect
    I can't wait to test it myself!

    Likes(0)Dislikes(0)
  6. sofia

    October 24, 2019 at 4:37 pm

    ORG 0000H

    MOV P2,#00H

    MOV A,#71D
    MOV R0, A
    MOV R5,#123D
    MOV 47H,R5
    MOV 54H,#0A3H

    ADD A,#54H
    ADD A,54H
    ADD A,R5
    ADD A,@R0

    MOV P2,A

    HERE: LJMP HERE

    END

    ##can i know what is the result for the coding. for the led

    Likes(0)Dislikes(0)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Report