How to use SPI library
this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.
SPI (Serial Peripheral Interface) library make the use of the SPI/SSP interface very easy.
Use cases:
- SPI based Temperature sensors
- Memories like Flash and EEPROM
- Audio codecs
- DAC (Digital to Analog Converter)
- MMC and SD cards
- and many more..
SPI Library
For general information about SPI, please have a look at this article.
We provide free SPI Library including sample demo source codes.
- SPI using Pooling Mechanism
- SPI using DMA Library
NOTE: Please use compatible SPI Channel if you want to maintain compatibility between different Colibri modules.
Demo Application showing how to use external SPI DAC Chip
This tutorial demonstrates the use of Toradex SPI library to interface MCP4921 12-bit digital to analog converter (DAC) with Colibri T20 module using Evaluation board v3.1A to generate waveform.
Hardware setup
The following pin connections have to be made between MCP4921 12-bit DAC and Evaluation Board v3.1A.
MCP4921 | SPI Signal | Evaluation Board V3.1A (Silkscreen) |
DAC_CS | Chip Select (CS) | SODIMM_86 / SSP_FRM |
DAC_SCK | Serial Clock (SCLK) | SODIMM_88 / SSP_SCLK |
DAC_SDI | Master Out Slave In (MOSI) | SODIMM_92 / SSP_TXD |
+5V (2.7V - 5.5V operational range) | - | 3.3V |
GND | - | GND |
Download Project
VS2008 Project | VS2013 Project | VS2015 Project | Module compatibility | Language |
---|---|---|---|---|
SPI | - | - | PXA / Tegra | C |
SPI | SPI | SPI | Tegra / VFxx / iMX6 | C |
SPI | - | - | PXA / Tegra | C# |
SPI | - | - | VFxx / iMX6 | C# |
It is always recommended to update the libraries first before compiling the demo project. Click on this link to get latest libraries.
Demo application in C
Demo application in VCsharp
Output
Sine waveform
Square waveform
Sawtooth waveform
Triangle waveform