Saleae Support
HomeDownloadUser ForumContact Us
  • Saleae Support
  • Orders & Shipping
    • Place an Online Order
    • Place a Purchase Order (PO)
    • Get a Quote
    • Check your Order Status
    • Distributors
    • Pricing and Availability
    • Discounts
    • Tax & VAT Exemption
    • Saleae Business Information
    • Shipping Policy
    • Receiving Invoices
    • Sales FAQ
      • What Is Included with the Product?
      • What Accessories Should I Purchase with My Device?
      • Is the Saleae Software Sold Separately?
      • Does Saleae Have a Trade-In or Upgrade Plan?
      • How Can I Find the Current Status of My Order?
      • Part Numbers, ECCN, HS Codes, and Country of Origin
      • Discontinued Products
      • International Customs and Duty Information
      • Does Saleae Offer Demo Units or Units on Loan?
      • When Is My Card Charged?
      • Unable to Ship to PO Box Error
      • Referred a Friend? Email Us!
      • Does Saleae Provide Drop-Shipping Service?
  • Getting Started
    • Setup
    • Configure
    • Record
    • Navigate
    • Measure
    • Trigger
    • Protocols
  • User Guide
    • Product Summary
    • Safety & Warranty
    • Supported Voltages
    • Device Calibration
    • Using Logic
      • Navigating the Software
      • Connecting the Logic Analyzer
      • Logic Accessories
      • Device Settings
      • Capture Modes
      • Navigating Your Data
      • Time Bar Settings
      • Measurements, Timing Markers & Notes
      • Capture & Preset File Management
      • Exporting Data
      • Delete Part of your Capture
      • Analyzers
      • Data Table & Terminal View
      • Color Themes
      • Demo Mode
      • Software Glitch Filter
      • Keyboard Shortcuts
      • Automatic Updates
      • Message Us Directly
  • Software
    • Supported Operating Systems
    • Download
    • Installation
    • Firmware Updates
    • Driver Install
    • Legacy Software
      • Logic 1.x Download (Deprecated)
      • Logic 1.x Installation (Deprecated)
      • Logic 1.x Changelog (Deprecated)
      • Logic 1.x User Guide (Deprecated)
  • Protocol Analyzers
    • Supported Protocols
    • Analyzer User Guides
      • Async Serial Analyzer - User Guide
        • Decode UART
        • Decode RS-232, RS-485, & RS-422
      • SPI Analyzer - User Guide
      • I2C Analyzer - User Guide
      • CAN Analyzer - User Guide
      • Simple Parallel Analyzer - User Guide
      • I2S / PCM Analyzer - User Guide
      • DMX-512 Analyzer - User Guide
      • SMBus Analyzer - User Guide
      • Decode Differential and High Voltage Data
  • Software Extensions
    • Extension Installation
    • Create and Use Extensions
    • High-Level Analyzer (HLA) Extensions
      • Shared High Level Analyzers (HLAs)
    • Measurement Extensions
      • Analog Measurement Extensions
      • Digital Measurement Extensions
    • Extension File Format
    • About Third-Party Extensions
    • Disabling Marketplace Extensions
    • Publish an Extension
    • HLA - Analyzer Frame Format
      • Async Serial - Frame Format
      • I2C - Frame Format
      • SPI - Frame Format
      • CAN - Frame Format
      • Manchester - Frame Format
      • 1-Wire - Frame Format
      • Async RGB LED - Frame Format
      • Simple Parallel - Frame Format
      • LIN - Frame Format
      • I2S - Frame Format
    • API Documentation
  • Automation & Analyzer SDK
    • Automation API - Logic 2
    • Automation API - Legacy Logic 1.x
    • Protocol Analyzer SDK
      • FrameV2 / HLA Support - Analyzer SDK
      • Rename a Custom Analyzer
    • More Information on our SDKs
      • Can I Access Raw Data in Real Time?
      • Migrate Code to the New Analyzer SDK
      • Sharing Custom Low-Level Analyzer (LLA) Code
      • VB.NET Support for Automation
  • Datasheets & Specifications
    • Datasheets
    • Logic Hardware Revisions
    • Logic Dimensions
    • Compliance Documents
  • Troubleshooting
    • Installation Errors
    • The Software Fails to Launch
    • The Software Crashes
    • Logic is Not Detected
    • Getting your Machine ID
    • Getting your Software Crash Logs
    • Getting the Console Output
    • Location of Your Config File
    • Error Message: ReadTimeout
    • The Captured Data Looks Incorrect
    • The Captured Data is Corrupted
    • A Protocol Analyzer Produces Unexpected Results
    • The 'Waiting for Trigger' Window Never Closes
    • Device USB VID and PID Information
    • Error Message: Out of Memory Exception Was Thrown
    • PC Performance Issues with Logic
    • Data Export Is Not Working
    • Error Message: A device was found, but the software was unable to access it
    • Trouble Downloading the Latest Software
    • Logic Does Not Connect over USB 3.0
    • Why Am I Seeing Spikes in the Digital Capture?
    • Logic Interferes with My Circuit Operation
    • The Add Analyzer Menu Is Not Displaying
    • Other Drivers Interfere with Logic's Operation
    • The Maximum Sample Rate is Not Selectable
    • The Digital and Analog Recording on the Same Channel Appear Different
    • Advanced USB Debugging for USB 3.0 Users with Linux Kernels 3.3 and Older
    • Saving or Loading Anything Crashes the Software
    • Error Message: The application was unable to start correctly (0xc0000005)
    • Memory Usage with Triggered Captures
    • The Cabinet File disk1.cab has an Invalid Digital Signature (Logic 1.x)
    • Software Crashes with Virtual Desktops
    • Pre-Trigger Buffer is Incomplete
    • Linux Shared Memory Crash
    • Missing Files: api-ms-win-crt-runtime-l1-1-0.dll or msvcp140.dll
    • Known Issues on OS X
    • A Measurement Appears Incorrect
    • All Known Issues
    • USB 3.0 Cable Customer Notice (2017)
    • Warning Message: Logic Pro is running as a USB 2.0 device
    • Software Issues with Encryption Products
    • Linux Permission Requirements for Logic Software
    • My Rise Time and Fall Time Measurements Seem Incorrect
    • The Analog Waveform Loads Very Slowly after Capture Is Complete
    • Input Channels are Missing
    • Exported MATLAB File Does Not Open
    • Saleae Logic LED Blinks Red
    • Crashes Caused by macOS Mojave (10.14)
    • Troubleshooting Signal Crosstalk
    • Error Message: DeviceSetupFailure
    • Error Message: Unable to detect WebGL and Other GPU Issues
    • Warning Message: Unsupported Version
    • Error Function: Device2::SetupDevice
    • Warning Message: Possible USB Host Controller Problem Detected
    • Error Message: StartCommandError
    • Logic 2 Error Messages
    • PC Detection Test
    • CentOS Compatibility Issues
    • Error Message: Failed to Load Extension
    • CSV Export is Slow
    • Set an Analyzer Starting Point in your Capture
    • Logic 2 is Consuming Disk Space
    • Connection Conflicts with USB Debuggers
    • PC Restart Causes Logic to Disconnect
    • HLA Fails to Display Special Characters
    • Data Table Shows Incorrect Values
    • Error Message: Failed to Load Custom Analyzer
    • Error Message: Capture Stopped
    • Error Loading Marketplace Extensions
    • Error: Capture stopped because backlog data exceeded 90%
    • This Analyzer's Native Export is Not Supported in Logic 2
    • Mouse Scrolling Issues
    • Error: A device was found, but it was removed before initialization completed
    • Error: An unknown error occurred during device connection
    • Visual Studio Error: Failed to Launch Debug Adapter
    • VS Code Fails to Launch Python Automation API Script
    • Analog Waveforms Do Not Appear on Linux
    • Reinstall USB Host Controller Drivers
  • FAQ
    • Technical FAQ
      • System Requirements for Saleae Products
      • What Is the Normal Behavior of the LED?
      • What Is the Difference between Logic/Logic16 (Gen1) and Logic 8/Pro 8/Pro 16 (Gen2)?
      • Recommended USB 3.0 Host Controller Cards
      • Device Settings Configuration Tips
      • What Is the Worst Case Channel to Channel Skew?
      • What is Asynchronous Sampling?
      • Which Saleae Products Can Decode 4-Bit Parallel LCD Communications?
      • How Can I Compare Two Clock Signals for Synchronization and Drift?
      • Converting I2S/PCM Captures into Audio
      • My Capture Shows an Uneven Duty Cycle
      • Can I Create or Edit .logicdata Files?
      • Can Saleae Logic Run on ARM / Apple Processors?
      • What Annotations Are Supported?
      • Time & Memory Saving Tools
      • How Can I Record Power Consumption?
      • Moving Logic to Its Own Host Controller
      • How Long Does It Take to Save a File?
      • XMonad on Linux Causes Issues
      • What Is the Maximum Bandwidth of Logic?
      • How Long Can I Record Data?
      • Can I Export Protocol Results Between Timing Markers?
      • Can I Generate an Analog Graph from Digital Data?
      • Time Measurement Error
      • Can These Products Replace an Oscilloscope?
      • Can I Use Multiple Logics on a Single PC?
      • Native Windowing Features Are Not Working Such as Snap or Gestures
      • Opening .logicdata Capture Files
      • How to Choose the Right Logic Analyzer for You
      • Saleae Open Source Support
      • How to Trigger the End of a Capture Instead of the Start
      • Using the Hardware with USB Extension Cables, Through Virtual Machines, or Ethernet Extenders
      • Are the Ground Pins Required for Each Input Used?
      • Can Saleae Products Output Data?
      • Resolution of the Analog Inputs
      • What Sampling Rate Should I Use?
      • Can I Share Data Captures with Others?
      • Binary Export Format (Digital) - Logic 1.x
      • MATLAB Data Export Format - Legacy Logic 1.x
      • Recording Multiple Protocols at the Same Time
      • Changing the Display Radix (Base)
      • Which Logic Analyzer Should I Get?
      • How to View and Debug Firmware Variables, State, and Function Calls
      • Using Saleae Logic Devices with Third-Party Pattern Generators
      • Can Logic Operate with a Full-Speed USB Isolator?
      • Which Saleae Devices Support Analog Recording?
      • How to Manage Protocol Analyzers when Using the Socket API
      • How to Export Serial Protocol Results to a Raw Binary File
      • How to Trigger On a Pulse with No Maximum Time Limit - Logic 1.x
      • Finding Your USB 3.0 Host Controller Information
      • Logic Reports Different USB Current Requirements
      • Is It Possible to Adjust the Logic Thresholds for the Digital Inputs?
      • Why Does Channel 0 Use a Black Wire?
      • Software Shows Multiple Logic Analyzers Attached
      • Are the Input Channels Isolated from Each Other?
      • Are There Feature Differences in the Software when Different Logic Analyzers Are Used?
      • Packet Level Decoding Support in the Analyzer SDK
      • What Higher-Level Protocol Analysis Features Are Available?
      • Support for USB 3.0 and USB 3.1
      • How Can I Compare Signals from Different Captures?
      • Do the Saleae Logic Analyzers Support Trigger Out?
      • Why is the Length of my Capture Incorrect?
      • The Options Button is Missing
      • Can I Change the Voltage Range of the Analog Inputs?
      • How Does the ASCII Radix Display Characters?
      • Do I Have a USB 3.0 Port?
      • What Is the Best Way to Compare Similar Sequences of Protocol Data?
      • Which Version of the Software Should I Use?
      • Import Custom Low Level Analyzer
      • OSX Analyzer SDK Xcode Setup
      • Can Custom Analyzers Process Analog Channels?
      • Automating Long Overnight Captures
      • What Options Are There to Export Multiple Protocol Analyzer Results into the Same File?
      • Do the Saleae Devices Support AC Coupling?
      • Suggestions for Capturing Multiple Instances of a Triggered Event Automatically
      • How Many Protocol Analyzers Can Be Used at Once?
      • Is It Possible to Run the Saleae Software on a PC without SSE2 Instructions?
      • Is It Possible to Import Data into the Logic Software?
      • How Do I Convert Exported CSV Analog Data in Voltages?
      • Is There Cross-Platform Support for the SaleaeSocketApi C# Project
      • Why Does Logic Get Warm?
      • Binary Export Format (Analog) - Logic 1.x
      • Electrical Isolation Suggestions
      • FCC and CE Testing Recommendations
      • 'Save Capture' and 'Export Data' is Disabled in the Software
      • File Format Description for Exporting Protocol Analyzer Results
      • Is There a Newer Version of the Software Available?
      • Is There a Way to Change the Window Resolution?
      • How Can I Extract Recorded Data Using Socket API?
      • Does the Software Support Windows 10 Tablets or Windows RT Tablets?
      • Standalone Software Information
      • Does the Saleae Software Support the Original Logic and Logic 16?
      • Timing Markers Disappear When I Start a New Capture
      • What Sample Rate Settings Are Available? Can I Sample at a Slower Rate?
      • How Do I Differentiate Data in the Export File when Duplicate Analyzers Are Used?
      • Running Multiple Versions of the Software
      • Test Clip Differences - Gen 1 & Gen 2
      • USB-C Cable Recommendations
      • Is My Capture Data Private?
      • Ethernet Connectivity Suggestions
      • Binary Export Format - Logic 2
      • Viewing I2C Addresses as 8-bit
      • Can I use Python Packages in my Custom Extension?
      • Are the Inputs Synchronously Sampled or Sweep Sampled?
      • Is Logic Affected by the Log4j Exploit?
      • Connecting Remotely with SSH
      • Is Silent Installation Supported?
      • Is the .sal File Format Documented?
      • Export Data via Socket API
      • Running Logic in a CI Environment on Windows with the SYSTEM Account
    • General FAQ
      • How Do I Get More Help on an Issue That's Outside the Scope of Saleae Support?
      • How to Identify Each Saleae Device
      • License for the Saleae Logic Software, SDKs, and APIs
      • How Do You Pronounce Saleae?
      • How to Create Project Content for Saleae
  • Returns & Warranty
    • Submit a Warranty Claim
  • Community
    • Ideas & Feedback
    • User Forum
    • Community Projects
    • Community Created Accessories
    • Community Shared Analyzers
  • Tutorials
    • Oscilloscope Tutorial
    • Logic Analyzer Tutorial
    • Learning Portal
      • Digital Protocols
        • Learn Asynchronous Serial
        • Learn I2C - Inter-Integrated Circuit
        • Learn SPI - Serial Peripheral Interface
        • Learn CAN – Controller Area Network
        • Digital MultipleX (DMX512)
        • Manchester
        • 1-Wire
        • Learn I2S / PCM
        • Management Data Input/Output (MDIO)
        • BiSS C
        • HDMI Consumer Electronics Control (CEC)
        • PS/2 Keyboard/Mouse
        • Universal Serial Bus (USB) 2.0
        • Single-Wire Interface (SWI)
        • Simple Parallel
        • Local Interconnect Network (LIN)
        • Joint Test Action Group (JTAG)
      • Common Acronyms and Definitions
      • What is a Glitch?
      • What is RAM? Why Does Logic Use it?
      • What is a Display Radix?
      • What is Data Bandwidth? Can I Reduce this in Logic?
    • Example Projects
      • STM32 Nucleo Board - Digital Signals
      • STM32 Nucleo Board - Analog Signals
      • STM32 Nucleo Board - Analyzing UART
      • STM32 Nucleo Board - Analyzing SPI
      • STM32 Nucleo Board - Analyzing I2C
Powered by GitBook
On this page
Edit on GitHub
Export as PDF
  1. FAQ
  2. Technical FAQ

How to View and Debug Firmware Variables, State, and Function Calls

Here are several suggestions for performing more advanced firmware debugging using Saleae logic analyzers and microcontrollers. All require that you have the ability to control one or more IO pins from firmware that can then be recorded by Logic.

Common applications:

  • Benchmark the time required for a function to complete

  • Carefully track and time transitions between power states

  • Record the number of occurrences of a particular event

  • Monitor program state and function call chains

  • Capture variable values

  • Get an overall picture of the timing of your program, end to end.

Before going into detail, it's worth noting that using a logic analyzer isn't the only way to debug or gain insight into what your embedded program is doing. Odds are you are already set up with an in-circuit debugger or a serial output already logging to the PC. While both of these debugging options are highly recommended, they also have big drawbacks that make using a logic analyzer an ideal complement to these tools.

Breakpoints and stepping through code: This is a great way to examine the state of your application, monitor variables, and single step through complicated functions. They are super useful for all embedded applications, but they have some pretty big drawbacks. First, the entire program halts when a breakpoint is hit. That means that if your code is time-sensitive, you will not be able to debug your code during the most important parts. For instance, if you want to debug code that is responsible for receiving some kind of signal, doing some processing, and then transmitting back in a fixed amount of time, you can use breakpoints to examine the state of the firmware, but the overall application will fail due to the unexpected delay or failure to receive a response. Breakpoints also can only be set on firmware instructions. You can't set a breakpoint for when an i/o pin changes state, and a breakpoint (or internal variable checking) won't tell you why SPI data isn't getting written to the bus when you call the write command.

Serial print messages: printf has been a staple of programming since before I could code, and although it's still very powerful, it has always had serious issues. The biggest is probably its speed. Generally, your serial port will be running at 9600 baud, but even if you have it clocked a lot faster, simply sending the string "done" or "error" could take thousands of times longer than the rest of your program's operation. If you're running an update loop at 1,000 Hz or even 100 Hz, adding one or two blocking print statements will stall out your program. For timing-sensitive applications, printf can cause more bugs than it can solve.

Using a Logic Analyzer for Firmware Debugging

The most common use of a logic analyzer during firmware debugging, beyond protocol decoding, is to simply check to see if a particular part of code is running at all. A simple toggling of an IO pin is low overhead (usually 4 clock cycles or less on some microcontrollers) and can be recorded using a logic analyzer with high precision. When sampling 4x faster than the core clock of your microcontroller, you can usually measure the timing between toggles down to the clock cycle, if necessary.

Toggling an IO pin, however, only provides 1 bit of information. The next logical step after toggling just one IO is to toggle multiple IO pins to print a parallel state. The Saleae software includes a simple parallel analyzer that can be used to decode the parallel state into an integer value. The parallel analyzer requires a clock channel in order to decode the data automatically, so it's recommended to dedicate one IO pin to the clock channel and then write a macro to output the parallel word and cycle the clock channel. That may require double the instructions as before, up to about 8 in many cases. (With a 20 MHz instruction clock, that's about 400 ns, or 0.4 us, which is still a lot faster than 1 ms required to transmit 1 byte with 9600 baud serial.)

What if you're running low on IO pins or run out? What if you need to transmit more information than just a few bits?

Saleae devices can record and decode serial data at much higher bit-rates than any USB to serial adapter. Logic 8 should have no trouble recording and decoding up to 25 mbps serial streams (when sampling at 100 MSPS).

Another common problem is when working on a form-factor PCB design where there are few or no unused IO that are accessible. In these cases, a little creativity can go a long way.

In our own designs, we've used an exposed I2C bus to print debug messages for Logic to record. Since a I2C host won't send data payloads unless a device ACKs its address, we've even implemented a debug system where only the address byte of a packet is used to print debug information. It's slow, and you need to make sure you don't accidentally write to a real device, but it's infinitely better than having no debug output at all.

Also, if the microcontroller directly or indirectly drives an LED, you can output high-speed bit-banged serial to that pin and record it with Logic. That is a lot more useful than using the LED as a basic status light.

Suggested Analysis Strategies

Logic analyzers are already very useful for decoding protocol data, verifying timing and operation of signaling, measuring frequency and duty cycle and measuring time between events and counting occurrences. Here are some suggestions for analyzing firmware operation by recording signals that were purposely created for firmware debugging and would not normally be present in an application.

Interrupt handling: Making sure that interrupts are not missed and handled appropriately. Try toggling a pin when the interrupt routine enters and again when it exits. Then record that pin as well as the signal that triggers the interrupt. Is there any chance that the event might occur again one or more times while the interrupt handler is still running? You may need to move data processing to a queue to free up the interrupt faster.

Program flow verification: It's very common for more advanced modules such as authentication modules, phones, and network connections to have complicated handshaking procedures that require careful state management. Printing a basic Hex word to a 3-bit parallel interface every time your application's state machine changes state will help you trace your application through the initialization process. If a resource is not always available, for instance, does your state machine properly go back to a valid state?

Power state monitoring: If you print out the power state with a few IO pins every time it changes state, you can record this extremely accurately using a high sample rate. Then use the built-in measurement tools to compute the duty cycle for which your device is awake. Already printing this to the serial port? That serial print command might be taking longer than the rest of your application time combined.

Benchmarking and Profiling: Some development tools include a cycle accurate simulator for finding the bottlenecks in high-performance code. However, if the performance relies on a physical event or signal that can't be simulated accurately, then this might not help. Toggle pins or print parallel words before and after every piece of code you would like to profile, and consider using inline assembly, if necessary. It should only add a few instructions as a very deterministic overhead. Move the statements around and retest to zero in on the problem.

Keep in mind that the Saleae Logic devices can record at high speeds for considerable lengths of time when little activity is present on the bus. In most cases, you should be able to record for minutes or even hours to thoroughly test your design. In some cases, it may be helpful to set up long recordings of your device's operation. For long-term recording or to automate captures, you can use our socket API below.

PreviousWhich Logic Analyzer Should I Get?NextUsing Saleae Logic Devices with Third-Party Pattern Generators

Last updated 3 years ago

There are a lot of other ways to extract debug information from your complete design when none of the obvious methods are available. If you can, we recommend designing in a logic analyzer debug header (or two) so you can directly connect Logic to your design. We recommend using 4x2 0.1" pitch male unshrouded headers and accessory connectors you can find here:

Logic-to-2x4 Header (Gen 2)
Automating Long Overnight Captures