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
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 )
After saving your file this new window open to select you CPU
Right click on Target Group >> and select Option for Target
A dialog box open as shown in below image
Change the setting as shown in Red Area (for Target and Output )
Now make a new file and save it with .asm extension (myproject.asm)
and put this test code in file and save
Now build you code to debug and find error
Now click on Debug Tab and then Select port 1 form Peripherals Tab
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 imageStep 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 )
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
Step 4: Target setup
Right click on Target Group >> and select Option for Target
A dialog box open as shown in below image
Change the setting as shown in Red Area (for Target and Output )
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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now build you code to debug and find error
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
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.
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...
ReplyDeleteTo 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..
which version of keil you use and controller.
ReplyDeleteI'm using Keil v9.01 which comes with Uvision4 IDE.
ReplyDeleteI 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.
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.
ReplyDeleteDid 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.
ReplyDeleteNow 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!! :)
welcome buddy... send me your project files.. zip your Keil Project folder and mail me..
ReplyDeletenetsmertia@gmail.com
Figured it out!! Can't believe the problem was so small..
ReplyDeleteApparently 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!
Correction in last comment --> In 3rd sentence, it is 'LED Blink.asm' & not 'LED Blink'
ReplyDeletehey I have executed and got the the output I wanted..
ReplyDeletethank you so much
i cannot find target device, it is all empty, in placer of cpu, it is showing nothing,,,,
ReplyDeletepls help me asap.....
gauravpayal001@gmail.com
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