Search by Tags

How to use SPI library

Applicable for

Article updated at 08 Jun 2018
Compare with Revision

Attention: 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.

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_SDI Master Out Slave In (MOSI) SODIMM_92 / SSP_TXD
+5V (2.7V - 5.5V operational range) - 3.3V

Download Project

VS2008 Project VS2013 Project VS2015 Project Module compatibility Language Library Version
SPI - - PXA / Tegra C Toradex CE Library (Old)
SPI SPI SPI Tegra / VFxx / iMX6 C Toradex CE Library (New)
SPI - - PXA / Tegra C# Toradex CE Library (Old)
SPI - - VFxx / iMX6 C# Toradex CE Library (New)

Note: 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


Sine waveform

Square waveform

Sawtooth waveform

Triangle waveform