In this example I am using P89V51RD2 micro-controller, MCU 8051IDE for programming on micro-controller and p89pgm-0.1.0 for burning Hex file into the P89V51R2 chip.
MCU 8051 IDE
MCU 8051 IDE is a free software integrated development environment for microcontrollers based on 8051. MCU 8051 IDE has its own simulator and assembler (support for some external assemblers is also available). This IDE supports 2 programming languages: C and Assembly language. For C language it uses SDCC.
Installation on MCU 8051 IDE
Open Ubuntu Software center by clicking on Dash Home icon on the left top corner of your screen and searching for the Ubuntu Software Center application.
After opening Software canter you search for MCU 8051 IDE, when you find MUC 8051IDE you can click on More Info button. Before doing this make sure that INTERNET is connected.
After clicking on More Info the following window will appear. To install the IDE click on Install button.
Writing first C program in MCU 8051 IDE
Open MCU 8051 IDE from Ubuntu applications. After opening IDE you can see a window something like a window shown below.
Creating new project
To create a new project click on Project → New from the main menu of IDE. After selecting the New option from project following window will appear. Write the project name and specify the project directory and select the processor AT89S51 (this will also work for P89V51RD2 IC ) and click on OK
Writing C program
Write the C program in the editor window of IDE, you can also copy and pest the
following code to your editor and save the file with ( .c ) extension.
/****************************************************
***** this code will blink the LEDs connected ******
*****on Port P0 ******
***** Author : Bahubali Fuladi ******
***** Date : 08032014 *****
****************************************************/
#include<at89x51.h>
/******** function for delay **********************/
void delay()
{
unsigned char i,j;
for(i=0;i<200;i++);
{
for(j=0;j<250;j++);
}
}
/******** main function *************************/
void main()
{
while(1)
{
P0 = 0x00; //shitch ON the LEDs
delay(); //wait for some time
P0 = 0xFF; //switch OFF the LEDs
delay(); //wait for some time
}
}
Compiling your C Program
To compile your C code click on Tool → Compile (F11) from main menu. If there is no error in C code then Compilation successful message will appear on Message window. The HEX file will automatically be generated after compilation.
Simulation
To start simulation click on simulator → start/shutdown (F2) from main menu, this will show all the SFRs and internal resistors of 8051 in the simulator window. You can also connect some virtual hardware from Virtual HW menu. After connecting the virtual hardware click on Simulator → Animate to see the output on virtual hardware, you can also see the contains of all SFRs during simulation.
Burning Hex File into the P89V51R2
To write Hex file into the chip you have to first download a tar file of software p89pgm-0.1.0 . The downloaded file will be in tar format (tar is compressed file format) so first you have to un-tar the tar file. To un-tar right click of the file icon and select Extract here option this will create a folder with name “p89pgm-0.1.0”. (Note : copy p89pgm-0.1.0 folder in to your Documents folder).
Making the executable of burning software
open the Linux Terminal by pressing keys Ctrl+Alt+T here you write the following commands.
First change the directory to p89pgm-0.1.0 by writing the following commands.
$ cd Documents/p89pgm0.1.0/
Now write the following command to create the executable
$ make
now you are ready to burn your chip.
connect your 8051 Kit to the PC using RS232 serial cable (USB to RS232 it serial port is not available on your PC) and power on your 8051 Kit. To burn the chip write the following command
$ ./p89pgm ../IDE_test/IDE_test.hex /dev/ttyS0
this command is divided into three parts first the name of executable starting with ( . / ) second the complete path of your hex file and third is the path of your serial port (if you are using USB to Serial module then give path /dev/ttyUSB0) after executing this command it will ask you to reset your 8051 board. And after reseting the hex file writing will start. Reset your board again after the burning process id done. and see the output by connecting LEDs on port0 of 8051.
This comment has been removed by the author.
ReplyDeleteplz send ur mail id i am facing error in mcuide 8051
ReplyDeleteBpfuladi@gmail.com
Deletechaya.ravindra@gmail.com
ReplyDeleteNice explanation on 8051.
ReplyDeleteIs it possible to program the other 8051 IC's using same p89pgm script?
Is this IDE supports assembly language
ReplyDelete