realterm

What if what you’re debugging is a little more complicated than verifying a serial packet? That you’re not just tracking down an issue with a couple bytes or words of sensor, variable, or EEPROM data, but a more complex algorithm. In doing so, you may want to know the critical values involved in each step of the calculation. Oftentimes attempting to use a debugger will fall through due to the normal real-world timing issues. At this point you are going to need to look at some serious and fast data logging. A common method I employ is to generate an ad-hoc CSV file from the embedded solution and record the data using RealTerm. This will allow me to access and manipulate that data in MATLAB, Octave, or Excel depending on the exact needs of that project. I’ll walk you through a basic approach on the STM32 platform.

Useful hardware

  • Your development system, or board under test
  • An external USB to TTL cable. Having your COM port being powered separately from the device allows for more fluid debugging. You won’t lose your port number when you power cycle.

Useful Software and Libraries

  • RealTerm, or your serial terminal software of choice.
  • STM32 UART Subroutines

Step 1: Set-up your firmware

WARNING: Timing is always critical in embedded systems. Only print out the data that is absolutely necessary. If the debugging code has to be placed inside of a timer, be sure that the data being printed is not longer than the timer interval.

The first step is obviously implementing the proper debug code in your firmware. Note that the data is separated by a comma and each line is terminated by a “\r\n ” (which denotes a carriage return and a new line). Below is an example:

Step 2: Set-up and Capture with Real-Term

Configuring the baud rate and the port number on the Port tab, then configuring your “capture”. I will note that when RealTerm starts to save the data it will no longer update the display live.

Ports1

capture1

Step 3: Analyze the Data

Once you have your data captured, it’ll look something like the image below. Now you need to figure out what you want to do with it to find the information you need. Sometimes a simple analysis in Excel is enough. You may need to know the delta between the current and previous values or verify your math and writing a quick formula based on your inputs. To take this a step further I’ll show how this can be done using Octave (a free alternative to Matlab).

The necessary commands are:

The resulting plot is:

sample_trendline

Leave a Reply

Your email address will not be published. Required fields are marked *