This is only a preview of the September 2018 issue of Silicon Chip. You can view 53 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Dipole guitar/PA speaker without a box!":
Items relevant to "Digital white noise generator":
Items relevant to "Steam loco or diesel engine sound effects module":
Items relevant to "Super sound effects module – Part 2":
Items relevant to "El Cheapo modules Part 19 – Arduino NFC Shield":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Turns Four!
A couple of months ago, we featured an advert
for the new PICKIT 4 in-circuit programmer and
debugger from Microchip. We’ve long been a fan of
the PICKIT and finally, we got our hands on a “4”.
What did we think of it? Well, here’s a clue: it’s not
going to be sent back in a hurry . . .
T
he first thing I noticed upon
unpacking it is that the PICKIT
4 is slightly wider and thicker than the PICKIT 3. It has an 8-pin
in-circuit serial programming (ICSP)
header instead of a 6-pin header like
the previous version and strangely, I
couldn’t see any buttons or indicator
LEDs adorning the device (but I figured out where they are hidden later,
as you will soon read).
On the side of the unit, there is a MicroSD card slot, presumably for programmer-to-go function. This allows
you to reprogram a PIC when you don’t
have a computer at hand. I also noticed
that the USB socket has changed from
the mini socket on the PICKIT 3 to a
micro socket on the PICKIT 4.
What you get in the box
Besides the unit itself, there’s nothing else in the box except for a USB
Type-A to micro-B cable (around 1.2m
long) and a small sheet of PICKIT
4-themed stickers. The back of
the PICKIT 4 has a “Get Started”
URL listed (microchip.com/
pickit4). Interestingly, the
logo on the PICKIT 4 boasts that it is
an in-circuit debugger; I hope it can
program PICs too!
I opened up the web page mentioned and found a product page with
a list of specifications and features.
Of particular interest to me is the
“silicon clocking speed match” feature, which allows it to automatically
select the highest possible programming speed for a given PIC. The same
page also states that the PICKIT 4 supports the JTAG and Serial Wire Debug
protocols.
The Quick Start Guide (which can
be downloaded from the aforementioned product page) indicates that
the two extra pins on the connector
are used in JTAG, Serial Wire Debug,
UART CDC and SPI modes.
This suggests that the PICKIT 4 may
be able to provide serial communications while connected to a PIC;
something that the PICKIT 3 did not
support.
The PICKIT 4 can
“Hands on”
review by Tim Blythman
supply power to the target device from
the USB host; the voltage is adjustable to suit different PICs. It can also
program chips running off their own
power supply.
When used in “programmer-on-thego” mode, the PICKIT 4 must be powered from a USB power source such
as a battery bank.
The instructions mention the future
possibility the device being powered
from the target board but that will require a firmware update. As expected,
the microSD card is used to load the
firmware in this mode.
You press on the PICKIT 4 logo to
initiate programming in this mode. Is
it a magic logo, perhaps?
No, the logo conceals a tactile
switch, which has a distinctive action
when pressed.
Software and setup
The MPLAB X IDE/IPE software
(version 4.15 or later) is needed to use
the PICKIT 4.
Since we already had that software
installed on our Windows 10 PC (Windows 7/8, macOS and Linux are
also supported), we simply we plugged it into
our PC to try it out.
Once plugged in, it becomes obvious that the indicator LEDs are hidden.
Just like the switch, the
indicator LEDs shine through
Inside the PICKIT 4, shown here about twice life size.
The clear triangle you can see left and centre is a LED
bar light guide which replaces individual LEDs on the
front panel.
90
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
a light guide, with a purple stripe appearing above the logo, which soon
turns blue.
At the time of this review, we were
working on the Super Digital Sound
Effects Module, for which we were using a PICKIT 3.
We swapped it out for the new PICKIT 4 and selected the new programmer for the project.
Programming the device for the first
time involves updating the PICKIT’s
firmware to suit the type of PIC being
programmed, so we let that happen.
Interestingly, the console output for
the firmware upgrade notes that the
FPGA version is ff.ff.ff.
Does it have an FPGA or can it program FPGA’s? We’ll have a look when
we open it up later.
Some users report that the PICKIT
4 stores multiple firmwares onboard,
so the tedious process of the PICKIT
3 slowly updating its firmware when
changing between target microcontrollers should be a thing of the past.
In use
Programming a chip with the PICK4 is noticeably faster than with the
PICKIT 3; it took about 1.5s to erase
and program the PIC32 in our Sound
Effects Module, compared to around
eight seconds for the PICKIT 3.
Having said that, the IDE software
(written in Java) still spends another
six seconds connecting to the programmer and checking its firmware before
it will initiate programming.
The LED stripe on the unit turns
green while programming.
Like the PICKIT 3, the PICKIT 4 is also
capable of in-circuit debugging (see explanatory panel) but the new version
makes this much snappier. The older
unit took a few seconds to resume from
a breakpoint while the PICKIT 4 takes
half a second or less.
This is one of the biggest improvements to our day-to-day use of this
tool, especially since we can now step
over a few instructions quickly without setting extra breakpoints.
We also found that the PICKIT 4 is
able to set breakpoints practically instantly, while the target is running (although the target software appears to
pause briefly).
This is great for bringing debugging
closer to a real-time experience.
Interestingly, there’s a speed option (under Program Options/Program
Speed) that by default is set to “norIT
siliconchip.com.au
Comparison between
PICKIT 4, at 90 x 43 x
19mm and the PICKIT
3, 95 x 40 x 11mm. The
other obvious difference
between the two is the
apparent lack of LEDs
and pushbuttons on
the PICKIT 4 – the blue
bar on the 4 actually
changes colour in use,
while pressing the logo
triggers a tactile switch.
What’s inside?
The big news is that the latest and greatest PIC programmer is not powered by a PIC
microcontroller, but in fact a 32-bit 300MHz Atmel SAM E70. The internal ISP header
looks like the standard AVR 10-pin variant. Of course, Microchip has owned Atmel for
two years, so it’s not surprising they would pick the best of both worlds.
That’s not the only IC, as there appears to be around fourteen ‘large’ ICs, plus numerous smaller ones around the board, and nineteen test points. Based on this circuit’s
complexity compared to the PICkit3, it looks like this PICkit might be a bit harder for
the cloners to replicate.
The PICKIT 4 appears to be a close relative of the ICD4 In-Circuit Debugger, which
also sports a SAM E70 and an FPGA for ‘faster communication, downloads and debugging’, so it appears the FPGA forms part of the high speed USB interface for these parts.
There’s an MCP4452 quad I2C digital potentiometer near the ICSP header, presumably used for VPP voltage control, and two MIC2042 power switch IC’s on board. These
are rated at 3A, so may be used for VPP generation. There’s another digital potentiometer and a number of op-amps around the board.
The IO pins of the ICSP header have substantial networks surrounding them, suggesting a high degree of protection.
The light pipe covers much of the board, and appears to be held in place by what
looks like a flexible flat cable connector, but is actually an RGB LED module, pointed into
the light pipe. The back of the PCB where the pushbutton is mounted has case support
preventing the PCB from flexing excessively. Still, pushing the button requires flexing
the front of the case and seems like it takes more force than necessary.
Next to the USB socket is a small hole in the case which corresponds to a small
edge mounted tactile switch marked SW2 on the PCB, which apparently puts the SAM
E70 into bootloader mode, after which you should use the ‘Hardware Tool Emergency
Boot Firmware Recovery’ from the Debug menu in MPLAB X. We wouldn’t recommend
pushing this button for the sake of seeing what it does, but if the PICKIT 4 isn’t recognised by your computer (even after rebooting and or replugging the PICkit), then it may
be an option.
The PICKIT 4 packs a lot more
in than it appears to need, hence
the slightly larger case, but with
pending support for many more
features, possibly including JTAG
and AVR ISP and a pleasing increase in speed, it is certainly welcome.
The two sides of the PICKIT 4 PCB,
removed from its case and
with the LED bar indicator
removed for clarity (it sits in
the angled white socket on
the photo above. Other
connectors of note are the
large I/O socket on the left and
the USB socket (right side top
photo).
Australia’s electronics magazine
September 2018 91
The ‘Program Options’ section of the PICKIT 4 configuration has many more
options than that for the PICKIT 3. In case it is too bright, the LED brightness
can be adjusted (with a range of 1 to 10, defaulting to 5), and the PGC and PGD
resistor values can be customised.
mal” but can also be set to “high” or
“low”.
So if the already faster experience
isn’t good enough, there’s an even
faster option.
Some teething problems
One small problem we discovered
is that the Hold in Reset/Release from
Reset option in the MPLAB X IDE no
longer works.
We found that we needed to disconnect the VPP line between the PICKIT
4 and the target circuit to allow the
circuit’s MCLR pullup to get the target out of reset.
92
Silicon Chip
Apparently, this is a software bug
which has been rectified in MPLAB
X v4.20.
So if you purchase a PICKIT 4, you
should make sure to upgrade to the
latest version of MPLAB X to avoid
this sort of bug.
We also found that we occasionally would get a “Connection Failed”
message during programming but this
was usually overcome by unplugging
and replugging the USB cable from
the computer.
We have seen similar behaviour
from the PICKIT 3 in the past. It may
be due to the relatively high power demand of the unit when it’s also powering the target circuit.
Interestingly, the PICKIT 4’s LED
remains lit when the cable USB is
disconnected. It appears the “power
programmer from target” setting is active by default, causing the PICKIT 4
to draw power from the target when
it has no USB supply.
From the notes in the quick start
guide and links, it’s apparent the current version of the firmware (supplied
with MPLAB) is not quite complete.
For example, the Programmer-To-Go
support is currently listed as “Feature will be added with a firmware
upgrade”.
The Microchip forums suggest
that this will be added in the August release of MPLAB X. See:
siliconchip.com.au/link/aakx
The Microchip website also has the
following comment:
“Currently, the MPLAB PICkit 4 InCircuit Debugger/Programmer supports many but not all PIC MCUs and
dsPIC DSCs, but is being continually
upgraded to add support for new devices.”
With this being the first release of a
Comparison of PICKIT family
PICKIT 1
Release
2003
ICSP Header
No
UART tool
No
Programmer-To-Go No
Programmer-To-Go
Storage
Main Controller IC PIC16C
Interface
USB
Clones available
-
PICKIT 2
2005
6 pin
Yes
Yes (128kB)
EEPROM
(upgradeable)
PIC18F
USB
High Speed
Yes
PICKIT 3
2009
6 pin
No
Yes (512kB)
EEPROM
PICKIT 4
2018
8 pin
Yes*
Yes*
Micro SD Card
PIC24
USB
High Speed
Yes
SAM E70
USB
High Speed
-
* some features of PICKIT 4 are not currently available, but are planned for future firmware updates
Australia’s electronics magazine
siliconchip.com.au
In-circuit debugging
One of the biggest advantages of using
micros from Microchip is the near-universal
support for in-circuit debugging (ICD).
If you have had to debug a complex program running on a microcontroller with only
a serial console (or in some cases, not only
that) you will know how frustrating it is to not
know what is going on inside the program.
You end up having to add a lot of extra
print statements, temporarily remove sections of code and constantly re-flash the microcontroller until you can figure out what’s
going wrong.
All of that pain can be avoided by using incircuit debugging. The main thing you need to
do so that you can use this feature is to ensure
that the programming pins do not share their
functions with any other hardware that may
interfere with the debugging signals.
You also need to compile the project in
debug mode, which normally uses less aggressive speed/size optimisations.
Once you have done that, you can set
“breakpoints” on just about any line in your
software and when you start the debugging
session, the program on the PIC will run until it reaches one of these breakpoints. It will
then stop and the code surrounding that line
will be shown on the screen (see screen grab
below). You then have the ability to perform
the following actions:
• Inspect the state of all the variables at this
point in the execution of the program. That
includes global variables and those local
to the function containing the breakpoint.
• View the “call stack” which shows you
which line of which function called the cur-
rent function and so on, up to the entry
point function (normally “main”).
• Inspect the state of the PIC’s RAM, its
control registers and so on. Basically, you
have full access to a snapshot of the PIC’s
state at that point in the code’s execution.
• “Step” through the code one line at a
time and see which order the statements
are processed (which will depend on any
loops, if statements, function calls etc
which are encountered).
• See how variables and other processor
state changes as the program progresses.
In fact, variables, registers or memory that
you are “watching” will be highlighted in
a different colour when the state changes
for any given step.
• Change breakpoint locations, including deleting existing breakpoints or setting new
ones, and then allowing the code to continue execution until it encounters another
breakpoint. In fact, one valuable aspect of
in-circuit debugging is the ability to set a
breakpoint and see whether the code on
that line is ever reached.
This should give you an idea of how much
easier it is to diagnose and fix complex faults
in the software using ICD compared to other
techniques. The fact that the PICKIT 4 makes
it faster is a great benefit.
It’s difficult to use ICD to diagnose timingsensitive problems as debug mode changes
program timings and any time the program
is frozen (eg, when encountering a breakpoint), real-time tasks running in the processor also halt. But it can still be useful in
some of these situations.
PICkit since the merger of Microchip
and Atmel and with the extra pins on
the ICSP header, users will be curious
as to whether it can program Atmel
parts such as AVRs.
This too appears to be a future capability, with support still to be added
to MPLAB X.
Interestingly, the 8-bit AVR family
appears to be available as an option
in both the current IDE and IPE, although no actual parts are available
for selection.
Conclusion
As far as we’re concerned, the PICkit 4 does what we need it to do, ie, it
programs and debugs PICs, and it does
both much faster than the PICkit 3 did.
So we feel that the hardware improvements makes the cost of upgrading
well worthwhile.
If you’re hoping to program AVRs
or use the programmer-to-go function,
you may want to wait until the software is ready to pull the trigger.
You should also check that the
PICkit 4 has software support for the
PICs you intend to use, in the latest
version of the MPLAB X software.
so, check which version of MPLAB X
SC
you’ll need.
MaxiMite
miniMaximite
or
MicroMite
Which one do you want?
They’re the beginner’s computers that the
experts love, because they’re so versatile!
And they’ve started a cult following around the
world from Afghanistan to Zanzibar!
Very low cost, easy to program, easy to use –
the Maximite, miniMaximite and the Micromite
are the perfect D-I-Y computers for every level.
Read the articles – and you’ll be convinced . . .
You’ll find the articles at:
siliconchip.com.au/project/mite
The in-circuit debugger being used on the Super Digital Sound Effects Module.
Three breakpoints have been set. The code is paused on the second breakpoint
and the bottom window (“Watches”) shows the value of monitored variables.
siliconchip.com.au
Australia’s electronics magazine
Maximite: Mar, Apr, May 2011
miniMaximite: Nov 2011
Colour MaxiMite: Sept, Oct 2012
MicroMite: May, Jun, Aug 2014
plus loads of Circuit Notebook ideas!
PCBs & Micros available from PartShop
September 2018 93
|