
chipKIT™ MX3 Board Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page
11
of
24
7
Serial Peripheral Interface (SPI)
SPI is a four wire synchronous serial interface and devices can operate as either an SPI master device or as an SPI
slave device. The four SPI signals are generally called Slave Select (SS), Master Out Slave In (MOSI), Master In Slave
Out (MISO), and Serial Clock (SCK). The master device generates SS and SCK, and the slave device receives SS and
SCK. The SS signal is used to enable the slave device, and this signal is only significant for slave devices. A master
device can use any general purpose I/O pin to generate SS to enable the slave.
The PIC32 microcontroller labels the SPI signals as: Slave Select (SS), Serial Data Out (SDO), Serial Data In (SDI), and
Serial Clock (SCK). When the PIC32 microcontroller is enabled as a master device SDO serves the purpose of MOSI
and SDI serves the purpose of MISO. When the PIC32 microcontroller is operating as an SPI slave device, SDI serves
the purpose of MOSI and SDO serves the purpose of MISO.
The PIC32 microcontroller provides two Serial Peripheral Interfaces, SPI1 and SPI2. SPI1 is accessed via Pmod
connector JB and SPI2 is accessed via Pmod connector JE.
RD9
JB-01 (used for SS output)
SDO1
JB-02
SDI1
JB-03
SCK1
JB-04
SS2 JE-01
MOSI
JE-02
MISO
JE-03
SCK2
JE-04
SPI1 is only laid out to support use as an SPI master. To use SPI1 as a slave device, it is necessary to use external
wiring to connect the signals appropriately. When using SPI1 as a slave device, the SS1 signal is obtained from
Pmod connector JD, pin 1 (JD-01).
SPI2 is laid out on the board for use either as an SPI master or as an SPI slave device. Jumpers JP6 & JP8 are used to
select between master and slave. These jumpers switch the microcontroller signals SDO2 and SDI2 between the SPI
signals MOSI and MISO at the Pmod connector. Place the shorting blocks on these jumpers in the M position when
operating as an SPI master and in the S position when operating as an SPI slave device.
Detailed information about the operation of the SPI peripherals can be found in the PIC32 Family Reference
Manual, Section 23, Serial Peripheral Interface.
When using the chipKIT MX3 with the MPIDE and the chipKIT system, the SPI ports are accessed using either the
standard chipKIT SPI library or using the Digilent DSPI library.
The standard SPI library supports access to a single SPI port, SPI2. This is accessed using the
SPI
object.
The DSPI library supports access to both SPI ports. The
DSPI0
object class is used to create an object used to
access the default SPI port, SPI2, and the
DSPI1
object class is used to access SPI1.