4.6.5 Connecting to the SPI Interface

Four different FLEXCOM interfaces, with seven possible configurations (configured in SPI mode), and two pure SPI Interfaces, with four possible configurations, are available on the ATSAMA5D27-WLSOM1 module.

The Flexible Serial Communication Controller (FLEXCOM) offers several serial communication protocols that are managed by the three submodules USART, SPI, and TWI.

The Serial Peripheral Interface (SPI) circuit is a synchronous serial data link that provides communication with external devices in Host or Client mode. It also enables communication between processors if an external processor is connected to the system.

The Serial Peripheral Interface is essentially a shift register that serially transmits data bits to other SPI devices. During a data transfer, one SPI system acts as the “host”' which controls the data flow, while the other devices act as “clients'' which have data shifted into and out by the host. Different CPUs can take turn being hosts (multiple host protocol, contrary to single host protocol where one CPU is always the host while all of the others are always clients). One host can simultaneously shift data into multiple clients. However, only one client can drive its output to write data back to the host at any given time.

A client device is selected when the host asserts its NSS signal. If multiple client devices exist, the host generates a separate client select signal for each client (NPCS).

The SPI system consists of two data lines and two control lines:

  • Host Out Client In (MOSI)—This data line supplies the output data from the host shifted into the input(s) of the client(s).
  • Host In Client Out (MISO)—This data line supplies the output data from a client to the input of the host. There may be no more than one client transmitting data during any particular transfer.
  • Serial Clock (SPCK)—This control line is driven by the host and regulates the flow of the data bits. The host can transmit data at a variety of baud rates; there is one SPCK pulse for each bit that is transmitted.
  • Client Select (NSS)—This control line allows clients to be turned on and off by hardware.
Table 4-7. SPI Interface Configurations
Interface Instance IO set Pin # PIO Pin Name Comments
SPI0 1 21 PA14 SPI0_SPCK
SPI0 1 22 PA15 SPI0_MOSI
SPI0 1 23 PA16 SPI0_MISO
SPI0 1 24 PA17 SPI0_NPCS0
SPI0 2 76 PA30 SPI0_NPCS0
SPI0 2 75 PA31 SPI0_MISO
SPI0 2 81 PB00 SPI0_MOSI
SPI0 2 80 PB01 SPI0_SPCK
SPI0 1 18 PC01 SPI1_SPCK
SPI1 1 17 PC02 SPI1_MOSI
SPI1 1 16 PC03 SPI1_MISO
SPI1 1 19 PC04 SPI1_NPCS0
SPI1 1 20 PC05 SPI1_NPCS1
SPI1 1 176 PC06 SPI1_NPCS2
SPI1 1 177 PC07 SPI1_NPCS3
SPI1 3 132 PD25 SPI1_SPCK
SPI1 3 127 PD26 SPI1_MOSI
SPI1 3 123 PD27 SPI1_MISO
SPI1 3 124 PD28 SPI1_NPCS0
SPI1 3 131 PD29 SPI1_NPCS1
SPI1 3 130 PD30 SPI1_NPCS2
Table 4-8. FLEXCOM Interfaces Configurations in SPI Mode
Interface Instance IO set Pin # PIO Pin Name Comments
FLEXCOM0 1 28 PB28 FLEXCOM0_IO0 MOSI Signal
FLEXCOM0 1 27 PB29 FLEXCOM0_IO1 MISO Signal
FLEXCOM0 1 30 PB30 FLEXCOM0_IO2 SPCK Signal
FLEXCOM0 1 26 PB31 FLEXCOM0_IO3 NPCS0 Signal
FLEXCOM0 1 15 PC00 FLEXCOM0_IO4 NPCS1 Signal
FLEXCOM2 1 171 PA06 FLEXCOM2_IO0 MOSI Signal
FLEXCOM2 1 173 PA07 FLEXCOM2_IO1 MISO Signal
FLEXCOM2 1 167 PA08 FLEXCOM2_IO2 SPCK Signal
FLEXCOM2 1 172 PA09 FLEXCOM2_IO3 NPCS0 Signal
FLEXCOM2 1 168 PA10 FLEXCOM2_IO4 NPCS1 Signal
FLEXCOM2 2 127 PD26 FLEXCOM2_IO0 MOSI Signal
FLEXCOM2 2 123 PD27 FLEXCOM2_IO1 MISO Signal
FLEXCOM2 2 124 PD28 FLEXCOM2_IO2 SPCK Signal
FLEXCOM2 2 131 PD29 FLEXCOM2_IO3 NPCS0 Signal
FLEXCOM2 2 130 PD30 FLEXCOM2_IO4 NPCS1 Signal
FLEXCOM3 2 56 PC18 FLEXCOM3_IO2 SPCK Signal
FLEXCOM3 2 70 PC19 FLEXCOM3_IO1 MISO Signal
FLEXCOM3 2 58 PC20 FLEXCOM3_IO0 MOSI Signal
FLEXCOM3 2 63 PC21 FLEXCOM3_IO3 NPCS0 Signal
FLEXCOM3 2 65 PC22 FLEXCOM3_IO4 NPCS1 Signal
FLEXCOM4 1 39 PC28 FLEXCOM4_IO0 MOSI Signal
FLEXCOM4 1 38 PC29 FLEXCOM4_IO1 MISO Signal
FLEXCOM4 1 34 PC30 FLEXCOM4_IO2 SPCK Signal
FLEXCOM4 1 36 PC31 FLEXCOM4_IO3 NPCS0 Signal
FLEXCOM4 1 33 PD00 FLEXCOM4_IO4 NPCS1 Signal
FLEXCOM4 2 119 PD12 FLEXCOM4_IO0 MOSI Signal
FLEXCOM4 2 116 PD13 FLEXCOM4_IO1 MISO Signal
FLEXCOM4 2 117 PD14 FLEXCOM4_IO2 SPCK Signal
FLEXCOM4 2 114 PD15 FLEXCOM4_IO3 NPCS0 Signal
FLEXCOM4 2 115 PD16 FLEXCOM4_IO4 NPCS1 Signal