Line 4: Line 4:
  
 
=Keil Setup Steps=
 
=Keil Setup Steps=
<b>Step1:</b> Open the Keil software and select the New Microvision project from Project Menu as shown below.<br>
+
<b>Step1:</b> Open the MPLABx software and select the New project from File Menu as shown below.<br>
 
+
 
+
<b>Step2:</b> Browse to your project folder and provide the project name and click on save.<br>
+
 
[[File:Pic16F877A_MplabX_Setup01.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup01.png]]<br><br>
  
<b>Step3:</b> Once the project is saved a new pop up “Select Device for Target” opens, Select the controller(NXP:LPC1768) and click on OK.<br>
+
 
 +
<b>Step2:</b> Selcet the Standalone option for the project.
 
[[File:Pic16F877A_MplabX_Setup02.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup02.png]]<br><br>
  
<b>Step4:</b> Select the controller(NXP:LPC1768) and click on OK.<br>
+
 
 +
<b>Step3:</b> Choose the Controller(PIC16f877A) from the device drop down.
 
[[File:Pic16F877A_MplabX_Setup03.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup03.png]]<br><br>
  
<b>Step5:</b> As LPC1768 needs the startup code, click on <b>Yes</b> option to include the <b>LPC17xx Startup</b> file.<br>
+
 
 +
<b>Step4:</b> Select the required programmer. In this case it is Pickit2 the IC(PIC16f877A) from the drop down.
 
[[File:Pic16F877A_MplabX_Setup04.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup04.png]]<br><br>
  
<b>Step6:</b> Create a new file to write the program.<br>
+
 
 +
<b>Step5:</b> Choose the xC8/Hitech compiler which ever is installed.
 
[[File:Pic16F877A_MplabX_Setup05.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup05.png]]<br><br>
  
<b>Step7:</b> Type the code or Copy paste the below code snippet.<br>
 
[[File:Pic16F877A_MplabX_Setup06.png]]
 
<html>
 
<script src="https://gist.github.com/SaheblalBagwan/cb2cf78aadc724737d79.js"></script>
 
</html>
 
<br>
 
  
<b>Step8:</b> After typing the code save the file as <b>main.c</b>.<br>
+
<b>Step6:</b> Provide the project name and select the project project folder.
 +
[[File:Pic16F877A_MplabX_Setup06.png]]<br><br>
 +
 
 +
 
 +
<b>Step7:</b> Now the required project is created. Create a new .c/main.c to write the code.
 
[[File:Pic16F877A_MplabX_Setup07.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup07.png]]<br><br>
  
<b>Step9:</b> Add the recently saved file to the project.<br>
+
 
 +
<b>Step8:</b> Save the file with C extension.
 
[[File:Pic16F877A_MplabX_Setup08.png]]<br><br>
 
[[File:Pic16F877A_MplabX_Setup08.png]]<br><br>
  
<b>Step10:</b> Add the main.c along with system_LPC17xx.c.<br>
 
[[File:Pic16F877A_MplabX_Setup09.png]]<br><br>
 
  
<b>Step11:</b> Build the project and fix the compiler errors/warnings if any.<br>
+
<b>Step9:</b> Type the code or Copy paste the below code snippet and save it<br>
[[File:Pic16F877A_MplabX_Setup10.png]]<br><br>
+
[[File:Pic16F877A_MplabX_Setup09.png]]
 +
<html>
 +
<script src="https://gist.github.com/SaheblalBagwan/cb2cf78aadc724737d79.js"></script>
 +
</html>
 +
<br>
  
<b>Step12:</b> Code is compiled with no errors. The <b>.hex</b> file is still not generated.<br>
 
[[File:Pic16F877A_MplabX_Setup11.png]]<br><br>
 
  
=Enable Hex File Generation=
 
<b>Step13:</b> Click on <b>Target Options</b> to select the option for generating .hex file.<br>
 
[[File:Pic16F877A_MplabX_Setup12.png]]<br><br>
 
  
<b>Step14:</b> Set IROM1 start address as 0x0000.<br>
+
<b>Step10:</b> Build the project and fix the compiler errors/warnings if any.<br>
[[File:Pic16F877A_MplabX_Setup13.png]]<br><br>
+
[[File:Pic16F877A_MplabX_Setup10.png]]<br><br>
  
<b>Step15:</b> Enable the option to generate the .hex file<br>
+
 
 +
<b>Step11:</b> Code is compiled with no errors. The <b>.hex</b> file is generated.<br>
 +
[[File:Pic16F877A_MplabX_Setup11.png]]<br><br>
  
  
<b>Step16:</b> .Hex file is generated after a rebuild.<br>
 
  
  
<b>Step17:</b> Check the project folder for the generated .hex file.<br>
 
  
<br><br>
 
  
 
=Uploading the Hex file=
 
=Uploading the Hex file=
 
After generating the .hex file check this tutorial for [[LPC1768: Uploading Hex and Bin files|uploading Hex and Bin files.]]
 
After generating the .hex file check this tutorial for [[LPC1768: Uploading Hex and Bin files|uploading Hex and Bin files.]]
 
<br><br>
 
<br><br>

Revision as of 16:12, 22 April 2016

In this tutorial we will see how to setup a Mplabx project to generate .hex file for Pic16f877a

Pic16F877A MplabX Setup0.png

Keil Setup Steps

Step1: Open the MPLABx software and select the New project from File Menu as shown below.
Pic16F877A MplabX Setup01.png


Step2: Selcet the Standalone option for the project. Pic16F877A MplabX Setup02.png


Step3: Choose the Controller(PIC16f877A) from the device drop down. Pic16F877A MplabX Setup03.png


Step4: Select the required programmer. In this case it is Pickit2 the IC(PIC16f877A) from the drop down. Pic16F877A MplabX Setup04.png


Step5: Choose the xC8/Hitech compiler which ever is installed. Pic16F877A MplabX Setup05.png


Step6: Provide the project name and select the project project folder. Pic16F877A MplabX Setup06.png


Step7: Now the required project is created. Create a new .c/main.c to write the code. Pic16F877A MplabX Setup07.png


Step8: Save the file with C extension. Pic16F877A MplabX Setup08.png


Step9: Type the code or Copy paste the below code snippet and save it
Pic16F877A MplabX Setup09.png


Step10: Build the project and fix the compiler errors/warnings if any.
Pic16F877A MplabX Setup10.png


Step11: Code is compiled with no errors. The .hex file is generated.
Pic16F877A MplabX Setup11.png




Uploading the Hex file

After generating the .hex file check this tutorial for uploading Hex and Bin files.