====== SPI Protocol Viewer ======
{{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:shot2.png|}}
{{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:shot1.png|}}
===== Introduction =====
This is a workspace set up to generate SPI transactions with the //Protocol Analyzer// instrument's custom signal scripting tool. Through the scripting tool, the //Protocol Analyzer// generates a pattern corresponding to the binary ASCII values of "Hello World!". The //Logic Analyzer// is set to display the values transferred through the SPI signals in decimal. The signals are generated at 40kHz, and the //Logic Analyzer// is set to collect 4,096 samples at a rate of 1.02MHz, resulting in an approximately 3 ms acquisition time.
To learn more about the SPI protocol, the [[https://en.wikipedia.org/wiki/Serial_Peripheral_Interface|Wikipedia]] article about it is a good resource.
----
===== Inventory =====
* A Discovery Device with Digital I/O:
* [[https://digilent.com/shop/digital-discovery-portable-usb-logic-analyzer-and-digital-pattern-generator/|Digital Discovery]]
* [[https://digilent.com/shop/analog-discovery-studio-a-portable-circuits-laboratory-for-every-student/|Analog Discovery Studio]]
* [[https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply/|Analog Discovery 2]]
* //An Analog Discovery (Legacy) can also be used.//
* {{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:spi-protocol-viewer.zip|SPI Protocol Viewer Workspace ZIP Archive}}
----
===== Setup Instructions =====
==== 1. Hardware Setup ====
Plug your Discovery device into your computer via a USB cable.
No additional hardware setup is required for this project.
----
==== 2. Software Setup ====
Download and extract the WaveForms workspace from the {{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:spi-protocol-viewer.zip|SPI Protocol Viewer Workspace ZIP Archive}} (also linked in the inventory section, above).
----
Open WaveForms. Upon launch, WaveForms will generate a prompt asking to switch to the device used with the workspace. As this is the device originally used when the workspace was created and archived, select **No**. Navigate to //Settings -> Device Manager// in the menu bar at the top of the window, to check that the active device is your Discovery device.
{{reference:test-and-measurement:digital-discovery:pmod-kypd-output-to-console:device-manager.png|}}
----
Click the **Open Workspace** button on the Welcome tab. Navigate to and open the //spi-protocol-viewer// workspace in WaveForms.
{{reference:test-and-measurement:digital-discovery:spi-protocol-viewer:open-spi-protocol-viewer-workspace.png?600|}}
----
==== 3. Running the SPI Protocol Viewer ====
The workspace is ready to use. Press the "Single" button in the Logic window, then press the **Execute** button in the //Protocol Analyzer// instrument. The //Logic Analyzer// will display the decimal values of the ASCII codes for "Hello World!".
**Note:** //To view the data through the Logic Analyzer while using the Protocol Analyzer, the Protocol Analyzer was placed into debug mode, which disables the Protocol Analyzer's ability to receive data. If this workspace is used to receive data through the Protocol Analyzer, the debug button will need to be deselected.//
----
{{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:shot2.png|}}
//Protocol Analyzer Instrument//
{{reference:test-and-measurement:analog-discovery-2:spi-protocol-viewer:shot1.png|}}
//Logic Analyzer Instrument//
----
===== Final Notes =====
This workspace is a good starting point for testing a SPI device through WaveForms. By simply modifying the contents of the ASCII array, different values can be sent to a SPI slave device. An additional SPI bus can be added in the Logic Analyzer to view a device's responses on the MISO data line.
For more guides and example projects for your Test and Measurement device, please visit its Resource Center, which can be found through this wiki's [[test-and-measurement:start]] page.
For technical support, please visit the [[https://forum.digilentinc.com|Digilent Forums]].
{{tag>project digital-discovery analog-discovery-2 analog-discovery analog-discovery-studio}}