I’ve been spending some time getting to know AVR Studio 4, especially the simulation and debugging functionality. It’s a very functional and very useful free development suite that can be downloaded from Atmel from here.
As I mentioned a while back I have had a C compiler and development and programming tool chain set up for a while now but I hadn’t got around to working out how to debug the code. AVR Studio allows me to simulate (or debug with an ICE if I had one) and is very powerful. So far I’ve only debugged assembly code but from the docs with WinAVR (my source of the C tool chain) imply that I can use AVR Studio to simulate and debug C code too as long as I get the debug info format correct.
The great thing about simulating the microcontroller is that I can simulate chips that I don’t have (which is convenient as I have been stepping through the code for the 16 channel servo controller that I mentioned here (code available from this article, here)). At first I thought I’d need to port this code from the Atmel AT90S4414 to something that I have, but, of course, I can simply run this code in the simulator. The simulator is very powerful and shows the internal state of the microcontroller and lets you fiddle with ‘virtual’ input pins and watch the values of the outputs, etc. I’ve found that it’s made it much easier to start to get a grip on AVR assembly language as I simply step through and watch the code as I would C++ on my PC. I’m currently wondering about how one goes about unit testing such code (I’m rather big into Test Driven Development and Unit Testing in my day job and would feel more comfortable writing code for my micros if I could bring some of those disciplines across with me). It seems that there’s no standard solution for the AVR (at least none that the guys on AVRFreaks use) although these ideas look promising. Obviously it would be easier to test C code as there’s a chance of building it on the host PC…
So far I haven’t written any AVR assembly language myself yet, but I have several pages of notes and ideas as to how I can take the ideas that have been presented in the AT90S4414 servo controller code and write the servo controller that I feel I need for my robot.