Unpacking a PICkit 2 Programmer/Debugger


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146

    Default 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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Is MPLAB more professional (serious) or is it just bigger and overly complicated
    I think it is no more professional or less professional than MCS. It can do things that MCS cannot. So it is just a matter of different tools for different jobs.

    One of the things I like about MPLAB is it can tell me how the fuses are set after a program is compiled. I find this very useful when working with an unfamiliar chip when I am not sure it I have things correct. It also can take a saved hex and tell you how the fuses are set, nice when you need it.

    Again it is a matter of the right tool for the right job, and what you become comfortable with. Some times I us XP or Linux, MPLAB or MCS, PICKIT1 or PICKIT2 or PICSTART PLUS. Seems the only thing constant is PBP.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by duncan303 View Post
    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...............
    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, ..................

    Off to have a glass of wine…. Oh yeah Happy Easter to you All
    I had downloaded the PICKIT2 with .net elements from microchip site. It did not take that sort of time for me. If I remember, it took hardly less than 10 mnts
    Regards,
    Sarma

  4. #4
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi Dave

    ……One of the things I like about MPLAB is it can tell me how the fuses are set after a program is compiled.……
    I noticed the child window available in Mplab, but I have to say that initially I much prefer the Melabs Serial programmer Interface. I assume that multiple options are probably equally available using PICkit2, I just haven’t found them yet. Like reading the eeprom of a device and having it displayed full screen height rather than a piddly little 5 line scroll combo box. I like to use eeprom as an alarm event log recorder so the more I can see in one hit the better.

    Redeading my post, I appear to have presented it as a better/ worse thread, this wasn’t my intention, I just thought I would share an experience. Having to succumb to Microchips policy of protectionism.


    Hi Sarma,

    Yeah I guessed something was wrong, to be honest most of the time taken was with installing windows updates to Net framework, my point was really that MPLabs is a monster and in my humble experience, vulnerable to failure. For example Windows update continues to attempt a forced install of a critical update service pack to Net framework V.1, but it also has installed through to version 3. PICkit initially installed version 2. Do I want to go searching the windows Knowledge base on an Easter weekend, yeah I think Not.

    I hate to sound jaded but it is many years now since I was “in love” with PC’s. I am reminded of a quote by Damon Hill an F1 racing driver who found himself looking across at a competitor as he was entering the first bend and thinking “what’s the rush?”. I am sure Damon continues to thoroughly enjoy driving but there is only so much of your life you can spend fiddling about with the OS on any computer. How many guys do we all know who come into work on a monday having spent the weekend Fdisking their Hdrives and getting the optimum setup “for the very last time”….. until the next month!

    Minimum code = Maximum enjoyment! Just look at the response on here when you get a code condensing thread.

    “If it ain’t bust don’t try to fix it” ………… just hang on as I put my bright yellow cardigan on and settle down into my rocking chair

    Duncan

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Duncan

    I've always used PbP with MPLAB, Picstart plus and ICD2 ...

    I do agree MPLAB is somewhat Huge ... but, I also do think we are really far from using it's real and full power ...
    Not really useful for Hobbyist, but really nice for pro's ...


    I also use some others IDEs ... and find MPLAB is one of the ... lightest !!!

    you should have a try with PSoC Express ( Cypress ) or Processor Expert ( Moto ... euhhhh, Freescale ) ...

    Just to have something to "trim your scale" ... ( LOL )

    And a yeah Happy Easter to you and everybody here

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by duncan303 View Post
    Hi Dave

    I noticed the child window available in Mplab, ...............
    Hi Sarma,

    Yeah I guessed something was wrong, to be honest most of the time taken was with installing windows updates to Net framework, my point was really that MPLabs is a monster and in my humble experience, vulnerable to failure. For example Windows update continues to attempt a forced install of a critical update service pack to Net framework V.1, but it also has installed through to version 3. PICkit initially installed version 2. Do I want to go searching the windows Knowledge base on an Easter weekend, yeah I think Not.

    I hate to sound jaded but it is many years now since I was “in love” with PC’s. I am reminded of a quote by Damon Hill an F1 racing driver who found himself looking across at a competitor as he was entering the first bend and thinking “what’s the rush?”. I am sure Damon continues to thoroughly enjoy driving but there is only so much of your life you can spend fiddling about with the OS on any computer. How many guys do we all know who come into work on a monday having spent the weekend Fdisking their Hdrives and getting the optimum setup “for the very last time”….. until the next month!

    Minimum code = Maximum enjoyment! Just look at the response on here when you get a code condensing thread.

    “If it ain’t bust don’t try to fix it” ………… just hang on as I put my bright yellow cardigan on and settle down into my rocking chair

    Duncan

    I do understand that you and many of us might be tuned for PBP and associated stuff.
    But I expect more than 30% of our members become professional experts as days pass by and will not remains in hobby alone. So we may not look at the magnitude of the MPLAB. In fact I am a beginner in software learning and at an advanced age of 62. Once i have a HDD of 80 or 160GB , this MPLAB is nothing perhaps, and I bite only as much a can chew. Perhaps you may be right from your perspective.
    Regards,
    Sarma

  7. #7
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by duncan303 View Post
    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
    Duncan, I'm in precisely the same situation, with a progress curve very similar to yours. I too am using a 16F887, and when I animate, the 14bit core lib. file opens up and animates.

    Very curious to know if you sorted it out.

    And a question to Bruce as well; with the help of your recent post at http://www.picbasic.co.uk/forum/show...=mplab+animate

    I have been able to see my variables in the watch window. However, I still cant see the variables assigned to the port pins. Is there any way to achieve this?

    BTW, I'm suing MPLAB 8.00

    Thanks and Regards,

    Anand

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Anand,

    When you create a variable for a port like PORT VAR PORTB or PORT VAR GPIO, all you're
    doing is creating an alias to the port. It doesn't create a variable in RAM like it would for
    something like X VAR BYTE.

    Look at the screen capture attached. Check out the address for _PORT, GPIO, _X and _Y.

    X and Y are variables in RAM. _PORT is just another name for the physicall address of GPIO.
    It's not a variable created in RAM. Just an alias to the port address.

    Running animations in MPLAB for PBP programs is a bit different than using it with assembly.

    If you run something like what's shown in my screen capture, and hit animate, it will show
    the green cursor on each line as it executes. Now insert a PAUSE 1 just after PORT = X.

    When it lands on the PAUSE 1 it calls the PBP library routine, so the library window opens
    and you don't see it execute the PAUSE 1 in the BASIC source window. It's only going to
    show inline type commands. Calls to PBP library functions aren't shown in the source code
    window. That's why the library window pops up.

    Using MPLAB with PBP takes a bit of getting used to, but it's worth the effort.
    Attached Images Attached Images  
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    Thanks for the reply; very lucid, as always.

    I now understand the issue I'd raised (kind of). What I dont understand yet, although you've touched upon it, is why the animation jumps to the library window whenever it encounters a pause statement. And then doesnt seem to return back to the source window. But, single-stepping seems to work fine.

    About the port pins. What you are saying is, I'd have to watch the whole port, and then see the behaviour of the individual pins within; am i right in my understanding?

    I must say MCS Plus has really spoilt me; this is one thing about it I miss. But like you said, there seem to be loads of other things in favour of MPLAB that makes the transition worthwhile.

    Thanks again.

    Anand

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Anand,

    But, single-stepping seems to work fine.
    Because when you're single-stepping with the Step Over button it steps over the huge
    library functions. If you single-step using Step Into, it executes the library function line
    by line. Step Over runs the whole library function immediately returning to the next PBP
    BASIC statement.

    Animation works similar to Step Into - so you lose the green animation cursor when a call
    to a library function is made.

    About the port pins. What you are saying is, I'd have to watch the whole port, and then see the behaviour of the individual pins within; am i right in my understanding?
    Yep. You can watch the port or the alias you've created, but you're still essentially
    watching the same thing since the alias is just another name for the same register address.

    I must say MCS Plus has really spoilt me; this is one thing about it I miss. But like you said, there seem to be loads of other things in favour of MPLAB that makes the transition worthwhile.
    MCS+ is a great little program, but once you get the hang of using MPLAB/MPSIM with PBP
    you'll never look back.

    MPLAB has a lot of things MCS+ doesn't like the stop watch, logic analyzer, and advanced
    features like register injection. You can setup stimulus files to send analog values to A/D
    inputs, simulate external switches on pins, and a lot more.

    It goes way beyond just watching the animation cursor & viewing register values...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    MPLAB has a lot of things MCS+ doesn't like the stop watch, logic analyzer, and advanced
    features like register injection. You can setup stimulus files to send analog values to A/D
    inputs, simulate external switches on pins, and a lot more.
    By the way are there any tutorials on these?

    Ioannis

  12. #12
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    Okay, that pretty much puts things in perspective. Wouldnt have been able to do the switch without all the inputs I got.

    Thanks,

    Anand

Similar Threads

  1. PICkit 2 and RBC interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 4th April 2009, 02:33
  2. PICkit 2 for £9.99 inc P&P
    By Agent36 in forum General
    Replies: 6
    Last Post: - 16th November 2008, 23:44
  3. PicKit 2 Questions
    By dmairspotter in forum General
    Replies: 3
    Last Post: - 11th November 2007, 21:10
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Programming from MicroStudio to a PICKit 2
    By jblackann in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th November 2006, 03:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts