In this tutorial, you will learn how to program a PIC using in-circuit serial programming with the MPLAB Snap debugger/programmer. This will be critical for your semester project as you will be working with a surface mount microcontroller that cannot be easily removed for offboard programming and does not have a USB port.
At the end of this tutorial you will be able to:
| Item | Description |
|---|---|
| In-circuit debugger/programmer | MPLAB Snap (3-D printable enclosure) |
| PIC 18F47K42 microcontroller (Got Sp ‘26) | Part Website (datasheet) |
| Voltage Regulator | Can use either the adjustable regulators located at the lab benches, or one on your breadboard. Set to 3.3V |
| Breadboard | |
| LED | |
| Resistors | Various, as described in the datasheets below and to limit current going through the LED |
| Capacitors | Various, as describedin the datasheets |
| Jumper wires | |
| Micro USB cable | |
| Male to male header |
Read and search the MPLAB Snap In-Circuit Debugger User’s Guide to find answers to the following questions:
Read and search the Pin Diagrams and ICSP sections of the PIC18F47K42 Datasheet to find answers to the following questions:
Set the BK Precision DC power supply to output 3.3V. Then, turn off the power supply before connecting it to your circuit.
Wire up your breadboard to connect the Snap and the PIC18F47K42-I/P according to what you learned above. Make sure to connect all of the VDD and VSS pins in addition to the external 3.3V power supply. Whenever there is conflicting hardware configuration information between the Snap manual and the PIC18F47K42 datasheet, follow the PIC datasheet as every PIC is a bit different and the Snap works with a number of different PICs.
Tip: If you attach an 8-pin male to male header to your breadboard (or PCB) then it makes it easier to quickly connect and disconnect the Snap from your circuit. |
Launch MPLabX and create a new project. Set it up for use with the 18F47K42 DIP version and the simple LED blink code from this tutorial.
Compile the project and fix any errors.
Turn on the external power supply and connect the Snap to your computer.
Download your code to the microcontroller. You should see the LED blinking on and off. If this step doesn’t work, debug by first checking all connections against the data sheet, looking for error messages in the IDE, and searching for the error messages on Google. Also see the MPLAB Snap Troubleshooting Guide for more information.