Tools for Debugging

For the systems described in this book, the minimum debugging tools you will need are a multimeter and an oscilloscope. Logic analyzers are very expensive tools that allow you to monitor and diagnose digital signals. They are essential for developing high-speed and complex systems (especially those with buses), but you should be able to get by without them for the designs in this book. Certainly, for a self-contained microcontroller, a logic analyzer is of no use at all.

A multimeter allows you to measure current and voltage, but more importantly, it also allows you to do a continuity test between two points (and verify that there is a physical, and therefore electrical, connection). However, do not do continuity tests if there are sensitive components in your system. The continuity test may damage them.

Warning

Don’t assume that just because a signal is present at one end of a trace it is present at all points along the trace. Check everywhere with an oscilloscope probe, and use your multimeter to confirm that signal paths are connected properly.

The oscilloscope allows you to view waveforms within your system, and as such, it is your principle debugging tool. Oscilloscopes range from the crude and ancient to the expensive and sophisticated. While you don’t need to spend $100k on an oscilloscope, you will need an oscilloscope that can accurately view waveforms. That rules out the $20 antique you picked up from Mr. Gorsky’s garage sale down the road.

You will need an oscilloscope of sufficient bandwidth to view the signals within your computer. There’s no point using a 20MHz oscilloscope to look at a 100MHz system clock. The oscilloscope simply won’t see it and, therefore, neither will you. The higher the bandwidth, the more you will see. While you may think that a 4MHz embedded processor might not need a 100MHz oscilloscope, that oscilloscope will allow you to see the rising edges of the waveforms as rising edges (and not just vertical transitions) and view minuscule timing differences that may be having an adverse effect. It will also allow you to see fine spikes of noise or ringing on your signal lines, which may be adversely affecting your machine.

I really like the low-cost Tektronix oscilloscopes for debugging embedded systems. HP and others also make nice tools. If you’re serious about developing embedded hardware, it’s worth investing in one. Keep an eye out for startup companies going under—you may be able to pick up some great test gear going cheap!

Tip

When using an oscilloscope, it is critical that you connect the ground clip of the probe to a ground connection close to (or better, on) your embedded system. Without this, your measurement of the signal will be affected by ground loop problems, and you will not get an accurate reading. You’ll spend ages chasing phantoms, all the while missing the real problem.

Another development tool is the In-Circuit Emulator (ICE). This is a small module, with the same footprint as the processor, which is placed into the target system under development. Under the control of software executing on a PC and emulating the embedded processor, the ICE behaves just as the processor would in-circuit. This allows you to interactively debug your hardware and software. This can be especially useful in systems based upon self-contained microcontrollers, where it would be otherwise difficult (impossible) to get to the system internals.

Some ICEs are better than others, and as with everything, you get what you pay for. For really sophisticated tools that closely match the timing and electrical characteristics of the processor, expect to pay big bucks. Cheaper systems will emulate the processor’s operation, but will do so with completely different signal timings. Also, for each processor type around which you develop systems, you’ll need a different ICE.

Some engineers use ICEs heavily during their embedded system’s development process. Call me a heretic, but I get by quite well without them. The catch with an ICE is that no matter how good a particular tool is, it is never going to be exactly like the real thing. There will always be some slight difference in the electrical characteristics or in the timing. The engineers at Boeing have a saying: “Test what you fly; fly what you test.” In other words, there’s no substitute for the real thing.

Get Designing Embedded Hardware now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.