–Creating .HEX file from C code
—————————————————————-
In this post we shall see how to create the .HEX file ,which is finally fused on to the PIC microcontroller.
To start with create a new folder , say PICTEST inside , D:\ drive
Inside this folder you can organize all your PIC projects.Create another folder inside this , say LEDBLINK , which is our first project.
Open the MPLAB IDE .
Click on Project Wizard under Project.
Select the PIC controller IC you’ve picked up for the project.Here it is PIC16F877A from the dropdown menu. Click Next.
Next window is selection of Language suite.We’ve already installed HITECH C separately on C:\ drive.Now MPLAB IDE detects it automatically & displays under drop down list of Active Toolsuite.
Select HITECH Universal Toolsuite & its location is automatically displayed.
Click on Next.
Click on Browse & locate the project folder you created earlier in D:\ drive.
Provide a name (without any extension) for your project & Save it under the project folder.
Click Next
Next window is to add any existing files to the project.For this test project , nothing to be added .So click Next.
Final Summary of your project will be displayed , with IC selected ,location of project & the Tool Suite used.
Click Finish to see the Project window of MPLAB , where you see you project with .mcp extension.
To write your C code you need to open the built in Text editor of MPLAB IDE by clicking
FILE –> NEW
An untitled text editor window opens.
Before typing into your C code save the file by clicking File –> Save As & then provide a name to your code file .Ensure that the file has an extension .c
Now inside the project folder you can see the .c file along with other 3 files created automatically by the MPLAB IDE. The file with .mcp extension is the project file , the one with .mcw is the Workspace file & .mcs is Make file.
Type in your C code .Your C code should comply with syntax of HITECH C Compiler.Learn to use the #include header files & Define statements from the help file of HITECH C Compiler.
After typing in the C code press ctrl+s to save the file.Now the * mark over blinkled.c disappears indicating the file is saved.
Right click Source Files & select Add Files..
Browse to the location where you stored the .c file & select Open.
The blinkled.c file will appear under Source Files.
Build the project by pressing F10 or by selecting BUILD under Project.
If there is no error in your C code the BUILD will be Successful & .HEX file is generated along with other support files.
Open the project folder in D:\ drive to see the .HEX file
This is the file we’re going to fuse on to the target PIC controller IC.
Watch this video on creating the .HEX file :
Continue to the next post “Hands on Hardware “