Experiences with Microchip® PICkitTM2 programmer

(latest page update: 22 December 2013)

PICkitTM2 programmer deliverables

{PICkit 2} There are several Microchip packages of the PICkit 2 programmer:
DV164120 PICkit 2 Starter Kit (programmer + 1 populated prototype board)
PG164120 PICkit 2 Microcontroller Programmer
DM164120-1 PICkit 2 Low Pin Count Demo Boards (programmer, 1 populated prototype board, 2 bare boards)
DV164121 PICkit 2 Debug Express (programmer + 44-pin populated demo board)
DM164120-2 PICkit 2 44-pin populated Demo Board

I obtained the Programmer package, which contains:

Click here to visit the Microchip site for PICkit 2 programmer and check which PIC microcontrollers are supported!

First impressions

The programmer is a cute little box, smaller than I expected by looking at the Microchip pictures. It measures only 10 x 4 x 1 cm.

The provided software from the Starter Kit CD installed without problems. Programming a PIC® microcontroller - I tried a PIC16F630 first - went smoothly and fast compared to a Wisp628!

Contents of the CDROMs

The CD with MPLAB IDE. It contains among others:

The CD labeled "PICkit 2 Starter Kit" contains several directories with:

PIC microcontroller programming with the PICkitTM2 programmer

The PICkit 2 programmer is an In-Circuit Serial ProgrammingTM device or short ICSPTM device. The target PIC microcontroller has to be mounted on its board and connected to the programmer. The cable connections with schematics are described in the User Manual.

The PICkit 2 starter kit does not contain a cable to connect programmer with a target board, so I had to make a cable with a 6-pin connector on the programmer's side.

There are some restrictions on the use of pins of the target PIC microcontroller which are (also) used for downloading the program to the target. These requirements are clearly described in the Users Manual.

The programmer is powered via the USB cable connected to the PC. It can also power the target board, but this has a limit of 100 mA. The target board may also be powered by another source.

Firmware updates

My programmer came with firmware 1.0.1 installed. This can be checked with the programmer software on the PC. Newer firmware can be downloaded from the Microchip site, but the PICkit 2 programmer discussion group at Google has also updates.

Replacing the programmer firmware with the standard (Windows) software is simple. There is a special menu option, which allows you to select the appropriate hex file. I'm currently running firmware 1.10.0 (PK2V011000.HEX), which - in combination with version 1.10 of the PC software - supports many more chips than version 1.0.1. See the PICkit 2 page at the Microchip site for details.

Target environment


The PC software delivered with PICkit 2 programmer is for Windows only. My goal is to get the PICkit 2 programmer working under eComStation. A couple of programmers is developing Linux software for the PICkit 2 programmer, and I'll try to port this software to eComStation. This software is based on 'libusb', an open-source project for Linux, Windows, MacOS, eComStation and other platforms. The Libusb driver for Linux can be downloaded from SourceForge, as well as the Libusb driver for Windows. The Libusb driver for eComStation is available from Hobbes.

The PICkit programmer discussion group is a Google group.

Available software

The PICkit programmer development group has 2 parallel development streams:

The developers of both programs use Linux as their development platform. Python exists for many platforms and python programs are supposed to be platform independent and pyk should run on all platforms.
Note: pyk supports also PICkit 1!

The pk2 executable is primarily tested on Linux, but the source is provided and should be compilable on other platforms (with GCC compiler). See the site of Jeff Post for PK2 and other PICmicro material.
A Win32 package of pk2 is distributed by Xiao Fan Chen.

Programming specifications

For each of the supported chips a number of programming parameters have to be available to the programming software. The Microchip software contains a table in binary format. I have written a Rexx script to convert the table to a human readable format. The Rexx script and the listing are in a ZIP archive available for downloading.

Using pk2 under Linux

I have Linux SuSE 10.0 installed (Kernel 2.6.13-15). After installing libusb for Linux, and compiling pk2 on my system it proved to be working with my PICkit 2 programmer.

It is a rather simple commandline-oriented application, no Graphical User Interface, much like my XWisp2. It is still in an early state of development, but already an alternative for Linux users, but it may not support the same set of PICmicros as the Microchip software.

Building pk2 for eComStation


I chose to use pk2.c for my base to build an eComStation version since I'm more familiar with C than with Python.

The pk2 program compiled without major problems with GCC 3.3.5 + EMX (the file doscalls.a was missing from the Libusb package for eComStation, but could be reconstructed with EMXLIB). After that pk2 could be built without problems.

However when running pk2 a problem arises, probably with the Libusb driver for eComStation.

PICkit2 to Wisp628 cable

Since I used to use Wisp628 as programmer most of my devices have a connector for re-programming by Wisp628. To be able to use the PICkit2 for these devices a converter cable is required.

{PICkit 2 to Wisp628 cable}
Both programmers use the same programming method (ICSP) and connections to the target device, only in a different sequence. In the case of Wisp628 the programmer is powered by the target, but with the PICkit 2 the target is (normally) powered by the programmer. This does not conflict! A 5-wire cable like on the photograph will do!

Another USB device driver

Recently I found on the in eComStation circles well know repository 'Hobbes' an alternative for libusb: USBecd10, a package containing a USB device driver providing a standard file I/O interface for applications desiring to access a USB device.

Although I would prefer to use libusb, which is available cross-platform wide, this could be an alternative if the problems with the eComStation version of libusb are not solved in a reasonable period. I already did some experiments and it works nicely. I might consider building a USB version of XWisp2!

{under construction}
.... more later ....

PIC and MPLAB are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.
PICkit, ISCP, In-Circuit Serial Programming are trademarks of Microchip Technology Inc. in the U.S and other countries.