Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Why do I need an ICD (In Circuit Debugger)?

Status
Not open for further replies.

Suraj143

Active Member
Hi all!

If I buy a trainer board with ICSP (In Circuit Serial Programmer) I can program the chip. And after program I can run & see if the code works well without removing the chip. Because the trainer board has the output LED’s, Relays etc….to test.

For ex: turn an LED ON if not works I can again adjust the code & program the chip again & see whether it is working without removing the chip.

Now my question is why do I need an ICD? Without ICD I can program the chip with ICSP & change the errors.

I have read many articles about ICD but all it says it’s to PROGRAM & DEBUG as well. Without ICD also I can debug the chip by looking the code so why do I need an ICD?

Please explain this!

Thank you
 
An ICD lets you "see" inside the chip. You can set breakpoints (stops program execution) and you can view / modify any SFR or RAM location. You can also single step through your program. It's a tool, much like a power screwdriver is to a screwdriver.
 
Hi thanks for your input.

To modify SFR or RAM location I can do in the MPLAB ASM file & program the chip from ICSP.
A trainer board with ICSP has the feature to view the output through LED’s, Segments etc…..also………

So why I need ICD.I still cannot understand.

Sorry for that.
 
An In Circuit Debugger is analogous to finding a fault on a car engine by opening the bonnet, starting the engine, hooking up some diagnostic equipment and then monitoring what's happening and allowing you to make adjustments while it's running.

Altering the source code and repeatedly reprogramming the PIC to find a fault is like fault finding an engine with the bonnet closed.

The ICD lets you see the code executing 'live' inside the PIC. As Bill says you can stop it, inspect the contents of file registers to see if they contain what you expected, and even stop the code mid-execution, alter registers and restart execution.

Sure you can walk through your code manually and keep altering the source code and eventually you'll find your bugs, but in some situations it can be far easier to let the PIC do the 'walking',

 
Suraj143 said:
Hi thanks for your input.

To modify SFR or RAM location I can do in the MPLAB ASM file & program the chip from ICSP.
A trainer board with ICSP has the feature to view the output through LED’s, Segments etc…..also………

So why I need ICD.I still cannot understand.

Sorry for that.
ICD (In Circuit Debug) is used in conjuntion with a debugger.

The debugger can be used to watch the program and its data values as it executes.

Your debug method is OK. But suppose you wrote a program that did not do what you expected. You spend hours looking at the code and still you can not see the problem. You are stuck.

If you use a debugger either with ICD or a simulator you can step through the program and actualy see at what instruction it acts differently then you expected.

My guess is that up to now you have been working with somewhat simple programs. As programs become more complex and use more on chip devices you will be happy to have an ICD.

To learn more about what a debugger can do read the MPLAB simulator or ICD2 documentation.
 
Last edited:
Suraj143 said:
Now my question is why do I need an ICD? Without ICD I can program the chip with ICSP & change the errors.

I have read many articles about ICD but all it says it’s to PROGRAM & DEBUG as well. Without ICD also I can debug the chip by looking the code so why do I need an ICD?

You don't NEED one, but it's a very useful tool, it makes it much easier to find any bugs or problems. Once you've got used to using one you'll probably wonder how you ever lived without it - and bear in mind I don't even use one! :D (yet!).
 
You don't need an ICD. I understand they're handy if you happen to have one but it's not a necessity.

I've never used the ICD function and have been sucessfully designing and debugging PIC projects and code for several years now.
 
For what it worth ;)... I'll third it... no need for any ICD or SIM. LCD, RS232 link and your brain is usually more than enough. I release hundreds of new products/code in a year for my customers. NO ICD or SIM have EVER turn me on 'till now. Maybe i miss something?

But yeah, i know several developer which CAN'T live without ICD AND/OR SIMs.

Nobody work the same way :(
 
That's how I've done it too. Whenever I get 'stuck' I implement an RS232 hookup to Hyperterminal and I add code to 'dump' registers, variables, whatever, to the terminal at the problem section of code. Usually only ever takes me a few minutes to find my screwball mistakes.

Don't get me wrong. I suspect the ICD2 "debugger" is an incredibly valuable tool but it's just too limiting for much of the real time interrupt driven stuff that I do.

On the other hand, the Simulator has proven to be an invaluable tool for me when designing or debugging exotic new algorithms.
 
Mike said:
That's how I've done it too. Whenever I get 'stuck' I implement an RS232 hookup to Hyperterminal and I add code to 'dump' registers, variables, whatever, to the terminal at the problem section of code. Usually only ever takes me a few minutes to find my screwball mistakes.

That's only a 'last resort' ;) I mostly manage by hanging an LED or two on a couple of pins, or even just toggling pins and checking with a scope. Often all you need to know is which way a program has gone - a couple of LED toggles on different branches often tells you all you need to know.
 
Count me in for the "NO" queue.

I built my ICD2 clone nearly two years ago.

Till now I have never ever use its "debugging" feature, as I have not found the need to. Most of my projects usually have LCD or serial output and using these for debugging is much quicker than ICD2.

After code change, I just do assemble and downloading to PIC, all done within a few seconds.
 
I've developed code that way at times too. I used a bootloader so it was just a matter of assembling, moving a jumper on the target board, pressing reset, sending the hex file to the target, moving the jumper back, and pressing reset again. The whole procedure takes a less than a minute and I never had to break out the programmer.

I don't think of the serial port debugging method as a "last resort". Since the serial connection is almost always connected to the PC anyway, it's very easy for me to use PutString "CCPR1L = " followed by PutHex "CCPR1L" or PutBin "CCPR1L" macro instructions in my code for debugging variable or register values. Not sure how you'd do that by testing a pin level or lighting an LED or two.
 
Last edited:
Mike said:
.... moving a jumper on the target board, pressing reset, sending the hex file to the target, moving the jumper back, and pressing reset again.

I'm too lazy to go through all that and came up with an automatic PIC reset circuit.

After I done compiling, I just press the "Write Flash" button in and the PC Bootloader front end then resets the PIC into its bootloader and downloads the new hex file. One second later after hex download completed, the PIC internal bootloader passes control to the new code.
 

Attachments

  • reset_pic.gif
    reset_pic.gif
    4.3 KB · Views: 266
I use Mecanique Bootloader, and yeah, i agree, the automatic Reset is handy.

**broken link removed**

i'd modified my EasyPIC4 board as well. One SOT-23 mosfet, 1-2 inch wire, not much :D
 
Last edited:
Hi all thanks for your replies.
Now I slightly understand what is ICD & is for what.

So I planned to build an ICD circuit. Here is the circuit I’m going to build.
**broken link removed**

In the circuit I see TARGET PGD, TARGET PGC and TARGET MCLR what is this?
For what reason are they?

And after built do I need some other software to program the chip like IC PROG, WinPIC Prog etc…or can I program the chip within MPLAB 7.6?

Please reply me I’m a newcomer to this DEBUGGING world

Thanks
 
The chip you are programming/debugging is know as the target chip or target for short.

The MCLR is a line used to set/reset the target, also provides the VPP program voltage.

The other two lines are serial lines used to communicate between the ICD2 and the target. PGD is program data and PGC is a clock line for use with PGD.

The ICD2 (and clones) is used with MPLAB software from Microchip. It is a IDE or Integrated Development Environment that also contains a PIC simulator program. MPLAB is the only free program that I know of that works with an ICD2. You can read more about MPLAB on the Microchip web site.

The inchworm and inchworm+ are ICD2 clones. You can find the schematics for building them at www.blueroomelectronics.com. Many here have built these from scratch or as kits.
 
Wow thanks 3V0 for your explanation.

Here I have attached an ICD circuit one has already made.

Now if I want to program a new PIC16F876 where do I have to insert the chip? In the circuit already there is a 876 PIC.

I can plug the RS232 cable into this circuit. After that can I program with IC Prog?
 

Attachments

  • ICD.jpg
    ICD.jpg
    49.2 KB · Views: 283
Suraj143 said:
Now if I want to program a new PIC16F876 where do I have to insert the chip? In the circuit already there is a 876 PIC.

You have to connect it outside the ICD. There's a small socket with five pins. Run a cable from this socket to the right pins on the PIC you want to program. Look at the datasheet for the PIC to see wich pins. They're named PGD, PGC, MCLR. In addition you connect Vdd and Vss (+5V and GND)

I can plug the RS232 cable into this circuit. After that can I program with IC Prog?

I don't know ICProg, but you can use MPlab, wich is free downloadable from Microchip.

One tip about finding the right pins to connect. Don't mix MCLR with PGM! I've done it myself on a couple of PICs, and spent some time finding the silly error...
 
Suraj143 said:
Here I have attached an ICD circuit one has already made.

Now if I want to program a new PIC16F876 where do I have to insert the chip? In the circuit already there is a 876 PIC.

I can plug the RS232 cable into this circuit. After that can I program with IC Prog?
The only program you can use with your ICD is MPLAB from Microchp. You can download it for free from the Microchip Website.

Your ICD uses an ICSP connector. It has the MCLR, PGD, PGC, +5 and GND pins. Take a look at the schematics you built it from. It is up to you to get these signals to your target chip. Most often we put an ICSP connector on the target board and use a cable to connect the ICD ICSP to the target ICSP. This saves having to move the chip to and from a programmer socket.

EDIT:
Did you build this ICD? If so I am not sure that you understand it. The ICD has a PIC on it that is used to program other PICs. The problem is that the onboard PIC needs to be programmed or the ICD will not work. So if this is your only programmer you have no way to programm the onboard PIC.

That is to say: The PIC on the ICD is part of the ICD and not a target for your use. It is the brains for the ICD.

Did you use a new/blank PIC in the ICD or has it been programmed for use with the ICD?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top