ICD, ICSP and Picbasic Pro


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Sep 2005
    Posts
    16

    Default ICD, ICSP and Picbasic Pro

    I'm a bit confused about using the ICD feature of the PICs that support ICD. I have managed for years using the serial DEBUG command to work out my bugs but have recently become interested in the ICD feature. A project I just completed used a 16F628 and while I still had it on the protoboard I thought I would see if I could get the ICD to work. I already had a MAX232 converter set up so it was a simple matter to give it a try. I am using MicroCode Studio and PicBasic Pro with a Warp13 programmer (I was not using ICSP). Using Bruce Reynolds' posting on his site I was able to get a simple program to work but when I tried it on a "real" program it would hang and stop running. In Bruce's circuit he uses the RX/TX pins on the '628 but I see that Microchip's AN DS51242A says that the ICD uses RB6 and RB7. I have also found reference to adding a NOP as the first executable instruction and also adding an INCLUDE ICDDEFS.BAS. My copy of PBP has several variations of this include file, none of which say they are for the '628.

    From what I can gather the Microchip ICD2 can connect to the ICSP pins and act as a programmer and then as a debugger, I assume using MPLAB. So my question is this:

    Will the ICD2 work with Microcode Studio and PicBasic Pro and provide programming and debugging functions?

    Is there something better than the ICD2 ?

    Many thanks,

    Mark

  2. #2
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi

    You can't use ICD with MCSP any way, and you need a firmware to download in the PIC before you can use the ICD feature. Don't mix between the loader of MCSP, and that for ICD. Anyway, if wanna use ICD, then you have to use MPLAB instead...

    Good luck

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default

    I disagree. MicroCode Studio Plus has in-circuit debugging.

    I can't figure out how to make it work, but it's there. I tried using that MAX232CPE circuit too, connected to TX/RX with the same results.

    Gonna try PGC/PGD and see what happens.

    Robert


    EDIT: D'OH! I had 1 cap and 1 wire from RS232 in the wrong place. Works like a charm now, using TX/RX too. The only downside to in-circuit serial debugging is that it interferes with any HSERIN/OUT, but it's awesome to find errors.
    Last edited by Demon; - 24th July 2006 at 18:52.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default

    The ICD feature in MicroCode Studio is totally different than Microchips ICD2.
    Hardware & software wise.

    ICD2 also doubles as a device programmer. That's why it uses the PICs'
    programming clock & data pins. To use ICD2 you need MPLAB, the ICD2
    hardware, and the PIC wired like shown in the ICD2 hardware diagram.

    The MCS ICD feature uses the PIC onboard hardware USART to send debug
    information back to the PC via the serial connection. When you compile your
    code in the MCS editor using the ICD compile button, it automatically includes
    additional debug code mixed in with yours to handle the ICD apsect.

    The two are completely different.
    Regards,

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

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I, too have tried to use the debuggers, but have had no success whatsoever. I'm either 1. Too dumb to understand the tutorials, or 2. Expecting it to work like it would if I wrote it.
    In either case, I have found both of the debuggers useless. So far, my opinion is that Microchip's is hard to use because it is purely software, and therefore has a hard time dealing with hardware events (how DO you write stimulus files, anyway?), while the Microcode Studio version always gives me errors, such as "path too long" - even when I have moved all files to the root of my C: drive.

    If someone has a "dumbed-down" explanation of the step-by-step use of a debugger, I would really appreciate it if they would post it.

    I have several ICD2's and all my PIC circuits use 8720's or 8722's with MAX chips. I use MCStudio. If there is a better/easier debugger that I should be using, tell me and I'll buy it.
    Charles Linquist

  6. #6
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default MCSP and ICD

    Hi,

    I have successfully used ICD with MCSP on a particular program I have used in the past (on a 16F877A) and found it to be invaluable - it really cut down the time to market on one of our more extensive projects!

    Using Bruce's circuit, you don't need an ICD2 for this, you can program and debug the software in circuit. You need to use the correct boot loader for the PIC you are using which is found in the MCLoader of MCSP program files. This needs to be programmed into the PIC with a programmer before placing the PIC into the ciruit.

    The RX and TX pins are the right pins to use for communiaction in this circuit.

    In the PIC program, you must type:
    DEFINE LOADER_USED 1 at the top of the program

    Choose specific points of the program that you wish to debug and type:
    ENABLE DEBUG before it
    then after that part of the program type:
    DISABLE DEBUG

    You then have to use the ICD Compile and Program Button to compile the program rather than just the Compile and Program button.

    The "Loader Help Topics" in the Help section of MCSP contain all the necessary information for ICD including the circuitry between the PIC and the PC - check 'em out as they're very useful.

    Hope these pointers help.
    Last edited by Rob; - 25th July 2006 at 09:49.

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default

    Again, apples and oranges. The loader is one thing and ICSD is another. I use in-circuit serial debugging from MCSP without using the loader at all.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Demon
    The loader is one thing and ICSD is another. I use in-circuit serial debugging from MCSP without using the loader at all.
    True - but if you program a bootloader into the chip, then program the chip in circuit you are testing that your hardware/wiring is correct.

    Regards

    Rob
    Last edited by Demon; - 4th October 2016 at 17:00.

  9. #9
    Join Date
    Sep 2005
    Posts
    16


    Did you find this post helpful? Yes | No

    Question MCSP and ICSD

    After I made the initial post to this thread I continued my "research". I now understand that the MCSP ICD and the Microchip ICD are two completely different animals. But recent posts still have me puzzled. I have kept the MC ICD page bookmarked and I recently reviewed the information presented thereon. The only mention of a bootloader is that MCSP now includes a free bootloader that enables the user to program certain PICs without a hardware programmer. There is no mention of any bootloader being required to get the ICD to work reliably. I use the MELabs USB programmer and do almost all my programming using ICSP and it works very nicely.

    All that said, I must admit that I have not actually had a chance to try the experiment again. I've been living with DEBUG statments but I can surely see the advantages of MCSP ICSD if only I could get it to work on something other than simple programs.

    Does anyone really know if a bootloader is the answer?

    Thanks everyone. Mark

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


    Did you find this post helpful? Yes | No

    Default

    Using a boot-loader is totally optional. You can program the PIC in-circuit with
    your device programmer, use a boot-loader, or move the PIC back & forth
    from programmer to ICD circuit.

    It makes no difference how you get your code into the PIC. Only that you use
    the ICD/Compile button when creating your code.
    Regards,

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

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default

    Yup, I wired the 10-pin connector on my MeLabs serial programmer directly to the breadboard and do all my programming in-circuit. I use MicroCode Studio Plus using normal compilation and try to get everything working right. The other night was the first time I hit a wall in the debugging and slapped together a MAX232CPE circuit and followed these steps:

    - ICD compile using MeLabs serial programmer.
    - unplug programmer and connect MAX232CPE circuit.
    - run ICD and follow the breadcrumbs.

    You don't have to do step #2 'cause you have a USB programmer.

    Now I have to make myself a "Y" switchboard to toggle between 2 DB9 connectors: serial programmer and ICD debugger. That way I won't have to play musical chairs with the single serial cable on my computer.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  12. #12
    Join Date
    Sep 2005
    Posts
    16


    Did you find this post helpful? Yes | No

    Smile MCSP and ICSD

    Thanks Bruce and Robert. Since I posted the original post I have purchased the full MCSP package but I have not tried the ICD method again. I had assumed that what Bruce said was the correct method and no bootloader was required.

    My original problem was that it worked fine on a sample program that I believe I got off the Rentron site. So I know the basic hardware was good. When I tried it on an actual project it would hang up after the first few executable lines - and not always in the same place. I don't remember what the project was now but I think the problems came during the initialization portion.

    All my 'stuff' is at my office and when I get a chance I'll try the ICD again with the new MCSP.

    Thanks again, Mark

  13. #13
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Unhappy Why do I get a compilation error ???

    Hi All,

    Havent used the ICD feature before but this thread has made me take a closer look at it.

    I decided that my current project will benefit from this as I currently have loads of code stuffed in there to try and debug what is happening but have realised that if I use ICD then I dont need it.

    The problem I have is with this section of code

    For CharCount = 0 to NameCount
    Hserout [Name[CharCount]]
    Next CharCount
    Hserout [10]
    Hserout ["IP: ",DEC IP[0],".", DEC IP[1],".", DEC IP[2],".", DEC IP[3],10] 'Display IP Address

    The two lines in bold fail with the message "Bad Expression" but ONLY when I compile with ICD (CTRL+F9).
    If I compile normally (F9) then it compiles without errors!!

    Any ideas ?

    Thanks
    Keith

    www.diyha.co.uk
    www.kat5.tv

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default

    HSERIN/OUT commands opened up a Serial Window when I executed them in ICD. At first glance I can't see what is wrong with your code.

    What about the HSER definitions in your program, what does that code look like? Baud rate, etc.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  15. #15
    Join Date
    Sep 2005
    Posts
    16


    Did you find this post helpful? Yes | No

    Smile ICSD and HSEROUT

    I believe that the ICD uses the hardware UART of the target PIC to communicate with MCSP. My guess is that you can't do both - run the ICD AND use the hardware UART under your program control. The complier is raising an error when it sees the HSERIN/OUT command when compiling for ICD use.

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


    Did you find this post helpful? Yes | No

    Default

    I suspect it's this line Hserout [Name[CharCount]]

    How is this supposed to work? I.E. how are your variables/constants defined?

    EDIT: Found the solution. Enclose all your array elements in parenthesis VS
    square brackets.

    For CharCount = 0 to NameCount
    Hserout [Name(CharCount)]
    Next CharCount
    Hserout [10]
    Hserout ["IP: ",DEC IP(0),".", DEC IP(1),".", DEC IP(2),".", DEC IP(3),10] 'Display IP Address

    Works as expected.
    Last edited by Bruce; - 30th July 2006 at 17:39.
    Regards,

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

  17. #17
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce
    I suspect it's this line Hserout [Name[CharCount]]

    Found the solution. Enclose all your array elements in parenthesis VS
    square brackets.

    Hserout [Name(CharCount)]

    Works as expected.
    Excellent. Thanks Bruce.

    I also found out that instead of

    For CharCount = 0 to NameCount
    Hserout [Name(CharCount)]
    Next CharCount

    it would compile with a single line of

    Hserout [STR Name\Namecount]

    which would achieve the same result although "Namecount" would have to be one higher than in the For/Next example.

    What I dont understand is why the ICD compile gets upset with the square brackets when the ordinary complier accepts it.

    I use the following two bits of code in the same program which follow the same style and both of those are fine.

    For CharCount = 0 to NameCount
    Read NameBase + CharCount,Char
    Name[CharCount]=Char
    Next CharCount

    For CharCount = 0 to NameCount
    LCDout Name[CharCount] ' Boot message.
    Next CharCount

    It would appear that it is only a problem with Hserout because that command requires square brackets as part of its syntax.
    Just tried Hserin with the line Hserin [Name[Namecount]] and that compiles fine with [] or () around the array element.

    Mighty strange, will drop David Barker an email to let him know of the inconsistency between the two compiles.
    Keith

    www.diyha.co.uk
    www.kat5.tv

Similar Threads

  1. Replies: 1
    Last Post: - 10th December 2007, 23:57
  2. MPLAB ICD ver 1 & 16F628A
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th February 2005, 00:44

Members who have read this thread : 2

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