The easiest way to test your Logic Analyzer is to use it to measure digital signals, that is, voltages that transition between two discrete values, such as 0 V and 3.3 V.
To demonstrate this, the example code (see below) for the STM32 Nucleo-F446RE can be uploaded via Arduino, mbed, or as a project for the AC6 System Workbench for STM32 (SW4STM32) integrated development environment (IDE).
Required Materials
Item
One of the Saleae logic analyzers: Saleae Logic 8, Saleae Logic Pro 8, or Saleae Logic Pro 16
To begin, plug 2 cable harnesses into your Saleae Logic Analyzer. Note that the arrow on the harness connector should be facing up and to the left (toward the ‘S’ in Saleae on your Logic Analyzer). While the colors of the wires do not ultimately matter, it can be helpful to have them line up with the resistor color code (from left to right): black, brown, red, orange, yellow, green, blue, violet.
Connect the wires to the male header pins on the Nucleo board as shown in the diagram. Note that most of the inner male pins are connected to the female pins in the Arduino UNO configuration. For a full pinout of the Nucleo-F446RE, refer to the pinout section on the mbed page.
Download the example code for your IDE:
If you would like to try running the code without installing any IDE, download the mbed example. Plug in your Nucleo board, and it should enumerate as a USB mass storage device on your computer. Unzip the example, and copy the .bin file to the Nucleo drive. The Nucleo board will reset, and the program will begin to run automatically.
Open the demo in your chosen IDE. Compile the program, and upload it to the Nucleo-F446RE development board. Whenever the board has power, it should begin running the digital example program, which counts in binary on pins D2-D9 (D2 is least significant bit).
Open the Logic software and make sure your Logic Analyzer is connected via USB (you should see “Connected” appear at the top of the window). Click on the Device Settings Button (the up/down arrow near Start). This will open the device settings window.
Set the speed to at least 50 MS/s and the duration to 1 second (length of time the analyzer will collect data). Click to enable 8 digital channels (0 through 7 in the top row). Make sure 3.3+ Volts is selected (only for Logic Pro 8 and Logic Pro 16; the Logic 8 does not have this setting but will automatically adjust for digital logic in the 1.8 - 5.5 V range).
Click the Device Settings Button again to close the configuration window. You should see all 8 channels appear on the left side. Click Start. The software should take a moment to collect data, and show you the results to the right of their respective channels.
Zoom in using your mouse wheel or the plus (+) key. Hover your mouse over a part of the waveform from Channel 0. You should see some text pop up, giving you some information about the pulses. The Logic software will automatically calculate the pulse width (w), the frequency (f), and the period (τ).
Sometimes, you need to measure a pulse or signal that happens sporadically. If you are unable to time the capture appropriately (e.g. within the 1 second capture time), you can use triggers to start the capture process whenever a channel changes state.
For example, we will configure the Logic software to begin capturing whenever Channel 7 (the most significant bit in our counter) switches from high to low (falling edge). This will center the capturing process around the point (t = 0) when the counter rolls over from 255 (0xFF) to 0 (0x00).
By default, the Logic Analyzer should be configured to trigger on a rising edge for Channel 0. Click on the Trigger Settings Button for Channel 0 and click on the Rising Edge button, which should disable all triggers for the analyzer. Verify that the trigger buttons for all channels change to the rising edge icon.
Click on the Trigger Settings Button for Channel 7. Select the Trigger on Falling Edge button.
Press the Start button and wait while the logic analyzers captures and processes data. Waveforms should appear in the main window pane. Zoom in around the trigger point, which should read 0 s : 0 ms : 0μs. You should see that the falling edge of Channel 7 lines up with this point (origin in time).
If you pan left on the waveforms, you should see that the Logic Analyzer is capable of capturing up to about 0.5 ms prior to the trigger point.
If you zoom in around the trigger point, you should see that not all pins on the microcontroller are capable of toggling at the exact same time.
One useful feature of your Saleae Logic Analyzer is its ability to measure analog signals (from 0 to 5 V). As such, it can function as an oscilloscope with up to 8 channels (for the Logic 8 and Logic Pro 8) or 16 channels (for the Logic Pro 16).
Depending on the number of channels you use, the Logic 8 can sample up to 10 MS/s (bandwidth of 1 MHz). The Logic Pro 8 and Logic Pro 16 can sample up to 50 MS/s (bandwidth of 5 MHz).
Example code is provided below for Arduino, mbed, or AC6 System Workbench for STM32 (SW4STM32).
Required Materials
Item
One of the Saleae logic analyzers: Saleae Logic 8, Saleae Logic Pro 8, or Saleae Logic Pro 16
For this example, you will only need 1 harness plugged into your Logic Analyzer. We will be using channel 0.
Connect the channel 0 and GND wires to the Nucleo board as shown below. Note that pin PA_4 (A2 on the Arduino headers) is DAC_OUT1 (digital-to-analog converter output 1) on the Nucleo-F446RE.
Download the example code for your IDE:
Open the demo in your chosen IDE. Compile the program, and upload it to the Nucleo-F446RE development board. Whenever the board has power, it should begin running the analog example program, which produces a sinewave pattern on pin PA_4 (Arduino pin A2).
Open the Logic software with the Logic Analyzer plugged in. Click on the Device Settings Button.
In the device settings window, set the speed to at least 50 MS/s and the duration to 1 second. Click both Clear buttons to disable all channels, leaving only the digital channel 0 enabled. Click the analog Channel 0 to enable it, and click the digital Channel 0 to disable it.
Click the Device Settings Button again to close the configuration window. Click Start to begin collecting data. After a moment, you should see a sinewave appear in the main window. Note that you might have to zoom out. If you hover your mouse over the sinewave, you should see the measured voltage at that time pop up.
If you would like to measure the time between two points on the signal, you can select the A1 and A2 markers underneath the Timing Marker Pair tab on the right side. Click the A1 button, which will put a marker on your cursor. Click on a peak in the waveform. Click on A2, which will put another marker on your cursor. Find an adjacent peak to place the second marker. You should see the time difference between those points appear next to the A1 and A2 buttons.
As you can see, the period is measured to be about 10 ms, which is close to the 100 Hz we set in the demo programs.
Universal Asynchronous Receiver/Transmitter (UART) is a fairly simple protocol with two lines (transmit and receive) going between two devices. The lines are normally held high until one of the devices wishes to communicate. At which point, the transmitting device pulls its transmit line low and sends out data with logic high being 1 and logic low being 0.
Example code is provided below for Arduino, mbed, or AC6 System Workbench for STM32 (SW4STM32).
Required Materials
Item
One of the Saleae logic analyzers: Saleae Logic 8, Saleae Logic Pro 8, or Saleae Logic Pro 16
Note that on the Nucleo-F446RE, the UART lines used to communicate with the host computer are connected to the programming chip next to the USB connector. Arduino pins RX/D0 and TX/D1 are disconnected from these lines by default, which means we need to use the RX and TX pins near the programming chip.
Connect the GND wire to an available ground pin on the Nucleo. Connect Channel 0 to TX and connect Channel 1 to RX.
Download the example code for your IDE:
Open the demo in your chosen IDE. Compile the program, and upload it to the Nucleo-F446RE development board.
Download and open a serial terminal program. Here are some suggestions:
Linux: screen, Terminator
Connect to the Nucleo board over the assigned serial port with a baud rate of 115200, 8 data bits, no parity bit, and 1 stop bit (8-N-1). Once you open the connection, anything you type should be echoed back to you.
Open the Logic software with the Logic Analyzer plugged in. Click on the Device Settings Button.
In the device settings window, set the speed to at least 50 MS/s and the duration to 1 second. Click both Clear buttons to disable all channels, leaving only the digital channel 0 enabled. Click the digital Channel 1 to enable it as well.
Click the Device Settings Button again to close the configuration window. With this setup, channel 0 is configured to capture UART data going from your computer to the Nucleo board (TX on the Nucleo), and channel 1 is configured to capture data from the Nucleo to your computer (RX on the Nucleo).
By default, triggering is set to occur on the rising edge of channel 0. UART is by default high, so we want to start capturing whenever the TX line drops low (start bit). Click the Trigger Button next to Channel 0 to bring up the Trigger Settings pop-up. Select the Trigger on Falling Edge option.
Click on the Trigger Button again to close the pop-up. Click Start, and you should see the Logic software tell you that it is waiting for a trigger.
Back in your serial terminal program, type the letter ‘a’. The Logic software should begin capturing data and then show you the results.
Click on the plus button (+) next to Analyzers on the right side of the Logic software. Select Async Serial to bring up the Serial settings window. Select 0 - ‘Channel 0’ for Serial, change the bit rate to 115200, and leave the rest alone.
Repeat this process to add an additional analyzer, but set the channel to 1 - ‘Channel 1’.
You should see two “Async Serial” bars appear under the Analyzers pane. Additionally, the captured serial data should both have the letter ‘a’ over them. This shows that you captured the ASCII letter ‘a’ going from the computer to the Nucleo and the same letter being echoed back.
Try measuring the time it takes for your Nucleo to capture and echo a letter, and see if you can type a few more letters during the capture period and decode them.
Serial Peripheral Interface (SPI) is a communication protocol often used between processors and devices that require a relatively fast interface, such as shift registers, flash memory, and some sensors. It is a synchronous protocol, which means it requires a separate clock line so that the transmitter can tell the receiver when to sample the data line.
Interestingly, SPI connections often rely on two data lines: MISO and MOSI. Because of this, data can be sent between the master and device at the same time (full duplex).
Example code is provided below for Arduino, mbed, or AC6 System Workbench for STM32 (SW4STM32).
Required Materials
Item
One of the Saleae logic analyzers: Saleae Logic 8, Saleae Logic Pro 8, or Saleae Logic Pro 16
Even though the Nucleo-F446RE has an onboard analog-to-digital converter (ADC), the MCP3002 is an easy-to-use and inexpensive ADC that communicates over SPI, which makes it perfect for demonstrating the protocol.
Connect the Nucleo to the MCP3002 and the MCP3002 to a 10k potentiometer as shown. Note that the SPI pins are also broken out to the male pins just to the right of the female Arduino headers on the Nucleo. This allows us to attach the Saleae Logic Analyzer wires.
Download the example code for your IDE:
Open the demo in your chosen IDE. Compile the program, and upload it to the Nucleo-F446RE development board.
Open the serial terminal program that you downloaded from the UART example.
Connect to the Nucleo board over the assigned serial port with a baud rate of 115200, 8 data bits, no parity bit, and 1 stop bit (8-N-1). Open the connection, and you should see the voltage from the MCP3002 being reported to you in regular intervals. Try turning the knob on the potentiometer to see the voltage change.
Open the Logic software with the Logic Analyzer plugged in. Click on the Device Settings Button.
In the device settings window, set the speed to at least 50 MS/s and the duration to 1 second. Click both Clear buttons to disable all channels, leaving only the digital Channel 0 enabled. Click digital Channels 1-3 to enable them.
We can set up the analyzer before we capture so that we can choose the appropriate signal as the trigger. Click on the plus button (+) next to Analyzers on the right side. Select SPI to bring up the settings window. Leave everything as default and click Save.
The Enable line (also known as CS or SS) is often the first signal to change prior to data being transmitted on a SPI bus. As a result, we’ll set our trigger on that line. Click on the Trigger Button next to Channel 3 (SPI - ENABLE), and select the Trigger on Falling Edge option.
Click on the Trigger Button again to close the pop-up. Click Start to begin collecting data. Because our code is set to send SPI data every 0.2 seconds, data collection should begin almost immediately.
Zoom in around the 0 s : 0 ms : 0 μs mark, and you should see the waveforms that traveled across the SPI bus at that moment. Click on the gear icon next to SPIunder Analyzers. Click on Bin under Display Radix to show the interpreted data as binary.
Above Channel 0 (MOSI), you should see the data that we are transmitting out from the Nucleo board: 0b11000000 for the first byte, and all 0s for the second byte. At the same time, data comes back in from the MCP3002 on Channel 1 (MISO). In this instance, only bits 1-10 carry information about the measured voltage.
Adjust the potentiometer and see if you get different data on the MISO line when you sample again.
Inter-Integrated Circuit (I2C or IIC) is a 2-wire communication protocol that allows multiple low-speed peripherals, such as sensors, to be attached to the same bus. Normally, a single microprocessor or microcontroller is configured as the master, which initiates all communication on the bus.
The 2 lines used in I2C are Serial Data Line (SDA) and Serial Clock Line (SCL). The lines are open collector or open drain, which means the drivers on the master or devices can pull the lines low but cannot pull them high. This configuration prevents damage to the drivers when more than one device attempts to communicate on the bus at the same time.
Example code is provided below for Arduino, mbed, or AC6 System Workbench for STM32 (SW4STM32).
Required Materials
Item
One of the Saleae logic analyzers: Saleae Logic 8, Saleae Logic Pro 8, or Saleae Logic Pro 16
One of the easiest to use I2C sensors is the inexpensive TMP102 temperature sensor. The sensor can be configured to drive an alert pin when certain temperature thresholds are met. However, we only need to worry about reading from the Temperature register. On power up, the TMP102 will simply begin sampling and storing temperature data in that register.
Solder header pins to the TMP102 breakout board, and connect the Nucleo to the TMP102 breakout board as shown in the following diagram. Note that GND, SDA, and SCL are broken out to the male pins to the right of the female Arduino headers on the Nucleo. This setup allows us to attach the Saleae Logic Analyzer wires.
Download the example code for your IDE:
Open the demo in your chosen IDE. Compile the program, and upload it to the Nucleo-F446RE development board.
Open the serial terminal program that you downloaded from the UART example.
Connect to the Nucleo board over the assigned serial port with a baud rate of 115200, 8 data bits, no parity bit, and 1 stop bit (8-N-1). Open the connection, and you should see the temperature (in Celsius) being reported to you in regular intervals. Try breathing on the TMP102 sensor to change the readings.
Open the Logic software with the Logic Analyzer plugged in. Click on the Device Settings Button.
In the device settings window, set the speed to at least 50 MS/s and the duration to 1 second. Click both Clear buttons to disable all channels, leaving only digital Channel 0 enabled. Click digital Channel 1 to enable it as well.
Set the protocol analyzer by clicking on the plus button (+) next to Analyzers on the right side. Select I2C to bring up the settings window. Leave everything as default and click Save.
The data line (SDA) is normally the first signal to change during an I2C transfer. Because the lines are open drain, they will be nominally high, which means that we need to watch for a high-to-low transition. Click on the Trigger Button next to Channel 0 (I2C - SDA), and select the Trigger on Falling Edge option.
Click on the Trigger Button again to close the pop-up. Click Start to begin collecting data. Because we told the Nucleo to read from the sensor every 0.2 seconds, we should begin collecting data right away.
Zoom in around the 0 s : 0 ms : 0 μs mark, and you should see some I2C data. Click on the gear icon next to I2C under Analyzers. Click on Hex under Display Radix to show the interpreted data as hexadecimal.
You should see a write operation and a read operation. Both should begin with the address of the TMP102, which is 0x48 as a 7-bit number. If we shift it left by 1 bit, we get 0x90, and the last bit determines the type of operation (0 for write and 1 for read).
If you look at the write operation, you should see that the address is followed by the memory location of the TMP102’s Temperature register (0x00) and an ACK (line is low for 1 bit). Immediately following the write operation, you should see a read operation. Here, the microcontroller waits for 2 bytes to be sent by the TMP102. In the picture, the bytes returned are 0x017 0x30 (binary 0001 0111 0011 0000). The first byte is followed by an ACK (line kept low for 1 bit) and the second byte is followed by a NACK (line returned to high for 1 bit to indicate the end of the transmission).
This binary data represents the temperature reading by the TMP102 and is interpreted in the program to produce a human-readable result (in Celsius). Try breathing on the sensor to change the reading and see if you can capture the results.