Using the Logic Analyzer

Logic analyzers are used to record and analyze digital communication signals. They work in a similar manner to an oscilloscope, but the data is processed and displayed with additional data that is calculated by the software to help with this analysis. With the Analog Discovery 2 or Digital Discovery and WaveForms, you can record and decipher most types of digital communication signals


  • A chipKIT microcontroller. For this tutorial we will be using the uC32.
  • Arduino IDE with chipKIT Core installed
  • A Pmod with serial communication. This could be SPI, UART, or I2C. We will be using the Pmod CLS, a 2×16 LCD display.
  • A USB cable
  • A Windows, Linux, or Mac computer with USB port to run the software
  • Analog Discovery 2 or Digital Discovery
    • You may also use the original Analog Discovery or the Electronics Explorer Board with WaveForms. There are some slight differences in functionality between the Analog Discovery Legacy, Analog Discovery 2, and the Electronics Explorer Board, but nothing that will prevent you from following along if you have one of the other tools.
  • WaveForms software

Step 1: The Logic Analyzer

If you want some help getting your Analog Discovery 2 or Digital Discovery set up and calibrated, or installing WaveForms, check out this Analog Discovery 2 quick start guide or the Digital Discovery Getting Started Guide.

Once you have your Analog Discovery 2 or Digital Discovery and WaveForms all set up, open the Logic Analyzer by clicking on the “Logic” button.

Figure 1. Logic button.

This will open the Logic Analyzer window.

Figure 2. Logic analyzer window.

Along the top you'll see the “File”, “Control”, “View”, and “Window” options.

Figure 3. Logic analyzer options.

Under “File” you'll see several options.

Figure 4. File options.

You can add a new instance of the logic analyzer, either by cloning the current analyzer settings or opening an empty instance with default settings. You can also “Save” the current logic analyzer settings, or “Open” a previously saved project. “Export” lets you save the current logic analyzer plot data, either as an image of the window in most common formats, e.g. *.bmp, *.jpg, *.tif, etc., or as a data file with the plot window information in either *.csv, *.txt, or *.tdms formats. “Close Logic” will close the logic analyzer window. This will not clear the current settings as long as you don't close WaveForms completely. Just click on the “Logic” button again and the window will pop back open with all of the same settings.

Under “Control”, you have access to the tool's Single, Run, and Stop acquisition commands.

Figure 5. Control options.

“View” opens different windows to let you view and analyze the captured data.

Figure 6. View options.

“Data” shows a table with 2048 data samples from the current plot. Changing the plot Base value in the upper right corner will change the amount of time between data samples, but the tool will automatically divide the plot into 2048 samples and record the data in this table.

“Events” displays a table of all state change events currently view-able in the plot window. Options are available to change between different signals or busses under observation and to filter results based on various conditions.

“Logging” allows you to export the data as a .csv file. Several options are available for choosing when to save the file, which acquisition is exported, and what data within each acquisition is saved.

“Cursors” allows you to add cursors to the plot window much like you can for several other Waveforms tools. You can make the cursors independent of each other, or link them together so that changing one cursor changes all of its dependent cursors.

“Window” lets you switch between the Help window, the WaveForms welcome window, or any tool window currently open.

Figure 7. Window options.

Next, you'll see the logic analyzer controls.

Figure 8. Logic analyzer controls.

“Single” allows you to capture one window worth of data. To capture more data, adjust the time base of the plot window.

“Run” will start the tool for continuous acquisition. This button becomes “Stop” once the tool is running.

The “Mode” box lets you change how the data is displayed in the plot window, either one full plot at a time, real-time that wraps around once the end is reached, real-time side-scrolling, or you can record data. The example project will utilize the record function, so stay tuned for that.

Figure 9. Mode box.

The Logic Analyzer uses the computer memory to store past data acquisitions in a buffer. It keeps a running tally of which buffer you are currently using. Clicking on the green plus sign, displayed in Fig. 11, lets you save the currently shown acquisition data to a new tab. The name of the tab can be edited by double clicking the tab header.

Figure 10. Buffer.

Figure 11. Green plus sign.

You can trigger the Logic analyzer several different ways by clicking the “Trigger” box.

Figure 12. Trigger box.

“Auto” is selected by default. The tool will wait approximately 2 seconds once started. If no trigger is detected, acquisition will start automatically. “Normal” will place the tool in “Armed” mode once started. The tool will wait indefinitely for the determined trigger condition, at which point acquisition begins. “None” will ignore trigger settings and immediately start acquiring data once the tool is started.

You can set the source of your trigger by clicking the “Source” box.

Figure 13. Source box.

“Digital”, “Scope”, “Wavegen 1”, “Wavegen 2”, and “Patterns” refer to the Static I/O, Oscilloscope, Waveform Generator, and Pattern Generator tools of the Analog Discovery 2. Digital and Patterns refers to the tools on the Digital Discovery. “Manual” refers to the manual trigger button at the bottom left of the Waveforms window. “External 1” and “External 2” corresponds to the trigger pins T1 and T2, respectively, on the Analog Discovery 2's 30-pin header and allow you to connect any other external trigger source you wish. Up to two of the input channels on the Digital Discovery may be used as a trigger source.

Figure 14. Manual trigger.

Clicking “Pulse” opens the pulse configuration window. It is not recommended you use the Pulse or Advanced windows if you can avoid it. Protocol-specific trigger “wizards” are available from the grid setting options, which are covered in the next step.

Figure 15. Pulse button.

The “Glitch” tab is selected by default and triggers the acquisition when a signal pulse shorter than the specified time is registered.

Figure 16. Glitch tab.

“Timeout” triggers the acquisition when a signal pulse longer than the specified time is registered.

Figure 17. Timeout tab.

“Length” triggers the acquisition when a signal pulse of exact length with the given hysteresis is registered.

Figure 18. Length tab.

“Counter” looks for a set number of specified edges before starting acquisition.

Figure 19. Counter tab.

The “Advanced” button opens a window for advanced trigger settings.

Figure 20. Advanced button.

Figure 21. Advanced trigger settings.

Each protocol has its own specific trigger wizard, which are covered in the steps relating to each protocol. Since the wizards will configure the advanced options as needed, it is recommended that the wizards are utilized to set advanced options.

In order to adjust or apply an advanced option, you will need to have added a channel to the grid, which will be covered in the next step. Also, be sure that the Advanced box is checked. Clicking “Clear” will clear all settings to default, including unchecking Advanced.

Figure 22. Check Advanced box.

Figure 23. Clear settings to default.

Click the “Reset Condition” to set the trigger reset conditions for the tool.

Figure 24. Reset condition.

Your choices will appear in the grid in the “R” column. Once you clock “Close”, you will also see a text-based logic equation in the box next to the “Reset Condition” button in the “Trigger” window.

Figure 25. Close button.

Figure 26. Reset condition box.

Click the “Trigger Event” button to set the trigger event condition for the tool.

Figure 27. Trigger event.

Your choices will appear in the grid in the “T” column. Once you click “Close”, you will also see a text-based logic equation in the box next to the “Trigger Event” button in the “Trigger” window.

Figure 28. Trigger event box.

“Count” specifies how many edge counts should be ignored before triggering acquisition. You can specify up to 215 (32,768) counts. Check “Restart” to restart the counter once the count has been reached.

Figure 29. Count drop-down.

Figure 30. Restart option checked.

With “One wire” unchecked, “Filter” specifies the filter time for which a trigger containing an edge condition (rise, fall, or edge) does not detect further events. This also delays the sampling rate fir deserializer. For a trigger without an edge condition (rise, fall, or edge), “Minimum” specifies the minimum stable period. “Maximum” is not used for a trigger with an edge condition. For a trigger without an edge condition, it specifies the maximum stable period.

Figure 31. One wire unchecked.

Figure 32. Filter.

Figure 33. Minimum.

Figure 34. Maximum.

With “One wire” checked, “Bit” specifies the bit length. Sampling rate for the deserializer is also half this time length. “Timeout” specifies the protocol timeout. “Stuffing” tells the analyzer to skip the bit after the specified number of consecutive equal bits. You can specify up to 128 bits.

Figure 35. One wire checked.

Figure 36. Bit drop-down.

Figure 37. Timeout drop-down.

Figure 38. Stuffing drop-down.

Check “Deserialize” to use the deserializer unit. This function internally converts the serial data into parallel data, allowing the system to look at all of the bits at once. There is no user access to this parallel data. “Pin” specifies the pin from which to read the incoming serial data. “Value” and “Mask” are used together to mask the deserialized bits to compare to value. You can enter the values for Value and Mask in decimal, binary, or hexidecimal and the program will convert it and display it in hex format. Use this option to check specific bit states in a serial signal and then use that exact condition as your trigger.

Figure 39. Deserialize checked.

Figure 40. Pin drop-down.

Figure 41. Value drop-down.

Figure 42. Mask drop-down.

Step 2: The Grid (Part I)

The next section is the grid itself.

Figure 43. The grid.

Click the green plus drop-down to open a menu where you can select which type of data protocol you would like to analyze. Details on each choice are a bit farther down in this step. For our example, we will be analyzing a UART signal.

Figure 44. Green plus drop-down. Figure 45. Choose UART data protocol to analyze.

Click on the red minus drop-down to delete a selected protocol, or click on the “Clear” button to clear the entire grid. You can also press the delete key on your keyboard to delete a selected protocol.

Figure 46. Red minus drop-down.

Figure 47. Clear entire grid.

Figure 48. Drop-down menu for the remove options.

The button displayed in Fig. 49 opens the properties editor for whichever protocol channel is selected in the grid. This is the same window that opens when you first select a protocol to add to the grid.

Figure 49. Properties editor.

The “T” drops down the basic trigger settings. In order to use this menu, you have to have a specific DIO channel selected within the protocol being analyzed. You can choose “X” to ignore this channel, “L” to trigger when the signal is low, “H” to trigger when the signal is high, “R” to trigger when the signal rises from low to high, “F” to trigger when the signal falls from high to low, or “E” to trigger on any falling or rising edge. These settings can be accesses in multiple ways, and most protocols have their own specific trigger settings utilizing a trigger wizard, so if you don't see what you want here, keep reading.

Figure 50. Basic trigger settings drop-down.

Figure 51. Trigger settings options.

Use the scroll bar, displayed in Fig. 52, above the plot window to move the data window left/right once the data has been captured. Click on the arrows to change the position by a base span and double click to set the leftmost or rightmost position. Double click on the scroll area to reset the time to show the entire acquisition.

Figure 52. Scroll bar.

Below the scroll bar and to the left is the acquisition state indicator labeled “Done”. It's simply a visual indicator of the tool state, showing information such as whether the trigger is armed and ready or whether the tool is done collecting data. To the right of that, you'll see a print out of the number of samples, sample rate, and time of acquisition for the last acquisition captured. The data displayed here will also change to display data specific to each protocol as you move your mouse cursor over the data captured in each channel in the plot window below.

Figure 53. State indicator.

Figure 54. Data display.

To the far right of the screen you have two buttons, one for hot track and one to change plot window settings. Hot track is explained a bit later with the demonstration example. From the plot window settings, you can adjust the plot background color between “light” (white), “dark” (black), or “default” (dark gray). You can adjust the size, from 1-4 point, of the data plotted. You can also adjust and reset where the analyzer starts interpreting the captured data. This can also be accomplished by simply right clicking on the plot where you want to begin analyzing and selecting “Start from here”. All previous data will be ignored and the remaining data will be interpreted accordingly. Figures 57 & 58 illustrate this with a UART signal.

Figure 55. Hot track.

Figure 56. Plot window settings.

Original UART data captured. Notice how the 8-bit data packets are clearly interpreted and displayed above as both hexidecimal (h1B, h5B, h6A, h1B, h5B) and ASCII characters (“ESC”, “[”, “j”, “ESC”, “[”).

Figure 57. UART data interpretation.

Now telling the tool to adjust where to start reading the UART data, beginning where it “sees” a UART Start bit. Notice how the data displays incorrectly, missing one packet entirely and complaining of framing errors and skipping some bits. But by the fifth packet (second “[”) the tool had zeroed in on the correct UART sequence of bits and was able to decipher the remaining data correctly.

Figure 58. UART data errors and corrections.


Now let's add protocols to the grid. By clicking on the green plus drop-down, you can add several different protocols to the grid.

Figure 59. Add protocols to the grid.

Figure 60. Protocol options.

Be aware that you can assign DIO channels to multiple protocols, i.e., you can use DIO 0 to watch you UART data signal as well as your I2C SCL signal. Notice the “*” in the colored box in the IO column to indicate that the DIO is doubled up.

Figure 61. Assigning DIO channels.

Whatever data is captured will be displayed wherever that particular DIO is assigned. Luckily, you have 16 DIO pins (32 with the Electronics Explorer Board), so you should have no problem spacing out your protocols across the pins. Tyr and avoid doubling up if you can help it.

The first protocol in the list is Signal. Note that selecting any protocol will first open a small property editor window.

Figure 62. Property editor window.

Select one or multiple signals using the “Shift” and/or “Ctrl” keys on your keyboard. Once you have your channels selected, click the “Add” button to add the selected signals to the grid.

Figure 63. Add selected signals to the grid.

Figure 64. Grid displaying added signals.

You can edit each channel by double clicking it on the grid, or clicking either edit button in the grid next to the signal name or above the grid. For Signal, the only thing you can edit is the name of the channel. You can change the trigger condition from the grid by clicking on the symbol in the “T” column. “X” is set by default, but the same options described above apply here as well.

Figure 65. Edit button.

Figure 66. Edit drop-down button above the grid.

Figure 67. Trigger condition options.


The next protocol option is “Bus”.

Figure 68. Bus protocol.

Select the channels you want to use for your bus in the left table. Click on the white plus sign to add them to the table on the right. Remove any channel from the right hand side by selecting it and clicking on the white minus button. Clicking on the up or down green arrows with a channel selected allows you to change the order of the channels in the bus.

Figure 69. White plus button.

Figure 70. White minus button.

Figure 71. Up arrow to change order of channels up.

Figure 72. Down arrow to change order of channels down.

“Enable” selects and optional enable pin and polarity.

Figure 73. Enable.

“Clock” selects the optional clock pin and sampling edge.

Figure 74. Clock.

“Format” allows you to choose the numerical format for how the interpreted data is displayed. There are a number of formats to choose from.

Figure 75. Format.

Figure 76. Format options.

“Endianness” sets how the data is interpreted, either MSB first or LSB first.

Figure 77. Endianness.

“MSB” and “LSB” set the values for the first and last indices. The minimum for LSB is -32 and the maximum for MSB is +31. Changing either will change both, maintaining a separation difference equal to the number of channels assigned to the bus. This tool works like bit shifting the interpreted data, adjusting up/down the max/min values interpreted by the bus by a factor of 2 with each increase/decrease of the indices.

Figure 78. MSB.

Figure 79. LSB.

Click on “T” to open the trigger wizard.

Figure 80. Open the trigger wizard.

Figure 81. Trigger wizard.

With this wizard, you can set the trigger condition to look for a specific set of bits, corresponding to the number entered in the box. You can also set the individual trigger for any of the bus channels simply by clicking on the trigger symbol in the “T” column. Note that the tool will only trigger if the trigger settings fro all channels in the bus have been met when the data sample is taken.


Next on the list of protocols is Serial Peripheral Interface, or SPI, which is used extensively in embedded applications for synchronous serial communication.

Figure 82. Serial peripheral interface protocol.

Set the “Name” for your SPI.

Figure 83. Set SPI Name.

Assign a DIO to “Select” to watch the slave select signal and set the “Active” status as high or low.

Figure 84. Assign a DIO to Select.

Figure 85. Set Active status to high or low.

Set a second DIO to watch the “Clock” signal and set it to “Sample” on either the clock rising or falling edge.

Figure 86. Set DIO signal to watch Clock signal.

Figure 87. Set clock to sample.

Set a third DIO to watch the “Data” signal (either MISO or MOSI) and set whether the “First” bit in the data packet is the MSB or LSB.

Figure 88. Set third DIO to watch Data.

Figure 89. Set First as MSB or LSB.

“Bits” lets you set the bit size of your data packet (1-32 bits).

Figure 90. Bits.

“Format” allows you to choose the numerical format for how the interpreted data is displayed. There are a number of formats to choose from.

Figure 91. Format.

Figure 92. Format options.

“Leading: lets you set how many leading bits should be skipped when calculating the data value. Similarly, “Ending” sets how many trailing bits should be skipped when calculating the data value.

Figure 93. Leading.

Figure 94. Ending.

Using “Start”, you can delay the start of acquisition with respect to the first sample.

Figure 95. Start.

Once you have your SPI defined, click “Add” to add it to the grid. Once there, you can edit the SPI properties by double-clicking any of the SPI channels, or by clicking either of the property editor buttons.

Figure 96. Add button.

Figure 97. Properties editor.

Figure 98. Properties editor above the grid.

Open the SPI trigger wizard by clicking on the red “T” in the column.

Figure 99. Red T opens trigger wizard.

Figure 100. Trigger wizard.

You can set it to “Trigger” on SPI start, SPI Stop, or when a specific “Value” appears in the data packet. If you choose Value, define what value to look for in the Value box.

Figure 101. Trigger.

Figure 102. Value.


The next protocol on the list is Inter-integrated Circuit, or I2C. This protocol is also known as Two-wire Interface, or TWI. Like SPI, I2C is also used extensively in embedded systems communication.

Figure 103. I2C protocol.

As the alternate name, TWI, implies, I2C only uses two wires, so the protocol is really easy to set up. Define the “Name” of the protocol and set the “Data” and “Clock” channels.

Figure 104. Name.

Figure 105. Data.

Figure 106. Clock.

Once you have your I2C defined, click “Add” to add the protocol to the grid. Once there, you can edit the I2C properties by double-clicking any of the I2C channels, or by clicking either of the property editor buttons.

Figure 107. Add button.

Figure 108. Property editor button.

Figure 109. Property editor above the grid.

Open the I2C trigger wizard by clicking on the red “T” in the column.

Figure 110. Open the trigger wizard.

Figure 111. I2C trigger wizard.

The default “Trigger” setting is to trigger once the I2 signal starts. But you can choose from several other options as well.

Figure 112. Trigger.

Figure 113. Trigger options.

“Start” and “Stop” have no additional settings to define.

“Any ACK/NAK” will trigger acquisition on an acknowledge or not acknowledge signal. You can also set the option to Ignore any ACK/NAK signal.

“Address & Data” makes use of all options in the trigger wizard.

“Address” can be set to look for a specific peripheral device address. Valid address values are between h00 and h7F.

Figure 114. Address.

Set “ReadWrite” to trigger when reading or writing data to/from the device at the specified address, or set to ignore.

Figure 115. ReadWrite.

Set “Byte 1” and “Byte 2” to look for specific bytes in the data packet.

Figure 116. Byte 1.

Figure 117. Byte 2.

All three “Acknowledge” options look for the ACK or NAK data with the specified option. These can also be set to ignore the ACK/NAK data.

Figure 118. Acknowledge.

Step 3: The Grid (Part II)


Next is Universal Asynchronous Receiver/Transmitter, or UART. If you are familiar with microcontrollers in either the chipKIT or Arduino families, the Serial library uses UART to transmit/receive data.

Figure 119. Add UART.

Add any name for the UART protocol in the “Name” box.

Figure 120. Name UART protocol.

Set the Discovery DIO pin with “Data” to monitor the data being sent or received. You can only monitor either the TX or RX line with one instance of UART with the Logic Analyzer. If you need or want to monitor both TX and RX at the same time, simply add another instance of UART to the grid, assigning the second data line to the second instance.

Figure 121. Data.

Define how many bits are in your data packet with “Bits”. You have a range of 1-32 bits for the data packet size.

Figure 122. Bits.

“Parity” is defined as Odd, Even, Mark, or Space depending on the settings of the signal under observation. Select None if no parity bit is used.

Figure 123. Parity.

“Stop” lets you define how many stop bits are present in the signal.

Figure 124. Stop.

The default baud rate is set at 9600, but set “Baud” to “Manual” to manually set the “Rate to a different setting.

Figure 125. Baud.

Figure 126. Rate.

Set a delay in data interpretation using “Start”. The interpreter will not begin until that much time has passed with respect to the first sample.

Figure 127. Start.

Once you have your UART defined, click “Add” to add it to the grid.

Figure 128. Add button.

To edit the UART protocol, double click the Data channel in the grid or click on either of the property editors. Make the appropriate edits, then click “OK” to return to the grid.

Figure 129. Property editor.

Figure 130. Property editor above the grid.

Figure 131. OK button.

Click on the “T” to open the trigger wizard.

Figure 132. Open the trigger wizard.

Figure 133. Trigger wizard.

You can set the tool to trigger on Break, Idle, or a Value. If Value is chosen, enter the value of the data packet in the “Value” box. Click on “Ok” to return to the grid.

Figure 134. Value.

Figure 135. OK button.


Next is the Controlled Area Network, or CAN, which is used in automotive and robotic applications to communicate with all of ther peripheral devices on one main bus.

Figure 136. CAN protocol.

Name the CAN protocol whatever you want in the “Name” box.

Figure 137. Name.

Set the device DIO pin with “Data” to monitor the data.

Figure 138. Data.

Set the “Polarity” to either High or Low.

Figure 139. Polarity.

Adjust “Rate” to whatever rate you have your signal set at.

Figure 140. Rate.

Set a delay in data interpretation using “Start”. The interpreter will not begin until that much time has passed with respect to the first sample.

Figure 141. Start.

Once you have you CAN defined, click “Add” to add it to the grid.

Figure 142. Add button.

To edit the CAN protocol, double click the Data channel in the grid or click on either of the property editor buttons. Make the appropriate edits, then click “OK” to return to the grid.

Figure 143. Property editor.

Figure 144. Property editor above the grid.

Click on the red “T” to open the trigger wizard.

Figure 145. Open the trigger wizard.

Figure 146. Trigger wizard.

You can set the “Trigger” to Error, Break, or Identifier. The remaining fields only apply if Identifier is selected as the trigger.

Figure 147. Trigger.

Choose between 11-bit or 29-bit identifier in the “Extended” box.

Figure 148. Extended.

Define the identifier value in the “Identifier” box.

Figure 149. Identifier.

In the “Request” box, select between Data and Remote request types. You can select Ignore if you wish to ignore requests.

Figure 150. Request.

In the “Bytes” box, you can define the data section byte length, or choose to ignore this field.

Figure 151. Bytes.

Once the CAN trigger is defined, click “OK” to return to the grid.


The last defined protocol on the list is the Inter-IC Sound, or I2S, which was designed to transmit digital audio data. It is not related to the I2C protocol, so be sure not to confuse the two.

Figure 152. I2S protocol.

Set the name of your protocol in the “Name” box.

Figure 153. Name.

“Select” sets the DIO pin to monitor the Word Select line. “Low” determines which channel, left or right, is active when Select is low.

Figure 154. Select.

Figure 155. Low.

“Clock” sets the DIO pin to monitor the Clock line. Set “Sample” to determine which edge of the clock, rising or falling, is the sample edge.

Figure 156. Clock.

Figure 157. Sample.

“Shift” allows you to set whether the data bits are shifted with respect to the clock signal.

Figure 158. Shift.

“Data” sets the DIO pin to monitor the Data line. Use “First” to set whether the first bit in the data packet is MSB or LSB. “Align” lets you set whether the data packet is right or left aligned with respect to the data frame edges.

Figure 159. Data.

Figure 160. First.

Figure 161. Align.

Set the size, in bits, of the data packet in the “Bits” box. Values can range from 1 to 32 bits.

Figure 162. Bits.

“Format” determines which numerical format to use to display the interpreted data on the plot.

Figure 163. Format.

Once you have your I2S defined, click “Add: to add it to the grid.

Figure 164. Add button.

To edit the I2S protocol, double click and I2S channel in the grid or click on either of the property editor buttons. Make the appropriate edits, then click “OK” to return to the grid.

Figure 165. Property editor button.

Figure 166. Property editor button above the grid.

Figure 167. OK button.

Click on the red “T” to open the trigger wizard.

Figure 168. Open the trigger wizard.

Figure 169. Trigger wizard.

Set the “Channel”, right or left, to use as the trigger source.

Figure 170. Channel.

Set a specific watch value in the “Value” box. You can also ignore data packets if you wish. The value range corresponds to the number of bits defined in the data packet in the properties window.

Figure 171. Value.

Use “Clocks” to specify clock cycles in a frame. This is independent of data packet size and can range from 0-128.

Figure 172. Clocks.

Once the I2S trigger is defined, click “OK” to return to the grid.


The last protocol option is Custom, which lets you define your own protocol interpreter.

Figure 173. Custom protocol.

Waveforms is coded using JavaScript. Utilizing the SDK that downloads with Waveforms, custom applications can be built and included with your own installed version of the Waveforms application. For more on that, see the SDK PDF that downloads with WaveForms and the Waveforms reference manual.

Step 4: An Example

We've talked about showing an example several times now, so let's get to that. The Pmod CLS is a great device to use for this example because you can communicate with it using SPI, UART, or I2C. For this example, we'll use UART, and from the reference manual, we know that with CLS revision E (found on the underside of the PCB), we need to set the communication selection jumpers like so:

Figure 174. Pmod CLS jumpers.

There are two 6-pin Pmod headers on the CLS, J1 and J2. The silkscreen on the bottom shows the different communication protocol connections.

Figure 175. Pmod CLS headers.

Since we're using UART, we will need to use the RX pin on J2. We won't be expecting to receive data from the CLS, so the TX pin doesn't need to be connected. Also on J2 are the SCL and SDA pins for I2C communication. Use J1 for SPI communication. Both J1 and J2 have 2 power (V and G) pins for powering the Pmod.

Using a 6-pin MTE cable, connect the CLS to the ChipKIT board. The image shows a uC32.

Figure 176. Connecting Pmod and microcontroller.

Be sure to connect the RX pin on the CLS to the TX pin (1) on the uC32.

The CLS has a number of commands in the user guide that can be used for some basic set up. Once that is done, you can start sending text to it. The following code is a very simple example of this.

// ASCII values are in HEX, but can be converted to chars by typing a single apostrophe (')
// before and after the char, e.g. '['. Note that 'ESC' won't work.
byte setup_display[] = {0x1B, 0x5B, 0x6A, 0x1B, 0x5B, 0x30, 0x68, 0x1B, 0x5B, 0x32, 0x63};
                      // ESC,   [,    j,   ESC,   [,   0,     h,   ESC,   [,    2,    c
byte clear_display[] = {0x1B, 0x5B, 0x6A};
                      // ESC,   [,    j
void setup() {
  Serial.write(setup_display, 11);
  Serial.write("Hello World. How are you today?");
  Serial.write(clear_display, 3);
  Serial.write("I'm fine, thank you.");
void loop() {}

Download the code to the uC32 and the messages should display on the LCD.

Figure 177. Display gif.

Utilizing a mini grabber test clip, you can piggyback on the uC32 TX signal to analyze it with the Logic Analyzer. Be sure to also connect one of the Discovery GND wires to a GND pin on the uC32.

Figure 178. Connecting with mini grabber clip.

Set up a UART protocol interpreter with the Logic Analyzer tool. The default property settings will work fine here.

Figure 179. UART protocol interpreter.

Click on the “X” in the trigger column and select “Fall”.

Figure 180. Click on "X" in trigger column.

The UART data line holds logic high when not in use. The start bit of the data frame is indicated by dropping the line to logic low, so we know that we are about to get a data packet when the line goes low and the tool will trigger on that first falling edge.

In the “Trigger” box, select Normal so that the tool wil wait for the trigger and not automatically begin acquiring data.

Figure 181. Trigger.

At the top right of the plot window, enter 4.5 ms in the “Position” box. This will center the plot at 4.5 ms, shifting 0 ms to the left to allow us to see more data.

Figure 182. Position.

Click “Single” and the tool will wait for the trigger condition to be met, indicated by the status indicator “Armed”. Reset the microcontroller to begin sending serial data on the TX line. The tool will trigger and acquire 9.5 ms of data.

Figure 183. Single button.

Figure 184. Armed status.

Figure 185. Serial data.

We can see that the analyzer correctly interpreted the data packets and the hex value along with the ASCII character is displayed along the top.

The only problem is that we know that we sent a lot more bytes of data than the 9 we can see in the plot. Using the record function, we can capture the entire data stream. Let's look at that.

Select Record from the “Mode” box. The plot will likely resize, but don't worry the data is all still there. Save it, export it, whatever, but we'll get another sample in a minute.

Figure 186. Mode.

Click “Config” to configure the record function. A configuration window will open.

Figure 187. Config button.

Figure 188. Configuration window.

Our serial baud rate is set at 9600, which is essentially 9.6 kHz. We want the sample rate to be significantly higher than that in order to capture the data. The default “Rate” should be 200 kHz, but any value higher than 10X baud is fine, just don't go to high or you won't have enough samples in the buffer to record enough data for the time required.

Figure 189. Rate.

Set the number of “Samples” to determine how long the tool will record. Multiply your rate by the time required for acquisition to get you samples. In this case I already know that the uC32 is finished transmitting data to the CLS after about 2.5 seconds, so with a rate of 200 kHz, that leaves me with 500,000 samples.

Figure 190. Samples.

“Base” is set by the tool in this case, so don't worry about it.

Figure 191. Base.

Use the “Position” box to set the position on the plot of the first sample. 0% is far left, 100% is far right, and 50% is right in the middle. For this example, set it to 5%.

Figure 192. Positions.

Once everything is set, click “Start” to begin acquisition. The tool will buffer a few samples and then wait in “Armed” status. Reset the uC32 to begin transmitting to the CLS. The plot should look like Fig. 195 below once it finishes.

Figure 193. Start.

Figure 194. Armed status.

Figure 195. Example plot.

It doesn't look like much, but luckily we recorded it, so we can zoom in to see the data stream.

Figure 196. Example plot, zooming in on recording.

Use the scroll bar above the plot window to move left or right through the recorded data plot.

Notice that the data packets have been interpreted by the tool and both the hexadecimal and ASCII values are displayed at the top of the plot window.

Click on the “Hot track” button at the top right of the plot window. Zoom in on the recorded data stream and hover the mouse over it. Measurements and associated labels will appear on the plot, showing information like the data pulse width, period, etc.

Figure 197. Hot track button.

Figure 198. Zooming in on the measurements.

Step 5: That's It!

As you can see, the Logic Analyzer on the Discovery is a powerful tool for helping test and analyze digital communication protocols.

Note: When using the Digital Discovery, in order to achieve sample rates higher than 200MS/s the High Speed Adapter must be used. This is an optional add-on at checkout. The pin diagram is below: