Skip straight to the Step-by-Step PIC Programming section.
Microchip makes hundreds, or possibly thousands, of different flavors of PIC and dsPIC micro-controllers. They come in 8, 16, and 32 bits and offer a wide variety of different embedded peripherals, packaging options, processor speeds, and pricing. One of the main attractions of the PIC line is all the integrated circuitry available. This includes FLASH (for program), RAM (stack and variables), EEPROM (for persistent data), digital I/O, and many peripherals - comparators, A/D converters, D/A converters, OpAmps, serial I/o (UART, I2C, I2S, QSPI, SSC, USB, and CAN), PWM controllers, LCD drivers, Touch control interfaces, and timers. Not every chip contains all these options, but fortunately, Microchip provides an online selection tool: Microchip MCU Selector.
PIC Software Development Environment
PIC applications are typically developed using Microchip’s MPLABX Integrated Development Environment (IDE). MPLAB X is based on the NetBeans IDE (open sourced from Oracle) and runs on Windows, Mac OS, and Linux. MPLABX is installed on the laptops on the Micro-controller workbench (both Linux and Windows, so choose your favorite OS), or you can download your own copy from Microchip.com.
If you are new to PIC programming, check out the Step-by-Step PIC Programming page. It provides a number of "lessons" to get you started and show you how to interface to a wide range of peripherals.
PIC Hardware Development
Microchip makes some Demonstration/Evaluation Boards, but often it is cheaper and easier to just prototype the circuit you need on a standard prototype board.To help get people started there are a couple options at Fox Build:
- A PIC12F508 (8 bit, 8 pin) based board with 2 LEDs and pads to connect up to 3 more output pins. These are pre-assembled boards that run on 6-14 volts AC or 7-20 volts DC, so it should be easy to find a wall wart power supply (or batteries) to run these.
- A PIC18F4550 (8/16 bit, 40 pin) based PIC in a prototyping socket with a power LED and a single LED that can be controlled via a port pin on the chip. This option allows significantly more I/O and the PIC18F4550 supports numerous internal peripherals.
Programming (Downloading) Environment Setup
The PIC micro-controllers are generally not programmable (downloadable) via USB like an Arduino, so a special programmer is typically needed. There are several options that work:
- PICkit 2 – PIC programmer
- PICkit 3 – Newer version PIC Programmer
- ICD 3 – PIC programmer and in-circuit debugger
Fox.Build has a PICkit 2 programmer which should work for most applications. Most of the PIC micro-controllers are programmable through a 5-wire interface that consists of Power, Ground, Program Enable, Program Clock, and Program Data. This interface is provided by all of the programmers listed above. When prototyping a PIC board it is easy to run these 5 signals to 5 sequential pins on the proto board and then connect straight to them from the connections coming out of the programmer.
To connect the 12F508 boards to the PICkit2 see Connecting the PICkit2 to the 12F508 boards. Be sure to hold the connector snugly in the board during programming - you may get connection errors otherwise. To connect the 18F4550 prototype boards to the PICkit2 see Connecting the PICkit2 to the 18F4550 prototype boards.
Once the PIC is connected to the programmer (such as the PICkit2) the device may be programmed by clicking the Make and Download button (the green down arrow pointing to an IC) in MPLABX.