The C32 compiler that comes as part of the install package for MPLAB has several example projects. They can be found in <install path>\Microchip\MPLAB C32 Suite\examples. I chose the project "led_message" for my first compile job. It blinks the LEDs on the Explorer 16 development board which seemed ideal to me since it would be obvious if my program image was running on the PIC or not. The source code contains a good description of exactly what the code is trying to do:
/*
** Message in a bottle
**
** Explorer16 version (long delays)
**
** Thanks to Lucio DiJasio for letting us use this example.
**
** Run this example on Explorer-16 board with PIC32MX PIM.
** Hold the board vertically from the PICtail connector size
** and wave the board back-and-forth to see message "HELLO" on LEDs
*/
** Message in a bottle
**
** Explorer16 version (long delays)
**
** Thanks to Lucio DiJasio for letting us use this example.
**
** Run this example on Explorer-16 board with PIC32MX PIM.
** Hold the board vertically from the PICtail connector size
** and wave the board back-and-forth to see message "HELLO" on LEDs
*/
To compile the code I opened the projects MCP file and selected the PICKit3 as my programmer under the Programmer --> Select Programmer sub-menu. This caused the programmer to connect to the board and triggered an error message that the device ID read by the PICKit3 did not match the device the project was setup for. To fix this I selected the PIC processor I was using by selecting Configure --> Select Device... and choosing my device from the dialog box. After this I built the project using Project --> Build All and then programmed the device using Programmer --> Program. After programming was completed the program started running on the PIC and the LEDs started blinking. My next project is to develop my own program and run that on the PIC.
No comments:
Post a Comment