Society of Robots - Robot Forum

Software => Software => Topic started by: Razor Concepts on August 04, 2010, 03:54:25 PM

Title: Debugging. Is. AWESOME
Post by: Razor Concepts on August 04, 2010, 03:54:25 PM
If you are doing some even slightly complicated stuff, try debugging! In the case of AVRs, you need a JTAG ICE MKII to do it. But debugging is so awesome. I'm coding MSP430s, with a debug enabled programmer, and it is SO much easier than serial-print debugging, trial and error, uploading new code, seeing if it works, reuploading, etc etc.

Basically debugging enables you to go through step by step of your code and monitor EVERY variable you make and EVERY register that is being modified so you know EXACTLY whats going on in the microcontroller!! No more guess and check!! Makes life so much easier. DEBUG  ;D ;D ;D
Title: Re: Debugging. Is. AWESOME
Post by: amando96 on August 04, 2010, 04:33:10 PM
gotta agree, MPLAB IDE comes with a debugger that's a dream, saves time programming and stuff  :D
Title: Re: Debugging. Is. AWESOME
Post by: madsci1016 on August 04, 2010, 05:07:32 PM
lol, little excited? Yeah in circuit debugging is cool. That's how i got through writing programs in assembly.

My first robot since legos didn't have the option for a debugger or even a serial to use, we ended up having 10-20 distinct short songs played through a speaker so we knew what part of the code the robot was in, and therefore where it was crashing. The rest of the students in the lab weren't really happy with us however. 
Title: Re: Debugging. Is. AWESOME
Post by: Webbot on August 05, 2010, 12:34:44 PM
You can use AVRStudio to debug, single step, view variables, registers,set breakpoints etc. By just running the code in the simulator - ie you just do it all on your PC.  Although it doesn't work too well if you have compiled with optimisations enabled. Also their data definitions of each processor have some bugs in them - so on an ATMega640 (eg Axon or Axon II) then Timer4 (or it may be 5) doesn't work properly.

The other problem with simulators is that it doesn't work with things like I2C (coz the other device isn't plugged into your PC). There is a specification for 'stimuli' files that allows you record the contents of input pins and you can then run the simulator and it reads these values back. A kind of record and playback.

But yep - in circuit debugging is very cool as you are looking at the actual chip 'in situ' rather than some kind of simulation of whats going on. But the simulator is still useful for checking over basic stuff and for checking timings of PWM etc etc.
Title: Re: Debugging. Is. AWESOME
Post by: paulstreats on August 05, 2010, 03:30:57 PM
I just got a PICKIT 2 so I could use in circuit debugging (I used to use a homemaden programmer but ICD is a must now).
 The simuator that comes with MPLAB is also essential if you are modifying the hardware stack, its good to be able to see this.

 Serial Port communications are also essential for higher level debugging, being able to read map data into the pc (and also control your robot through the serial is good for 5 minutes fun ;D)
Title: Re: Debugging. Is. AWESOME
Post by: Asellith on August 06, 2010, 11:53:49 AM
where did you get yours? how much? and does it work on the axon? I've been thinking of getting this for a while because yes debugging while programming an MCU project is SO much easier. Digikey has it for $300 thats way to much and I can find knock offs for around $80 - $150 that's do ok but still pricey. More then I spent on my axons.
Title: Re: Debugging. Is. AWESOME
Post by: Razor Concepts on August 06, 2010, 12:09:50 PM
I don't have once since I'm moving on to other platforms, but looks like there are a lot of DIY JTAG programmers - heres one (closed source)
http://www.scienceprog.com/build-your-own-avr-jtagice-clone/ (http://www.scienceprog.com/build-your-own-avr-jtagice-clone/)

Wouldn't cost too much to mess around with these, but I would imagine the debugging would be really slow  :-\  For MSP430, using the TI debugger is really fast, but using the Launchpads built-in one, it just crawls....