There are two parts to this software/firmware section:
-Writing The Program
-Compile In MPLABX
The program we're creating is as simple as it gets. A forever while loop, two for loops for delays and then on/off switching of an LED on PORTA. Nothing complicated, we're just trying to make sure we can successfully compile, build and program something onto the PIC.
LED Flasher Program
------------« Begin Code »------------
/************************************ Author: Chris @ PyroElectro.com Date: 4/5/2012 Description: This is a test program to make sure we can upload programs to a PIC 18F452 using the PICKit3 programmer made by Microchip. The delays inside the while loop create the effect of an LED blinking off of PORTA. ************************************/ #include#include #pragma config OSC = HS // Oscillator Selection:HS #pragma config WDT = OFF // Watchdog Timer #pragma config LVP = OFF // Low Voltage ICSP(PIN 6):Disabled void main(void){ //New Integer Counter unsigned int cnt = 0; //Clear PORTA TRISA = 0x00; PORTA = 0x00; //Forever While Loop while(1){ PORTA = 0x00 Delay10KTCYx(250); PORTA = 0xFF; Delay10KTCYx(250); } }
------------« End Code »------------
We will compile and download the program to the PIC in the data & observations section when we prove the system works and show an action video.