Microchip® Advanced Software Framework

SAM SPI Unit Test

Overview:

Introduction

This unit test carries out tests for SERCOM SPI driver.

It consists of test cases for the following functionalities:

  • Test for driver initialization.
  • Test for single byte write and read by polling.
  • Test for buffer write by polling and read with interrupt.
  • Test for buffer read & write using transceive function.
  • Test for 9-bit data transfer.
  • Test for baudrate.

The following kit is required for carrying out the test:

  • SAM D20 Xplained Pro board
  • SAM D21 Xplained Pro board
  • SAM R21 Xplained Pro board
  • SAM L21 Xplained Pro board
  • SAM L22 Xplained Pro board
  • SAM DA1 Xplained Pro board
  • SAM HA1G16A Xplained Pro board
  • SAM C21 Xplained Pro board
  • SAM R30 Xplained Pro board
  • SAM R34 Xplained Pro board
  • WLR 089 Xplained Pro board

Setup

The following connections has to be made using wires: -SAM D20 Xplained Pro

  • SCK: EXT3 PIN18 (PB23) <–> EXT2 PIN15 (PA17)
  • SS_0: EXT3 PIN15 (PB17) <–> EXT2 PIN16 (PA18)
  • DI/DO: EXT3 PIN17 (PB16) <–> EXT2 PIN17 (PA16)
  • DO/DI: EXT3 PIN16 (PB22) <–> EXT2 PIN18 (PA19) -SAM D21/DA1 Xplained Pro
  • SCK: EXT3 PIN15 (PB17) <–> EXT2 PIN15 (PA17)
  • SS_0: EXT3 PIN16 (PB22) <–> EXT2 PIN16 (PA18)
  • DI/DO: EXT3 PIN17 (PB16) <–> EXT2 PIN17 (PA16)
  • DO/DI: EXT3 PIN18 (PB23) <–> EXT2 PIN18 (PA19) -SAM HA1G16A Xplained Pro
  • SCK: EXT3 PIN17 (PA16) <–> EXT1 PIN16 (PA04)
  • SS_0: EXT3 PIN18 (PA17) <–> EXT1 PIN18 (PA05)
  • DI/DO: EXT3 PIN15 (PA20) <–> EXT1 PIN15 (PA10)
  • DO/DI: EXT3 PIN16 (PA21) <–> EXT1 PIN17 (PA11)

SAM R21 Xplained Pro

  • SS_0: EXT1 PIN15 (PB03) <–> EXT1 PIN12 (PA17)
  • DI/D0: EXT1 PIN16 (PB22) <–> EXT1 PIN7 (PA18)
  • DO/DI: EXT1 PIN17 (PB02) <–> EXT1 PIN11 (PA16)
  • SCK: EXT1 PIN18 (PB23) <–> EXT1 PIN8 (PA19)

SAM L21 Xplained Pro

  • DO/DI: EXT3 PIN9 (PA16) <–> EXT3 PIN17 (PB16)
  • SS_0: EXT2 PIN15 (PA17) <–> EXT3 PIN15 (PB17)
  • DI/DO: EXT2 PIN14 (PA18) <–> EXT3 PIN16 (PB22)
  • SCK: EXT2 PIN13 (PA19) <–> EXT3 PIN18 (PB23)

SAM L22 Xplained Pro.

  • SS_0: EXT1 PIN15 (PB21) <–> EXT2 PIN15 (PA17)
  • DO/DI: EXT1 PIN16 (PB00) <–> EXT2 PIN17 (PA16)
  • DI/DO: EXT1 PIN17 (PB02) <–> EXT2 PIN16 (PA18)
  • SCK: EXT1 PIN18 (PB01) <–> EXT2 PIN18 (PA19)

SAM C21 Xplained Pro.

  • SS_0: EXT1 PIN15 (PA17) <–> EXT2 PIN15 (PB03)
  • DO/DI: EXT1 PIN16 (PA18) <–> EXT2 PIN17 (PB02)
  • DI/DO: EXT1 PIN17 (PA16) <–> EXT2 PIN16 (PB00)
  • SCK: EXT1 PIN18 (PA19) <–> EXT2 PIN18 (PB01)

SAM R30 Xplained Pro

  • DO/DI: EXT1 PIN11 (PA16) <–> EXT3 PIN17 (PB02)
  • SS_0: EXT1 PIN12 (PA17) <–> EXT3 PIN15 (PA14)
  • DI/DO: EXT1 PIN7 (PA18) <–> EXT3 PIN16 (PB22)
  • SCK: EXT1 PIN8 (PA19) <–> EXT3 PIN18 (PB23)

SAM R34 Xplained Pro

  • DO/DI: EXT1 PIN11 (PA16) <–> EXT1 PIN17 (PB02)
  • SS_0: EXT1 PIN12 (PA17) <–> EXT1 PIN15 (PA23)
  • DI/DO: EXT1 PIN7 (PA18) <–> EXT1 PIN16 (PB22)
  • SCK: EXT1 PIN8 (PA19) <–> EXT1 PIN18 (PB23)

WLR 089 Xplained Pro

  • DO/DI: EXT1 PIN11 (PA16) <–> EXT1 PIN17 (PB02)
  • SS_0: EXT1 PIN12 (PA17) <–> EXT1 PIN15 (PA23)
  • DI/DO: EXT1 PIN7 (PA18) <–> EXT1 PIN16 (PB22)
  • SCK: EXT1 PIN8 (PA19) <–> EXT1 PIN18 (PB23)

To run the test:

  • Connect the SAM Xplained Pro board to the computer using a micro USB cable.
  • Open the virtual COM port in a terminal application.
    Note
    The USB composite firmware running on the Embedded Debugger (EDBG) will enumerate as debugger, virtual COM port and EDBG data gateway.
  • Build the project, program the target and run the application. The terminal shows the results of the unit test.

Usage

  • The unit tests are carried out with SERCOM1 on EXT2 as SPI master and SERCOM0 on EXT1 as SPI slave.
  • Data is transmitted from master to slave in lengths of a single byte as well as multiple bytes.

Compilation Info

This software was written for the GNU GCC and IAR for ARM. Other compilers may or may not work.

Contact Information

For further information, visit http://www.microchip.com.