PICkit 2 Logic Tool Trap

PICkit 2 Logic Analyzer - 300pxThe PICkit 2 logic tool/analyzer is a handy tool to have around, especially since the price is right!  The analyzer mode can show the timing of signals, and the logic tool can be used to monitor the output status of a few bits or to exercize a few inputs.  The logic analyzer and UART tool are reasons why I don't upgrade to the PICkit 3.

I'm working on a simple monitor that will record and display the status of 8 test points.  In the piece of machinery being monitored, a number of conditions can lead to shutdown, but the only indication a technician troubleshooting the issue is that one or more of these conditions caused the shutdown but not which particular faults occured.  A couple of the fault conditions are temperature-related, so a technician arriving some time after  a shutdown has occurred has little to go on for troubleshooting.

The monitor I am building will show what faults have occured, and the sequence in which they occurred.  It should be a powerful tool for the technicians.

I need to simulate the fault conditions to develop the software.  As I get it refined, I'll need to generate 8 signals, but for the initial work, simulating a few inputs will be sufficient.  I am using port B of the 18F26K22 to monitor the eight signals.  RB6 and RB7 are the ISCP programming pins, but there won't be a programmer connected in the field.  Using the PICkit 2, I can easily exercise RB6 and RB7 without making any changes in connections.  It's pretty slick.

There is however a trap doing this.  One of which I fell into a couple weeks ago when I was considering my approach to the problem and again last night when I was working with the printed circuit boards I had made.  Maybe by writing about this trap, I can warn you and prevent falling into it again!

The illustration below shows the startup screen for the logic tool.  Three of the pins may be used as either inputs or outputs, while the 4th, pin 1, may be used only as an output.  Until you click "enable I/O", you can't make any changes to the configuation.

Logic Tool Startup Start - 1000px


Simple enough.  In my case, the only pins I'm interested in are pins 4 and 5 which are connected to the port B programming lines.  Once I click "Enable I/O", I can set those pins to outputs and toggle those 2 bits.  Except when I do that, my board dies.  Can you see why?

When connected to the ICSP connector, pin 1 is connected to /MCLR.  With it set to 0, the PIC is held in reset.  I'm driving LEDs using an MCP23017 I2C peripheral expander chip - holding the PIC in reset freezes whatever LEDs were illuminated via the MCP23017.  The appearance is that the board is locked up!

The answer is simple... if you realize what's going on. Just set pin 1 high.  Then the PIC will come out of reset and operate normally.  If you don't realize what the problem is, you'll wonder why your board is dead and pressing the reset button has no effect at all!


Make Pin 1 High - 1000px

That's no big deal.  Unless for some reason you want to reset your board.  You could do it just by toggling pin 1 in the logic analyzer, but what you'll probably do is press the reset switch on your board.  What happens when you press the reset switch?  /MCLR is brought to ground...which means the PICkit 2 pin 1 which is high is shorted to ground!

If reset pressed - 1000px

The PICkit 2 is very good at self-preservation!  It shuts off the power to protect itself and possibly your circuit.  It also leaves the GUI hung, looking like everything is normal including the power being switched on.  Your board is dead again for no apparent reason.  In the initial stages of testing a board where you aren't 100% sure everything works, this can be very frustrating.

When the PICkit goes into self-protection mode, the GUI is hung and can't be closed.  To get going again, disconnect the PICkit from its USB connection, close the GUI and start over.

Hope this saves you some trouble.



Posted: 2 months 2 days ago by Jon Chandler #17870
Jon Chandler's Avatar
There's another gotcha with the PICkit 2 connected to port pins you're using for something else. A couple actually,

For my testing, I moved on to a switchbox with 8 SPST toggle switches; the switches are connected to ground and the lines are pulled high with a 10k resistor. At first, I thought a couple of my switches from the Happy Captain Switch Company (the best 10 pack of switches you can buy for five bucks) might be shorted. Bits 6 and 7 (the ICSP data lines) showed low in both positions - the other 6 switches preformed as expected and my monitor illuminated the LEDs as expected. Then I thought back to those notes on the logic analyzer screen. Pulled down with a 4.7k resistor. Ok, a 4.7k pulldown wins over my 10k pullup. Disconnect the PICkit and all is good with my switches (and my code).

With my switch box connected, I started getting errors when trying to program the PIC. "Device not found." I'll cut to the chase - if the switches for bits 6 and 7 are on, shorting the lines to ground, the ICSP data lines are shorted to ground. Oops.

Forum Activity

Member Access