Unpacking a PICkit 2 Programmer/Debugger
Well I have just come to the end of day having finally unpacked a pickit2 debug express DV164121 which has a 16F887 on a small dev board.
Although I researched MPLAB IDE a few years ago I have had little further to do with it preferring the easier option of MCSP 3.0.0.5 together with Melabs serial programmers and of course PBP2.50a. I am very comfortable with PBP/MCSP configuration I also have a LabX1 devboard which I still regularly use. However having been spoiled by David Barker’s ICD within MCSP, I have been developing much larger programs “in the dark” on devices not catered for in the ICD module MCSP.
I am disappointed, but not surprised, by Microchip’s policy of secrecy regarding the Debug routines for the majority of it’s own devices. Anyway some time ago I ordered a PICkit 2 to be able to transfer code over and get a “look inside” on some trickier problems (for me) to solve.
First I loaded the PICkit 2v2 software which was straightforward except for the fact that it took at least an hour and half for the “necessary” Net framework to be installed, I hoped this was not going to be an omen for badly written code, after all I have PBP and MCSP running off a ZX81! (Not really but close). Anyway a few hundred megs later I got PICkit 2 up and running, a simple interface with what looks like a handy box to control VDD. Getting it to work, sort of, seamlessly with MCSP requires downloading a PK2CMD application and setting it up. There is a comprehensive step by step article in Jan 2008 issue of Nut and volts, thanks Chuck Hellebuyck . For the moment I had been powering from the PICkit 2 but it appeared reluctant to let go of the programmed device, holding it in reset. Maybe this would not be the case with an external supply. The most noticeable difference is that there is no direct access to configuration fuses using the pickit2, fuses have to be set within code file, and there appears to be little in the way of control over the device itself whilst using MCSP. The MELabs programmer gives all the fuses with their options listed in combo boxes for all supported devices, this is very handy to quickly see and change a fuse value especially when you are using an unfamiliar device. Personally I later embed the fuse configuration into the file once I have them fixed and then set “read fuses from file” option. So it looks as if Pickit2 with MCSP works almost exclusively in the background, and it doesn’t much like having two instances open either, this appears to cause a major lockup.
Maybe it looks as if pickit2 is designed to work more flexibly within the Mplab environment.
As the purpose of this exercise is to debug it was time investigate MPLAB IDE V8. My few skirmishes with this IDE in the past have left me a little cold, so I have been putting it off a little.
Anyway I followed the step by step tutorial that came with the PICkit 2 and had the unit working in debug mode on the 16F887 very quickly. The PICkit2 is clearly designed to function more usefully within this environment, for a start it auto updates the PICkit OS, which I had previously done manually earlier on.(was it worth the time waiting for Net framework?)1 There is a monitor child window that relays info from the programmer as it operating, I suspect that there may well be more ways to interface the programmer later on, the only mechanism I tried was to be able to easily read the code space and eeprom from the current device, although there is a task bar button to read device I couldn’t easily find a way to display the contents without resorting back to the programmer interface, but I guess a few more hours will help here.
So now all that is left is to get the MPLAB to debug a program created in PBP. Time to install the MPLAB plugin created and downloaded from Melabs, this is installed as a language suite within MPLAB, so far so good.
Next to write a small few lines in PBP and compile and write to the device. First I used the project wizard to create a new file, but I have to say I got in a right pickle and gave up the wizard altogether and set about creating and naming a new project and creating and naming a new file directly from the menus, only thing to remember is to save the file as a .BAS or .ASM which allows it to become a “source file” that can then has to be added to the project. So now I have PBP operating within the MPLAB and can compile (build) and program a device, things are moving on quite fast. Next I build (compile) not as a “release” but as a “debug”, everything is fine and I note how well the PICkit performs.
I can set breakpoints within the PBP code, and it appears as if I have access to registers etc. Next I set the debug to animate, this time instead of animating my PBP code it animates the PBP 14bit core library file. I am hoping to get that sorted as I would prefer the PBP code to be animated but I think this has been enough progress for today.
So all in all not too bad, I thought it would be worse. Mind you MPLAB takes up so much space on the drive I think I have every right to expect it to work, but……… there is a lot more opportunity for it to go wrong and I fully expect it to sometime soon.
Is MPLAB more professional (serious) or is it just bigger and overly complicated, some (most) of the sweetest work I do is executed with the simplest tools.
Off to have a glass of wine…. Oh yeah Happy Easter to you All :D