piculear
This incomplete but slowly progressing project has the ultimate goal of producing a reliable PIC ICSP programmer that just works and can be more readily picked apart, examined, and/or replaced than a comparable Microchip programmer (for instance, the PICkit 2).
Design goals
The hardware interface should be simple in order to make it easier to track down points of failure. It should also be easy to replace, even if it must be with a makeshift, Radio Shack parts only version while waiting for new parts to arrive. On the flip side, the main hardware design should be flexible enough that it can be readily adapted to a production programmer, complete with firmware-adjustable target VDD.
The software should be trivially cross-platform, easy to study, and not involve substantial work to get running. For this reason C and C++, among others, are out. As tepid as I feel toward Python in general (I'm more of a Perl guy), it might be a good choice here.
The firmware should be very simplistic and do almost nothing, handling only what it does best—communications and fine timing—while allowing the software to do most of the work. This should make it easy to port and prevent problems with memory limitations, and could potentially make it feasible to run on smaller MCUs.
Hardware
The hardware aspect is to provide an interface module that could be connected to an arbitrary MCU/board (PIC16F88, Arduino, you know, whatever is handy) to deal with the parts that actually involve electricity:
- A simple boost converter for the
nominal 12V to 14V programming voltage, using PWM and ADC from the
MCU rather than a separate boost IC.
- Alternatively, if PWM, ADC, or a suitable inductor cannot be found, a place to accept an input for that voltage.
- If applicable, a PWM-controlled regulator for target VDD.
- A power output switch for target
VPP.
- Two pins are used for a tri-state effect.
- A power output switch for target
VDD.
- Two pins are used for a tri-state effect.
- Level shifters (between host VDD
and target VDD) for the communication lines.
- It's preferable if the hardware doesn't care which of host and target has the higher VDD. For example, a 3.3V host should be able to program a target at 2V or 5V without any hardware changes.
- Push-pull shifters would be preferable to just pulling up or down; this would allow support for dated or naïve designs having their own pull-ups/pull-downs on the lines.
- The ICSPDAT line must have a bidirectional shifter.
- The ICSPCLK line could use a unidirectional shifter or could be made bidirectional (as on PICkit 2 and 3) to provide additional facilities.
- The PGM/LVP/AUX line could be made optional. If implemented, it could use a unidirectional shifter or could be made bidirectional (as on PICkit 2 and 3) to provide additional facilities.
The hardware interface should readily connect to an MCU with a few GPIO pins and optionally a couple of PWM outputs and ADC inputs.
Firmware
The firmware will be tasked with communicating serially (e.g. via USB-to-serial) with the software and controlling the GPIO pins needed to implement the protocol expected by the target device.
The firmware for this project must be conscientiously designed to offload as much of the processing as is practical to the software. Code is cheap, as they say, but it is much cheaper on a PC (even a very old one) than on a microcontroller. There should be implementations for simpler primitives—for example, a command to clock out a byte—but anything much higher-level than that is the software's domain.
As a start, it might make sense to examine and convert the family
metadata and scripts stored in PK2DeviceFile.dat
and decide how they might best translate to this system. (Dumps from
the device file may have IP encumbrances, though, so care should be
taken before reposting them.)
While conceptually there need be no single firmware, this project will probably start by making something that works for Arduino, since that's currently the easiest...
Read more »