Programming PIC18F Chips


ICSP

The pin-out for Microchip standard 6-pin connector for In-Circuit Serial Programming (ICSP) is listed in table below:

Pin Function
1 _MCLR/Vpp (programming voltage)
2 Vcc(+5V)
3 GND
4 Data
5 Clock
6 LVP (low-voltage programming mode control)

 

PICkit 2

 

There are many PIC programmer available, commercial and DIY devices. As Microchip introduces the new microprocessors the programming software got to be updated accordingly playing catch-up with the PIC manufacturer. That is the root of the problem with third-party PIC programmers. Microchip's PICkit 2 is the low cost ICSP programmer for Flash PICs with USB interface introduced by Microchip. Only subset of PIC microcontrollers is supported, but the list is including all the recent devices from PIC16, PIC18 and PIC24 families and certainly covers all the PICs you are most likely want to use. It is fully integrated with Microchip’s MPLAB IDE and allow not only program but debug applications as well. As alternative you can use the standalone programmer applet, see picture below.

 

The PICkit 2 has USB bootloader and capable of updating the programmer firmware directly from Microchip web site. Every time the PICkit 2 programmer application is launched, it will check the firmware version of the PICkit 2 to see if it is the latest version. If not, it will attempt to automatically download the latest version. The software upgrades are free and Microchip updates them in timely fashion. Even more, the firmware and schematic are freely available. Apparently Microchip has made the open design intentionally, see it as the way to boost using the popularity PIC microprocessors. With such simplicity of design it is easy to build a clone version. The Sure Electronics is making a good clone and it comes with ICSP cables, see the Products page. My first PIC programmer was Melabs EPIC device with parallel port interface. After upgrading my PC I have realized that parallel port became legacy these days, as the most of new PC motherboards do not have it all. The another annoying part about Melabs programmers in general is that even if you buy the full package (hardware + software) upgrades are not free and only beta stuff available for download. I have successfully burned all my PIC18 and PIC24 chips using PICkit 2 and would definitely recommend it.

 

 

PICkit 3

PICkit 3 was introduced recently and supersedes  the PICkit 2.It is build around PIC24FJ256GB106 16-bit PC device. The Microchip states that the PICkit 3 differs from the PICkit 2 by providing:

  • Extended EE program image space (512 Kbytes)
  • True voltage reference
  • Increased voltage range (1.8-5V VDD; 1.8-14V VPP)
  • Doesn't have standalone programming application and can be used only with Microchip IDE

Some of the latest PICs being supported by PICkit 3 but not PICkit 2, it looks like eventually PICkit 2 will be phased out.

 

DIY PICkit 2

PICkit 2 was originally built by Microchip as open design programmer with the schematic, source code and firmware available to boost the popularity of the PIC devices. Because of that it is easy to build a clone version of the original device. Most of the clones will produce unregulated 5 volt VPP where the original Microchip PICkit 2 provides adjustable VPP output to allow 3.3 and 2.5 volt parts programming. The schematic I have used is based on the original PICkit 2 without programmer-to-go functionality. That functionality allowing a hex file to be downloaded to the PICkit 2 to later program PIC microcontrollers without a PC with a simple pressing programmer's push button. I do not think that functionality is required for a hobbyist but allows simplify the schematic by omitting two 24C512 EEPROM chips. The Eagle Files designed using only thru-hole mounting parts.

 

 

Building PICKit 2 clone is facing a chicken-egg problem as another programmer is required to program the firmware into the PIC18F2550. Once the PIC18F2550 chip for PICKit 2 is programmed, you can the upgrade the firmware as it includes USB bootloader. The latest PICkit 2 firmware version is available from Microchip and the current version is also is available on the site - click here to download!

 

 

Parts List

The DIY PICkit 2 part list for the two the most popular electronic components vendors, Mouser and DigiKey is shown below.

Part Description Mouser # DigiKey #

J1

USB type B connector 737-USB-B-S-RA 609-1039-ND

IC1

PIC18F2550 579-PIC18F2550-I/SP PIC18F2550-I/SP-ND

IC2

MCP601P 579-MCP601IP MCP601-I/P-ND
Q1,Q4,Q6 BS250P 522-BS250P BS250P-ND
Q2,Q3,Q5,Q7 2N7000 512-2N7000D26Z 2N7000FS-ND
D1,D2 BAT85 78-BAT85S 568-1617-1-ND
D3 Green 5mm LED 604-WP7113SGD 754-1263-ND
D4 Yellow 5mm LED 604-WP7113YD 754-1284-ND
D5 Red 5mm LED 604-WP7113ID 754-1264-ND
X1 Crystal, 20.000Mhz 815-ABL-20-B2 XC1723-ND
R1,R3,R4 10K Ohm 291-10K-RC 10KQBK-ND
R6,R10,R13 10K Ohm 291-10K-RC 10KQBK-ND
R2,R7,R8 470 Ohm 291-470-RC 470QBK-ND
R5,R14 100 Ohm 291-100-RC 100QBK-ND
R9,R12,R22 2.7K Ohm 291-2.7K-RC 2.7KQBK-ND
R11,R16,R20,R21 4.7K Ohm 291-4.7K-RC 4.7KQBK-ND
R15 1K Ohm 291-1K-RC 1.0KQBK-ND
R17,R18,R19 33 Ohm 291-33-RC 33QBK-ND
C1,C4,C7,C10,C11 0.1uF 871-B32529C104K189 495-2532-ND
C2,C3 22pF 140-50N2-220J-RC 490-4175-ND
C5,C8 10uF 647-UVR1V100MDD1TA 493-1036-ND
C6 0.47uF 871-B32529C474J 495-2560-3-ND
C9 47uF 16V 647-UVR1C470MDD1TD 493-1039-ND
L1 680uH 652-RLB0608-681KL 811-2051-ND
S1 Pushbutton 506-FSMCH 450-1665-ND

 

Setting Unit ID

The programmer can be assigned a Unit ID to identify it uniquely. After the fresh firmware programming the device applet is always showing the funny ID
"ID= OIHoss". It could be reset to not-assigned or set to any value by selecting “Tools>Calibrate VDD & Set Unit ID” menu, see picture below.

 

 

Calibration

Calibration allows greater the VDD voltage accuracy. Note that as the calibration is dependent on the USB voltage and moving the PICkit 2 unit to a different USB port, to or from a USB hub or to another computer port may invalidate the calibration. To calibrate the PICkit 2 unit, a digital multi-meter is required. Disconnect the PICkit 2 unit from the target and select "Tools>Calibrate VDD & Set Unit ID". to bring up the calibration wizard. Follow the steps in the wizard to complete the calibration process.

 

 

Troubleshooting DIY PICkit2 assembly

You can use "Tools->Troubleshoot" menu to help with resolving connectivity from the PICkit 2 to the target device. This is also useful where there are the device assembling errors, as providing step-by-step output validation process.