Cheap DIY PIC32 Programmer

This DIY PIC32 programmer comprises a cheap Chinese Arduino NANO (under $US 3 on a certain auction site), five resistors and a zener diode. Although it can be wired up on a breadboard, using a small piece of veroboard (strip board) eliminates lots of wires and is more useful for multiple chip programming.

The huge advantage with this programmer is that there is no chicken and egg problem (ie needing a programmer to program the programmer). All Arduino NANOs come with a bootloader to allow you to program them without needing a hardware programmer :)

Hardware
Build the programmer circuit using the following diagram:



A separate piece of vero board for the handful of components helps cut down on fly wires:



Here is my breadboard version:



Software
The software comprises the mature and cross-platform pic32prg program which is available for Windows, Linux and OS X.

See https://github.com/sergev/pic32prog/ to download the latest version.

Programming Usage
1. Connect the Arduino NANO to your PC (do not connect the PIC32 chip yet) and run pic32prog as follows:

Windows: pic32prog -d ascii:com5 -b3

Linux: ./pic32prog -d ascii:/dev/ttyUSB0 -b3

OS X: ./pic32prog -d ascii:/dev/tty.wchusbserial14330 -b3

where 'com5' is the comm port the Arduino appears as under Windows, and '-b3' selects the Arduino bootloader speed. if '-b3' does not work try '-b2', '-b4', or '-b1'.

> pic32prog -d ascii:com3 -b3 Programmer for Microchip PIC32 microcontrollers, Version 2.0.174 Copyright: (C) 2011-2015 Serge Vakulenko (ascii ICSP coded by Robert Rozee) 57600 baud ... synchronized Signature = 1e950f  Device = ATmega328P ############################################   Firmware uploaded to 'ascii ICSP' adapter OK

NOTE: This only needs to be done once to program the Arduino, after which the reset line on the Arduino can be jumpered to ground for quicker serial port opening.

2. Now connect the PIC32chip to the Arduino ICSP pins and program the PIC32 as follows:

pic32prog -d ascii: 

Here is an example session programming a PIC32MX170F256B chip.

> pic32prog -d ascii:com3 MM_V4.7B23.hex Programmer for Microchip PIC32 microcontrollers, Version 2.0.174 Copyright: (C) 2011-2015 Serge Vakulenko (ascii ICSP coded by Robert Rozee) Adapter:. OK1 OK2 - ascii ICSP v1C Processor: MX170F256B Flash memory: 256 kbytes Boot memory: 3 kbytes Data: 258956 bytes Erase: (80mS) done Loading PE: 1 2 3 4 (LDR) 5 6 7a (PE) 7b 8 v0301 Program flash: ################################################# done Program boot: ####### done Verify flash: ################################################# done Verify boot: ####### done Program rate: 1607 bytes per second total TDI/TMS pairs sent = 3108619 pairs total TDO bits received = 445584 bits maximum continuous write = 934 chars O/S serial writes       = 94803 O/S serial reads (data) = 13932 O/S serial reads (sync) = 1583 XferFastData count      = 58384 10mS delays (E/X/R)     = 8/0/0

Chinese Arduino NANO USB Drivers
The cheap $3 Arduino NANO boards use the Chinese CH340G USB chip and not the usual FTDI chip. So, you need to install an appropriate CH340G driver.

Windows 10 amazingly automatically installs the correct driver by itself :)

Windows 7 you need to download the driver from the Chinese manufacturer's website at http://www.wch.cn/download/CH341SER_EXE.html

OS X you need to download the driver from the Chinese manufacturer's website at: http://www.wch.cn/download/CH341SER_MAC_ZIP.html