Monday, September 27, 2010

How generate a Hex file and Burn it into PIC??

Now that you know how to write code, you need to know how to get your code into the PIC. The process of programming a PIC is often referred to as “burning”. To burn code into the PIC, we will be using the windows version of MPLAB.

In the MPLAB program, all the information about your program is stored in a project files. Project files contain information about the program, the device you’re using, one or more assembly language codes and compiled hex files. The process of burning a PIC contains three major steps. The first is to write the code in assembly language. Once the code is written, it must be compiled into a hex file for programming into the device. After successfully compiling the code, the final step is to program the device.

Begin by opening up the program MPLAB.

Create a new project by going to Project>New Project. In the new project dialogue box select a directory to place the project in and give the new project a name. When you’ve finished, click “Ok”.

You will now see the Edit Project dialogue box. Select the appropriate device, and set the development mode to MPLAB-SIM Simulator. In the project files window click the file that has the name of your file with a .hex extension. Click on the Node Properties button and in the window that appears, click “Ok”. This sets default node properties and allows you to add nodes later.

Exit the Edit Properties box by clicking “Ok”.

Now you may create assembly code. Got to File>New. A blank text editor box should appear. Enter your assembly code into this window. When you are done, save the code (File>Save, give the code a name and click “Ok”).

You must now assign the source code you just made to the project. Go to Project>Edit Project. In the Edit Project dialogue box, click the Add Node button. Browse to find the assembly code you just found. Select it and click “Ok”. The file name for the assembly code should now appear in the window. Click “Ok” to close the Edit Project box.

Now that the source code is associated with the project, its time to compile the code. Go to Project>Make Project. If the compile is successful, you will see the Build Results window appear with the message “Build completed successfully”. If there were errors they will be listed in the window. After compiling successfully, save the project (Project>Save Project).

The final step is to program the device. Select Picstart Plus>Enable Programmer. The Programmer Status dialogue box should appear. At this point, you should have the Picstart Plus device programmer plugged in and th serial cable connected to the serial port on your computer. Place the PIC in the ZIF socket with pin 1 in the top left corner, and lock it in place.

1 comment:

  1. STC Technologies also offers exclusive Library support and Individual Courseware for each module. STC Technologies

    ReplyDelete