PICkit 2 as an AVR programmer
We have a Microchip PICkit 2 on the electronics bench. It lives in the cardboard tray at the woodstore end of the shelves, with the logic analyser. There should be two 12 cm programming cables with it - grey ribbon cable with black ends - 6 pin SIL M-F for Microchip PIC ICSP, and 6 pin SIL M to 3x2 F for Atmel AVR ISP, and also an 18 cm 6 pin SIL M to individual colour coded pins breadboard programming cable.
These are User:IanM's installation notes.
AVRDUDE support
Recent versions of AVRDUDE support Microchip PICkit 2 as an AVR ISP programmer. Use command line option: -p pickit2
Installation (Windows)
I assume you already have AVRDUDE, and possibly a GUI for it installed.
Run Zadig (from https://zadig.akeo.ie/ ) and do 'Options=>'List all devices'. Select the PICkit 2 and install the WinUSB (libusb) driver. If problems occur later return to this step and try the libusbK driver.
Alternatively (my preference) use libusb-win32 and install a filter driver for the PICkit 2 so both AVRDUDE and the PICkit software can use it. N.B. libusb-win32 v1.4 filter installer is broken on Win10+. Use Zadig to get libusb-win32 installed with the files in the right place, then device manager to revert to the OEM or Microsoft driver (without deleting any files), then reinstall the driver as a filter using libusb-win32 v1.4 filter installer.
Reverting to PICs
N.B. If not using a filter driver, to revert the PICkit 2 to the original USB HID driver for use with MPLAB or the PICkit 2 GUI or command line PIC programming utility you need to 'De-Zadig' the PICkit 2 by uninstalling it from Device Manager, selecting the option to delete all drivers, then scan for hardware changes to let windows reinstall it.
Arduino IDE Support
To add PICkit 2 as a programmer in the Arduino v1.8x IDE, append the following lines to "programmers.txt" after making a backup copy:
# User added PICkit 2 pickit2.name=PICkit 2 pickit2.communication=usb pickit2.protocol=pickit2 pickit2.program.protocol=pickit2 pickit2.program.tool=avrdude pickit2.program.extra_params=-v -V
If Arduino IDE 1.8x is installed for all users, that can be found at "C:\Program Files (x86)\Arduino\hardware\arduino\avr\programmers.txt", but if its only installed for the current user, or if you have upgraded or downgraded the AVR core, it may be at "C:\Users\<your_user_name>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\programmers.txt", which is easiest to find by doing File => Preferences in the IDE, clicking the link for preferences.txt at the bottom of the Preferences dialog and in the resulting explorer window, drilling down through packages etc. till you reach programmers.txt. You *MUST* restart the IDE to see the added PICkit 2 programmer in the Tools => Programmer: ... menu.
Test the installation by selecting PICkit 2 as the programmer in the Arduino IDE and, with an AVR based board selected but no target connected, do 'Burn bootloader'. You should get a long and detailed report ending:
avrdude: MicroChip's PICkit2 Programmer firmware version 2.32.0 avrdude: initialization failed, rc=-2 Double check connections and try again, or use -F to override this check. Error while burning bootloader.
Connections to an AVR MCU
The PICkit 2 pin 1 is identified by a white arrow on the upper case.
Pin assignments are:
PK2| AVR |2x3 ISP|2x5 ISP|Breadboard| ATmega328P pin| Signal |header |header |ICSP cable| DIP pin ===|===========|=======|=======|==========|========== 1 - RST - 5 - 5 - Yellow - 1 + 10K pullup 2 - Vcc Targ. - 2 - 2 - Red - 7,20 } + 100nF 3 - Gnd - 6 - 10 - Black - 8,22 } decoupling 4 - MISO - 1 - 9 - Blue - 18 (PB4/D12) 5 - SCLK - 3 - 7 - White - 19 (PB5/D13) 6 - MOSI - 4 - 1 - Green - 17 (PB3/D11) ┌─┐ >│1│ ┌───┐ │2│ ┌───┐ │1 2│ │3│ │1 2│ │3 4│ │4│ 3 4│ 5 6│ │5│ │5 6│ │7 8│ │6│ └───┘ │9 o│10 └─┘ └───┘
Also see https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader/all