Calculating Timing

As we are finalizing the initial release of REXIS, we would like to provide some quantitative data on some of its features so that users and potential users can make intelligent decisions regarding this product.

There are a variety of methods for measuring timing on MCU firmware. Two popular methods are 1) using an internal MCU timer, and 2) toggling a GPIO pin so that you can observe the output waveform with an external device.

Because a timer needs to be set up, and also one must take into account of timer value rollover when computing the difference between the start time and the end time values, the GPIO output method is often the simplest. This is the method I chose to use in the test described below.

The MCU board I used in this test is the ST-Nucleo F411 with most/all of the I/O signals brought out to either the Arduino header pins or ST’s Morpho pins. At $13-$15, ST Nucleo boards are an excellent value. For this test, I selected PA5, since the pin is adjacent to the GND pin.

To detect the waveform, I required an external device that could observe a waveform. Logic analyzer, oscilloscope etc. are all capable tools. Most such tools are now PC-tethered and use the PC to display the data. I used the Saleae Logic (can vendors stop using generic non-googleable names for their products? I am looking at you, Google), which is a capable logic analyzer.

With my Saleae Logic 8, the gray wire goes to GND, and  I can connect up to 8 logic pins, each one to a different colored wire. The Saleae Logic pods are great for debugging I/O protocols such as SPI and I2C as well. For my simple test requirements, I just connected the black wire to PA5. Why the black one? I chose it because the last time I ran the Logic PC program, I had set up the black wire display to be on the top of this setup:

“Logic” Display

Each bar display corresponds to a physical colored wire on the Logic. You can move the bar displays to any order you like, and you can put a custom label under each bar. I had been using it previously to debug SPI issues, so the first few bars have the SPI signal names. The Logic program includes features that make analysis on popular protocols easy.

You can set a wire to trigger on logic changes, or logic levels. You can set the number of samples and the sampling speed from 25KHz to 24MHz, which should be fast enough for most MCU I/O activities.

Once it is triggered, it displays the detected waveform(s) on the corresponding bar displays. Conveniently, if you move the mouse to a wave, it will display its width, and if it is a regular waveform, it will display that waveform’s frequency.

For this test, it showed that the length of the output was 7.45 milliseconds. In the next post, I will explain what I was measuring and how it relates to REXIS.

This entry was posted in techniques. Bookmark the permalink.

Leave a Reply

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