Buying a debuger

I have come to a point in my noobish programing that I must see how my program is executed step by step, how my variables change, how my program detoirs because of the different conditions of the small loops that I construct/define , etc...
So what little I know about programming microcontrollers I need a debugger to do those things, to observe and step.So I was wondering is this going to do the job:

I have the Arduino Duemilanove and as I said I am a newbie and if that debugger is not usable I ask you to read why? :-?

That's not really a debugger. If you want to debug your program, connect it to your PC and add something like

Serial.print('Now reading analog sensor 3, current value is: '); Serial.print(aVar);

I think the key phrase is "AVR flash microcontrollers which support the ATJTAGICE interface".
168? no.
328? no.
1280? err....wait a minute...no.

Sorry, that won't do it.

If you have windows, you can install AVRStudio and run/debug your sketches in the simulator.
"real" Debugging of the AVR "in circuit" requires more complex hardware (jtag or debugWire) which the arduino hardware doesn't support (I guess that IN THEORY, it could support debugWire...)

Even if it supported such things, why not save your money and debug like they used to?

There is nothing stopping you from adding delays in the part you are debugging, and printing to serial where it is step-by-step at a pace you can follow.
You could even write a function that will wait untill you send a character over serial, giving the 'next step' method that so many modern IDE's offer for debugging purposes.

PS: if it is time critical code, trial&error is the only way to go (as far as I know).

trial&error is the only way to go

No there is a better solution, thinking about what is going on.

Get you thoughts confirmed by using print statements or flapping pins / LEDs up and down.

Trial & error is the infinite number of monkeys approach to getting it right.

Grumpy mike, please take note about the time critical code part in regards to the trial&error approach :wink:

please take note about the time critical code part

I did when I talked about:-

flapping pins / LEDs up and down

That is just an instruction and there are very few tasks that are that time critical. If they are that critical then they are not suited to this processor.

Grumpy mike, please take note about the time critical code part in regards to the trial&error approach

If things are really time critical, you compile to the assembler level (or decompile the object code), pull out your microprocessor data sheet, and start counting cycles.

The JTAG-hardware debugger will not work because the 328P does not have a JTAG interface.

thanks for the replies, they helped a lot!, I'll try the serial print stuff :wink: