SPI Peripheral Library for MPLAB® Harmony v2

This library allows you to control various Serial Peripheral Interface (SPI) functionality, including:

  • Data Transfer Functions
  • Transmitter Functions
  • Receiver Functions
  • Framed Mode Functions
  • Audio Mode Functions

The Serial Peripheral Interface library (SPI-PLIB) controls the SPI communications by accessing the PIC32's SPI Special Function Registers (SFRs). These registers are accessed using the PLIB functions. You do not need to know an SFR name or the specific SFR bit-field when calling an SPI-PLIB function. You have to identify the specific function to be performed on that timer.

Example SPI Library Functions

Mode Control

Function Name Description
PLIB_SPI_Enable (SPI_ID_2) Turns on the SPI Module
PLIB_SPI_Disable (SPI_ID_1) Disables the SPI Module
PLIB_SPI_MasterEnable (SPI_ID_3) Puts an SPI module in Master Mode
PLIB_SPI_SlaveEnable (SPI_ID_1) Puts an SPI Module in Slave Mode.

Reading and Writing Data

Function Name Description
PLIB_SPI_BufferAddressGet (SPI_ID_1) Returns the address of the SPI module's transmit/receive buffer.
PLIB_SPI_BufferRead (SPI_ID_1) Returns the value in the SPI read buffer
PLIB_SPI_BufferWrite (SPI_ID_3, data) Writes the value - data - to the SPI write buffer

The PLIB parameter for specifying an SPI Model (SPI_ID_x) is defined by the enum SPI_NUMBER_OF_MODULES, in the header file for the PIC32 being used.

 Learn More

Harmony SPI Tutorial
Learn more >
Entire SPI PLIB 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.