Accelerating development of embedded systems with logic analyzers

While logic analyzers may be originally known for parallel system debugging with wide data buses, the last decade has seen their usage shifting to serial protocol applications, involving less signal lines, like I2C, SPI or UART. In this article, we’re going to go through the process of embedded system development and see how logic analyzers can be used to speed up product development, and ultimately, time to market.

A PCB is always beautiful until you start developing embedded firmware!

Breathing life into your electronics board

So that PCB just landed on your desk, with all components perfectly soldered. You’ve powered it up and checked all power supplies, and you even have a little green LED that says “All is fine!”. So far so good. Now you want to start writing some code for the embedded micro-controller and make sure all interfaces with sensors, memories and other peripheral components are operating correctly. This stage is quite critical, and can become very time consuming the moment you hit the first bug. Many parameters — sometime well hidden features of the MCU — may affect the operation of serial interfaces. Among those are parameters like clock configuration, power modes and GPIO configuration. If you’ve been through this process before, you know there are many reasons why a system may not work from the very first time. A logic analyzer like ScanaQuad can be very helpful atthis stage as it will totally remove the guesswork from this process. For example, if you’re setting up an I2C communication bus between a micro-controller and a sensor, your design flow may look like this:

  • Configure MCU and run a test code to read sensor signature over I2C
  • Connect a logic analyzer to look at SDA and SCL lines (see image below)
  • Check SCL clock frequency and make sure it’s coherent with what you expected
  • Use protocol decoder feature to make sure address written in your code matches the address of the I2C slave device, and make changes in code if necessary.
  • Ensure slave device acknowledges master requests.
ScanaStudio logic analyzer software lets you capture logic signals and analyze them in depth

Getting through phase two: user application

After a system passes this first “sanity check” phase, a logic analyzer can still be a vital development tool. ScanaStudio logic analyzer software is designed to accompany embedded system developers in that second phase of a project, that is, when the low (physical) layers of a communication protocol are proven to be functional, but the top level, user application, needs development and — eventually — debugging. In this phase, one needs to be able to look at data transported through a communication protocol from various angles and with different levels of abstraction. A descent logic analyzer software lets a programmer look at high level transactions, and still easily track a specific bit or byte all the way down to the logic signals beneath it.

Testing your code

Even if more and more systems are shipped with firmware upgrade feature, I personally know the feeling you have when your code is being burned into thousands of chips that will travel around the globe. It’s stressful and the best thing you can do is to thoroughly test your code. But how? Again, logic analyzer can be used for that purpose. Let’s use the same I2C bus example and see how one can use ScanaQuad Logic Analyzer to monitor an I2C bus for a very long period (hours or days), searching for any signs of failures.

  1. First, you’ll need to identify what’s the normal behavior of your bus, and what isn’t. An abnormal behavior can be as simple as an address not being acknowledged or a data that read all ones (0xFF).
  2. Setup a trigger that matches this very specific situation you want to monitor
  3. Hit “Start” in ScanaStudio software, and get yourself a cup of coffee or some fresh air! As soon as the bug is detected, it will trigger a capture sequence, and you’ll be able to analyze the bug and hopefully fix it.
ScanaQuad Logic Analyzer lets you trigger on sophisticated events like a specific I2C packet.

In conclusion, this article shows how a logic analyzer — along with the good practice of talented developers — can lead to quicker and more robust embedded product development.