I got an email from Sara, a listener of Embedded.fm and a fairly new embedded developer.

Hi! It's my first job after college, and I was kind of thrown into this embedded world without knowing anything really (it's not what I studied in college). I'm the only one at my company that does embedded development, all my colleagues do web development, with Java, mySQL etc. What I mean to say is that I don't have anyone to ask, and that it's my responsibility alone that my code and my development environment works. It can be scary at times, and I feel that I lack knowledge.

At the moment I just use the development environment my predecessor at the job used and taught be before he quit. It's gcc and Eclipse IDE, and for debugging I simply print stuff on UART/COM.

Could you please talk about development environments and compilers? Would it be better to use Keil or IAR? What is the difference, really? Is gcc bad when compared to Keil or IAR?

And debugging, this JTAG thing everyone seems to talk about. How do you use it? How does it work? What can you do with it?

I got hired because I'm really good at C, but now there's all this other stuff too. I'm eager to learn, but I don't know where to start. You might be a good place to start? :)

/Sara from Sweden

Dear Sara from Sweden,

Have you used VisualStudio, XCode, or GDB to debug a program on your PC? So you can set a breakpoint, step through the code, and inspect variables? That's what a debugger will do for your embedded system. And JTAG is a common form of it (there are other forms of debugging interfaces: ARM’s is called SWD, Freescale’s is BDM, but most people still call them JTAG instead of "debugging interface").

I've done whole projects with debug-through-print and it isn't terrible. But printing takes time and that can mean timing-related bugs appear and disappear with the print statements. A debugger will let you look inside your code instead of standing on the outside. Crashes are much, much easier to figure out with a debugger.

You didn't say what kind of processor (or processor family) so I can't say "and for $60 this could all be yours" but debuggers aren't nearly as expensive as engineering hours. One important caveat, you must have the hardware support for a debugger: the necessary pins have to be sticking out of your board. If you have a schematic, look for TDO (for JTAG) or SWDIO (for SWD). If you don't have a way to hook your debugger to your board, then printing is probably the only way.

There is a good chance you may already have a debugger or something similar, how do you program your code into the board? Do you have a USB widget that looks like one of these and plugs into your board?