• Below example demonstrates the step by step procedure to include the libraries into any applications.

Step 1: Open the Mplab software and select the Project Wizard from Project Menu as shown below. Open mplab.png


Step 2: A new window opens which will guide to create and configure the project. Click next to proceed. Guide createproj.png


Step 3: After clicking next a new window opens to select the device, select Pic16f877A from the drop down and click next. Step one.png


Step 4: Once the device is selected a new window opens to select the compiler, select Hitech Universal ToolSuite from the drop down and click next.
Note:

  • Ensure the HiTech tool chain is installed before creating the project. Evaluation version of Hitech Compiler is embedded in Mplab Setup which needs to be installed along with Mplab.

Step two.png


Step 5: Upon selecting the ToolChain, Browse to the project folder and provide the suitable project name and save it. . Step three.png


Step 6:

Project saveas.png


Step 7: Click next to proceed as there are no files(.c/.h) to be added at this stage. Step four.png


Step8: Finally click finish to create the project. Now the project will be created with no initial files. Summary.png


Step 9: Create a new .c file to write the main program. Create newfile.png


Step 10: Write your program using the library functions and save it.
Note:

  • Include the respective header files before calling any library functions.

Program using library.png

Program using library1.png


Step 11: Provide the suitable file name(main.c) and save it in the same project folder. Suitable name.png


Step 12: Include your source files to the project.. Include sourcefile.png


Step 13: Select all the source files which needs to be included in the project and click open.
Note:

  • Library files should be copied to the project folder before including them into the project

Select allsrcfiles.png


Step 14: Include your header files to the project.. Include headerfiles.png


Step 15: Select all the header files which needs to be included in the project and click open. Select allheaderfiles.png


Step 16: The included files will be visible in the left side project navigator, if any file is missing then it should be copied to the Project folder and included as shown in step 11.

  • Compile the project by clicking on Build as shown below Project complies if there are no errors. If there are any errors fix them and re-compile.
Compile.png


Step 17: Once the project is built(compiled), hex file will be generated with the project name in the selected project folder. Hex files.png

                                                Configuration Bits

Step 18: Configuration Bits : Select the Configuration bits option from Configure menu. Select configuremenu.png


Step 19: Uncheck the “Configuration bits Ste in Code” and update the configuration bits as below to get value as 3F3A. Finally check the option “Configuration bits Ste in Code” to save the configuration.

Configurationbits in Code.png


                                           Flashing the hex file into the controller  

Step 1: Connect the Pickit2/3 programmer and select the same from programmer drop down menu. Connect the Pickit.png


Step 2: Once the programmer is detected below message will be displayed, if there is any errors double-check the connection and follow step1. Message.png


Step 3: Once the programmer is connected click the program option from the prommer menu to program the IC. Program the IC.png


Step 4: The controller will be programmed and the application starts running else reset the targed. Debug.png