PIC 12F/16F/18F quick start
From DP
Contents |
Features
- Huge selection of chips, many still in DIP packages
- One inexpensive device (PICkit/ICD, see eBay for clones) programs and debugs most PICs
- Previously famous for a generous sampling program (now dead)
Reference
Development and programming
IDE and compiler
- Microchip's IDE called MPLAB
- MPLABX is Microchip's new cross-platform IDE and compilers for Windows, Linux, and Mac
- Microchip's C18 Compiler for PIC 18F
- Microchip's C30 Compiler for PIC 24F/33F
We use Microchip's free demonstration compilers with MPLAB. The demo compilers have certain optimizations that expire after 60 days, but we don't use those anyway.
There are many third-party C, BASIC, and Pascal compilers too
- SDCC is an open source compiler for some PICs
Programmers
One inexpensive device (PICkit/ICD, see eBay for clones) programs and debugs most PICs
- PICkit
- ICD
- Build your own ICD clone
Bootloaders
PICs do not ship with a bootloader, but there are many that you can program yourself. After the bootloader is installed, a programmer is no longer needed for simple firmware updates.
- ds30 Loader serial bootloader for most PICs (GPL), our favorite
- Diolan USB HID bootloader for PIC18F (GPL), another favorite
Basic circuit
Power
- Connect all the supply pins to power or ground. Don't forget the AVcc and AVdd pins
- Put a 0.1uF decouple capacitor on each positive supply pin, and put it as close to the chip on your PCB as possible.
Reset
Two schematics: with and without MCLR diode
- Reset is MCLR/VPP (voltage programming) on PICs
- Connect a resistor from MCLR to the supply voltage for normal operation, use 10Kohms for 12/16/18, use 2Kohms for 24/30/33
- 12F/16F/18F - The programmer puts 12-13volts on MCLR to put the PIC in programming mode. Use a small diode between the supply voltage and resistor to protect the supply voltage from the 13volt programming voltage
- 24F/30F/33F - The programmer holds MCLR low and enters a key to start programming mode. No high voltage is used, no protection diode is needed.
Programming connections
PICs use a 5 wire programming connection called ICSP in PIC datasheets.
- VPP/MCLR - This pin is also the PIC reset pin. Used to enter programming mode, and reset after programming
- Supply voltage (from programmer, or to programmer)
- Ground
- PGC - Program clock
- PGD - Program data, a bi-directional data pin
Programming a PIC usually requires connecting these five pins to a programmer.
Newer/larger PICs may have multiple pairs of PGC and PGD pins, connect any pair you like. You need to use the same pair (PGC2 and PGD2, for example), and it's usually best to check the errata to be sure the pair you chose actually works.
