Debug SPI Communication Protocol with Analog Discovery 2

Article By : Digilent Inc.

Developed in conjunction with Analog Devices and supported by Xilinx University Program, the Digilent Analog Discovery 2 is small enough to fit in your pocket, but powerful enough to replace a stack of lab equipment.

Digilent and SPI Communication

The Serial Peripheral Interface (SPI) is a duplex synchronous serial communication interface specification used for short-distance communication, primarily in embedded systems. It is commonly used for communication with flash memory, sensors, real-time clocks (RTCs), analog-to-digital converters, and more. SPI can also support having multiple slave devices, but additional slave select (SS) signal would need to be added. You can explore how SPI works at Digilent learning materials.

SPI communication protocol uses four communication pins along with a power and ground pin. There is generally a “master” device and a “slave” device that communicate with one another. The “master” will select one of its “slaves” with its slave select (SS) communication line to indicate to the “slave” that it is going to communicate with it. The master and the slave will then simultaneously communicate with each other on the MOSI (Master Out Slave In) and the MISO (Master In Slave Out) data lines. Both the master and slave send one bit to each other before the actual data are sent to make sure the SPI works. The data can either be sent from the most significant bit (MSB) or the least significant bit (LSB).

To initiate the communication, the master device must bring the chip select (CS) line to a low voltage state and maintain that low voltage state throughout the entire communication session. Both the master and the slave devices will send a bit to each other to make the SPI communication works. Data can then be simultaneously transferred one bit at a time between the two devices. The microcontroller platform controls the timing of the data transfer.

Commonly, the SPI protocol transfers one bit of data on the falling edge of the serial clock (SCK) signal. The data must be put on the data line before the falling edge of the serial clock (SCK). The serial clock (SCK) line must also be at a high voltage state prior to “falling” to a low voltage state (i.e. before falling edge). This can be done with a microcontroller by changing the voltage state of the data line prior to bringing the clock signal to a low voltage state.

The cycle of changing the bit value (voltage) on the data line and pulsing the serial clock (SCK) line will continue until all required bits are transferred. The chip select (CS) line will be brought to a high voltage state. Then, the microcontroller knows that communication has been completed and prepares for another session.

A timing diagram of SPI communication is provided below.

SPI time diagram from Digilent learn materials

Debug SPI Communication

Digilent Analog Discovery 2 is a multi-function instrument which you can measure, visualize, generate, record, and control mixed-signal circuits of all kinds. There are 16 channels for digital inputs or outputs. You can get access to its Logic Analyzer, through Digilent Waveforms, multi-instrument software application to debug the SPI communication.

There is example project to show you how to do so. In the project, you use the Digilent Pmod MIC3 (master) and Digilent Basys 3 (slave) to create the SPI communication. After the hardware is set up properly. You can debug the SPI communication with Analog Discovery 2.

For example, you can create individual signals including CS, SCK, MOSI, MISO and SCK and SPI protocol in the Logic Analyzer at the same time to look at each signal in the communication.

Add SPI protocol

Add Digital Signal

You can use the Logic Analyzer in Waveforms to visualize the SPI communication.

Timing Diagram in Logic Analyzer

The step by step tutorial for this project is available on the Digilent Project Page.

Product Highlight: What is the Analog Discovery 2?

Digilent Analog Discovery 2 is a USB oscilloscope, logic analyzer, and multi-function instrument that allows users to measure, visualize, generate, record, and control mixed-signal circuits of all kinds. Developed in conjunction with Analog Devices and supported by Xilinx University Program, this test and measurement device is small enough to fit in your pocket, but powerful enough to replace a stack of lab equipment, providing engineering professionals, students, hobbyists. and electronic enthusiasts the freedom to work with analog and digital circuits in virtually any environment, in or out of the lab. The analog and digital inputs and outputs can be connected to a circuit using simple wire probes; alternatively, the Analog Discovery BNC Adapter and BNC probes can be used to connect and utilize the inputs and outputs.

Driven by the free WaveForms software (Mac, Linux, and Windows compatible) software, Analog Discovery 2 can be configured to work as any one of several traditional test and measurement instruments including an Oscilloscope, Waveform Generator, Power Supply, Voltmeter, Data Logger, Logic Analyzer, Pattern Generator, Static I/O, Spectrum Analyzer, Network Analyzer, Impedance Analyzer, and Protocol Analyzer.

Product Highlight: What is the Basys 3?

Basys 3 is one of the best boards on the market for getting started with FPGA. It is an entry-level development board built around a Xilinx Artix-7 FPGA. As a complete and ready-to use digital circuit development platform, it includes enough switches, LEDs, and other I/O devices to allow a large number of designs to be completed without the need for any additional hardware. There are also enough uncommitted FPGA I/O pins to allow designs to be expanded using Digilent Pmods or other custom boards and circuits.

The Basys 3 is designed exclusively for Xilinx’s Vivado Design Suite, and the WebPACK edition is available as a free download from Xilinx.

To find out more about Digilent products, please visit www.digilent.com.

 

Virtual Event - PowerUP Asia 2024 is coming (May 21-23, 2024)

Power Semiconductor Innovations Toward Green Goals, Decarbonization and Sustainability

Day 1: GaN and SiC Semiconductors

Day 2: Power Semiconductors in Low- and High-Power Applications

Day 3: Power Semiconductor Packaging Technologies and Renewable Energy

Register to watch 30+ conference speeches and visit booths, download technical whitepapers.

Leave a comment