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: 3/19/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 for loops inside of the forever while loop act like delays, which creates the effect of an LED blinking off of PIN2 or PORTA RA1. ************************************/ #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){ //Set PORTA=0 Many Times for(cnt=0;cnt<500000;cnt++) PORTA = 0x00; //Set PORTA=1 Many Times for(cnt=0;cnt<500000;cnt++) PORTA = 0x01; } }
------------« End Code »------------
Because of the parallel nature of the LCD's I/O it's very easy to send chunks of data to the LCD and we're loving sending 8-bit commands to it with a simple enable bit pulse.
A Quick Video Walk-Through
If you have never used MPLABX before, here is a quick walk-through of the process from creating a project, to setting up the C18 compiler and finally to compiling the project.
At this point, you have the hardware built, and you've just compiled the software program seen above in both the text and the video. It's game time, let's get this program loaded onto the pic and see some flashing LEDs!