Skip to main content

How To Use keil uVision 4 IDE - Project Setup, Debug And Simulation

In this tutorial i am going to show you how to setup your project  in Keil for 8051 (AT89s51) to simulate and debug your code. This is one of the most important tutorial for beginner who just start learning 8051. Because Keil is the best IDE to compile,debug and simulate your program.
 And most of 8051 programmer you this tool so you get lot of help about this on internet.
In this tutorial i use Keil v4.0 but it is same for all version or you can download lates trail version from here



Step 1: Keil Setup and Detail 

your IDE looks like this and if not then you can select following option in view tab as shown in second image


keil debug setup

keil window

Step 2: Project setup


To setup your project click on Project tab >> New uVision Project >> a dialog box is open
Then make a new folder(myproject) so your all files of this project not mix with other project files  >> open that folder
Choose a Project name ( myproject )

how to setup a project in keil

Step 3: Select Target Device


After saving your file this new window open to select you CPU
Now select you CPU (here i use  AT89s51)
expand Atmel >> and select AT89s51 (or which you use) >> click OK

choose 8051( AT89s51 ) microcontroller in keil


Step 4: Target setup


Right click on Target Group >> and select Option for Target

how to choose traget n keil

A dialog box open as shown in below image
Change the setting as shown in Red Area (for Target and Output )

frequency and hex file setup for keil

Step 5: Writing Code


Now make a new file and save it with .asm extension (myproject.asm)
and put this test code in file and save
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                Test Program In Assembly

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$mod51
         ORG 0000H 
MAIN:    MOV P1,#55H
         ACALL DELAY
         MOV P1,#0AAH
         SJMP MAIN

DELAY:  MOV R0,#10H
LOOP:   MOV R1,#0FFH
LOOP1:  DJNZ R1,LOOP1
        DJNZ R0,LOOP
        RET
        END
 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

keil in assembly

Now build you code to debug and find error

how to build project in keil

Step 6: Debug and Simulate


Now click on Debug Tab and then Select port 1 form Peripherals Tab


Now click on Over Step button or press F10 to simulate your code

debug in keil

In this image you can see that check box in port 1 are change when i press F10. so our code is correct and working properly. this tutorial use assembly but if you want to use  C language then dont worry ever thing remain same.

I hope you like this tutorial and if you facing problem in multisim, ultiboard or keil please leave comment
please share and give +1 if you like this tutorial and follow us.

Comments

  1. Hi, I can't run my own .asm file on keil uvision4. I followed your exact steps.. tried with many processors.. but it still doesn't run & gives fatal problem...

    To be exact, the error is --> *** ERROR: COMMAND-FILE ' ' NOT FOUND

    my Source Group consists of only 2 files : 1) STARTUP.A51 2) LEDBlink.asm


    what could be the problem? Am I missing something basic? I searched a lot on Keil forum & elsewhere but could not find any answer... Pls help me out..

    ReplyDelete
  2. which version of keil you use and controller.

    ReplyDelete
  3. I'm using Keil v9.01 which comes with Uvision4 IDE.
    I tried with at least 10 controllers including P89v51RD2, AT89C51, AT89S51 etc.

    Funny thing is that same program runs perfectly with Uvision3 IDE (Keil v8.12). Thanks for prompt reply.

    ReplyDelete
  4. Then the problem must be in uVision4. grab a new copy of IDE form here, fill the form to download it. before that try to re-install it with antivirus turn off. and don't include startup.a51 when a box pop up.

    ReplyDelete
  5. Did install the Keil v9.51 from their site. Created a new project copied the assembly code into a new file. As you suggested, did not include startup files.
    Now my Source Group contains only 1 file --> LED Blink.asm
    But alas, still the same problem! What should I do now? The code is very very straight forward, but still should I send it to you to try?

    By the way, millions of thanks for taking so much interest!! :)

    ReplyDelete
  6. welcome buddy... send me your project files.. zip your Keil Project folder and mail me..
    netsmertia@gmail.com

    ReplyDelete
  7. Figured it out!! Can't believe the problem was so small..
    Apparently Keil (Uvision 4) doesn't allow Spaces (' ') in their file names.
    Earlier my filename was 'LED Blink'. Then changed it to 'LED_Blink.asm' & it started working with zero errors & zero warnings!
    You might want to check it & mention it in your Tutorial. I spent 5-10 hrs trying to find bugs in my code & tried 100s of Keil settings & believe me I did not come across a single thread which addressed this..
    Pls highlight this in your tutorial as it would help a lot to someone.
    Thanks again & Cheers!

    ReplyDelete
  8. Correction in last comment --> In 3rd sentence, it is 'LED Blink.asm' & not 'LED Blink'

    ReplyDelete
  9. hey I have executed and got the the output I wanted..
    thank you so much

    ReplyDelete
  10. i cannot find target device, it is all empty, in placer of cpu, it is showing nothing,,,,

    pls help me asap.....
    gauravpayal001@gmail.com

    ReplyDelete
  11. Great work but why my u vision is not showing any AT89CXXX file in atmel part... please he me with this...and please upload or send me your u vision by mail Ravichaudhari712@gmail.com or FB.com/rvch7 please help...You are Great..!!

    ReplyDelete

Post a Comment

Popular posts from this blog

Multiplex 4 Seven Segment Display With 8051 In Assembly

Multiplexing is very essential part while working with 8051 because of its limited number of ports. which offer 32 pins for connecting external devices. 32 seems large but when you working with seven segment, keypad, LCD, ADC etc. or if you project have many parts to operate simultaneously then you definitely need to multiplex some of ports.

LCD Interfacing with 8051 in 4 bit mode : assembly tutorial

Hello friends, in this tutorial we are going to interface LCD with 8051 microcontroller but in 4 bit mode. we already interfaced LCD with 8051 in 8 bit and also done scrolling of text in previous tutorials.

how to get 7805 in multisim - Replacement of 7805 in multisim

  finding some parts in multisim is really tough work because multisim  not provide all general purpose component like 7085 and other voltage regulator. one more  bad information is that manufacturer of these component also not provide any PSPICE because output of these component are predetermined and not changed according to the circuit.