Debugging an embedded system can be an extremely challenging venture especially when communication interfaces are involved. The slightest timing offset between signals can be the difference between receiving a signal or not. Monitoring communication signals to ensure signal timing and even message content can be critical when developing a new driver or interface. One of the most fundamental tools used for debugging and monitoring a communication interface on an embedded system is a logic analyzer.
A logic analyzer is a powerful device that physically interfaces to the hardware signal lines similar to how a multi-channel oscilloscope would be connected. Unlike the oscilloscope, a logic analyzer can’t detect the voltage range but instead detects whether the channel is at a digital logic 0 (ground) or logic 1 (supply). This helps to remove distracting features such as rise times, overshoots, noise and other signal artifacts from the signal.
Most logic analyzers support at a minimum 8 channels of data which are often displayed in a strip chart fashion. This allows each channel to be compared to all other channels at the same instant in time. An example output from a Saleae Logic can be seen below
The logic analyzer allows different types of standard interfaces to be automatically decoded. Depending on the analyzer these can include UART, SPI, I2C, CAN and many more. Even if the interface that is being debugged can’t automatically be decoded, the signals can at least be recorded and then manually decoded.
Most logic analyzers have similar functions to an oscilloscope. These are functions like adjusting timing, sample rates and trigger modes. In fact, some higher end oscilloscopes include a logic analyzer built in so that both analog and digital signals can be monitored at the same time. It’s amazing the power that these tools bring to the development cycle! They be found at reasonable prices too! The Saleae Logic analyzer can be purchased for only $149!
Logic Analyzers can be used for more than just monitoring communications. They can also be used to get system timing. Spare input / output lines on the system can be used to determine when a function has started to execute and when it has finished. This is done by sprinkling some test code before and after the function calls that toggle the input / output bit. This is extremely helpful when analyzing how long it takes for different tasks in the system to run. The logic analyzer can be setup to measure the width of each of the toggles. An average can then be taken to get the average run time. It is helpful to also keep the maximum and minimum run times observed. This can be then used to understand the timing of the entire system.
Purchasing a logic analyzer is one the best things an engineer can do for their tool bench. These tools are indispensable for debugging an embedded system. After all, you can’t debug what you can’t see and the logic analyzer is an embedded engineers eyes.