- Published: Monday, 19 December 2016
- Written by Jon Chandler
- Hits: 1771
The 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.
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!
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!
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.