Serial Peripheral Interface (SPI) Driver Library for MPLAB® Harmony v2

The Serial Peripheral Interface (SPI) module is a full-duplex synchronous-serial interface useful for communicating with other peripherals or microcontrollers in Master/Slave relationships and it can transfer data over short distances at high speeds. The peripheral devices may be serial EEPROMs, shift registers, display drivers, analog-to-digital converters, etc. The SPI module is compatible with Motorola’s SPI and Sheltered Instruction Observation Protocol (SIOP) interfaces.

During data transfer, devices can work either in Master or in Slave mode. The source of synchronization is the system clock, which is generated by the Master. The SPI module allows one or more Slave devices to be connected to a single Master device via the same bus.

The SPI serial interface consists of four pins, which are further sub-divided into data and control lines:

Data Lines:

  • MOSI – Master Output, Slave Input
  • MISO – Master Input, Slave Output

Control Lines:

  • SCLK – Serial Clock
  • /SS – Slave Select (no addressing)
spi.png
Click image to enlarge.

The SPI module can be configured to operate using two, three, or four pins. In the 3-pin mode, the Slave Select line is not used. In the 2-pin mode, both the MOSI and /SS lines are not used.

Different types of SPIs are available on Microchip microcontrollers. Some have an internal buffer mechanism and some do not. The buffer depth varies across part families. The SPI driver abstracts out these differences and provides a unified model for data transfer across the different types of SPIs available.

Both transmitter and receiver provide a buffer in the driver which transmits and receives data to/from the hardware. The SPI driver provides a set of interfaces to perform the read and the write.

 Learn More

 
Harmony SPI Tutorial
Learn more >
 
Entire SPI Driver Interface
Learn more >
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.