Hi, and welcome to the Gooligum Electronics
PIC extras series, covering topics that sit outside the PIC tutorials. In this video I’ll
take a look at Microchip’s new PICkit4 and Snap programmer/debuggers.
Since I started making the baseline and mid-range PIC tutorials, Microchip have introduced a
few new PIC programmers. The PICkit series are low-cost programmers,
that can also be used as debuggers, which are intended mainly for the hobby or maker
market. They’re designed to connect to the PIC while it’s in the target circuit, using
a protocol called in-circuit serial programming, or ICSP.
The PICkit 2 was Microchip’s first standalone low-cost programmer (the PICkit 1 doesn’t
count because it was a dev board). The PICkit 2 was really good, and had some features that
the later PICkits still don’t. And you could buy cheap clones that worked pretty well.
But it’s only supported on the old MPLAB, not the newer MPLAB X. And it can only be
used with older PICs. So it’s no longer recommended for the Gooligum PIC tutorials.
The PICkit 3 also works pretty well, and it’s faster than the PICkit 2, which is important
when you’re programming or debugging bigger PICs. It’s still a good choice for programming
small PICs, and can program some that the PICkit 2 can’t. It’s also fully supported
by MPLAB X – so it remains the recommended programmer for use with the baseline and midrange
PIC tutorials. The PICkit 4 is much faster again, and it
can be used to program a much wider range of processors – not only PICs, but ARMs
too! To accommodate other programming protocols,
the connector was expanded from 6 pins to 8, but if you’re programming a PIC you can
just ignore the extra couple of pins – the first 6 pins are a standard ICSP connection
and can be used directly with existing boards such as the Gooligum baseline PIC training
board. The PICkit 4 plugs straight into the ICSP
header, in exactly the same way as a PICkit3, with the arrows marking pin 1 aligned. Use
the supplied micro USB cable to connect the PICkit 4 to your PC, and you’re good to
go. The newest member of the PICkit family is
the Snap, a cost-reduced version of the PICkit4. As you can see, it’s a bare board. And it
doesn’t come with a micro USB cable – you have to supply your own.
More importantly, it’s missing a couple of features.
Significantly, unlike the PICkits, it can’t provide any power to the target circuit. That’s
not usually a problem because your circuit would normally include its own power supply,
but it means that if you just want to program a PIC on a breadboard, you’ll have to power
it separately. Another important difference is that it only
supports low-voltage programming. The traditional way to put a PIC into programming mode was
to place a high voltage (12 volts or so) on the Vpp pin.
The Snap can’t do that, so it has to use the low voltage method. And the downside of
that is that your program can’t use the MCLR, or reset, pin as an input. That’s
a big deal on small PICs. For example, the 12F1501 only has 6 I/O pins, and one of those
can be configured as either an external reset or the digital input pin RA3. But if you’re
using a Snap programmer, you have to configure it as MCLR, so you can’t use RA3 and you
only have 5 digital inputs instead of 6. Partly because of that, the Snap doesn’t
support any of the baseline PIC devices, nor the original mid-range PICs. Only the newer
enhanced mid-range and more advanced PICs are supported.
That means that if you use the baseline and midrange PIC training board with a Snap programmer,
you’ll be limited to the enhanced midrange lessons.
The Snap plugs into the ICSP header as usual, with the arrows aligned. You’ll need a micro
USB cable to connect it to your PC. But, since the Snap can’t supply any power, you’ll
also need to connect a separate DC power supply to the barrel connector on the PIC training
board. We’ve seen that, if you use the Snap programmer,
your program can’t use any digital input that’s shared with the MCLR pin.
There’s a similar issue that affects both the PICkit 4 and Snap, which makes it harder
to use the other two programming pins. They’re called either ICSPDAT and ICSPCLK, or PGD
and PGC, but either way, on small PICs, those pins are also used for other functions such
as digital I/O. For example, on PIC12s the programming pins are GP0 and GP1,
or RA0 and RA1. The programmer has to take control of those
pins while it’s programming the PIC. The problem is that the PICkit 4 and Snap programmers
don’t release control when they’re finished, making it impossible to use those pins for
anything else as long as the programmer remains connected.
That’s true as of MPLAB X v5.05, at the time I’m making this video, in October 2018.
Maybe it’s a bug that that Microchip will fix in a firmware update. But at the moment
it means that you lose the use of another two I/O pins, unless you unplug the programmer
after programming. That doesn’t sound so bad, but it’s a real pain to have to keep
unplugging the programmer while you’re developing code. On the other hand, you could use a debug header, like these, which replaces the PIC in your
circuit, and that way you don’t lose any pins while you’re debugging. But it’s
still not great that you have to do that if you’re only programming.
To show you what I’m talking about, here’s a 12F1501 programmed to blink three LEDs connected
to the RA0, RA1 and RA2 pins. With the PICkit4 connected, only RA2 is blinking. Unplug the
programmer and RA0 and RA1 start working. Plug it back in and they stop. Not ideal.
Configuring a PICkit 4 in MPLAB X is pretty similar to configuring a PICkit 3.
If it’s plugged in, it will appear under hardware tools in project properties. You
can see that I also have a PICkit3. If I select the PICkit 4 and click apply, the PICkit 4
options become available. As with the PICkit 3, there are a number of option categories.
There’s usually no need to change the memories section. I don’t know why preserve memory
range shows an error by default. Probably a bug but anyway it works ok like this.
Program options lets you select high or low voltage programming mode, and it also lets
you choose the programming speed. You won’t notice the difference on a small PIC, but
for big ones and you like living on the edge you could try high speed. Or if programming
fails, try low speed. The power options are the same as for a PICkit 3:
you can choose to power the target circuit, and what voltage to supply. Note that it’s
limited to 50 mA though. If you’re using a Snap programmer, the configuration
options are much the same, there just aren’t as many of them. The Snap can’t supply power,
so there are no power options. Program options are more limited. In particular,
you can’t select high voltage programming. But you still get to choose different programming
speeds. Whichever programmer you’re using, you can
go ahead and make your project and program it into the PIC in the same way as usual. I’m intending to put together some video
tutorials for the enhanced mid-range PICs, modified as far as practical to work around
the Snap programmer’s limitations. See you!