User manual

Basys MX3™ Board Reference Manual
Copyright Digilent, Inc. All rights reserved.
Other product and company names mentioned may be trademarks of their respective owners.
Page 29 of 56
Please read the MMA8652FCR1 documentation for more details.
10.3 Shared Pins
The Accelerometer shares the I
2
C1 pins with other devices that can be connected using the interface connector
(detailed in the I
2
C Interface section).
11 Serial Peripheral Interface
Serial peripheral interface (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 MOSI, SS, and SCK. The
SS signal is used to enable the slave device. It is only necessary to use a dedicated _SS signal when using the
PIC32’s SPI controller in slave mode, because in master mode any general purpose I/O pin can be used to generate
SS.
The PIC32MX370F512L microcontroller provides two serial peripheral interfaces: SPI1 and SPI2 (see SPI1 and SPI2
sections). These hardware interfaces implement the MOSI, MISO, and SCK behavior and leave SS to be handled by
the user.
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.
Detailed information about the operation of the SPI peripherals can be found in the PIC32 Family Reference
Manual, Section Serial Peripheral Interface.
11.1 SPI1
SPI1 is used for the onboard Flash memory.
There is also a connector labeled SPI (J6) on the bottom that exposes the SPI1 signals. Assuming that another
digital output pin is used for slave select, SPI1 signals can be used in order to connect another slave SPI device
using this connector. Please read the Flash memory section for details about connecting to SPI1.
11.2 SPI2
It is possible to configure SPI2 to be accessed using the pins of PMOD A. The SPI2_SS, SPI2_SCK, and SPI2_SI pins
should be configured as digital output, while the SPI2_SO pin must be configured as digital input.
Note that RC1(SPI2_SI) and RC4 (SPI2_SO) need to be remapped to perform SDO2 and SDI2 functions. Also, note
that the naming of the signals is reversed, as SPI2_SI and SPI2_SO are named from slave perspective, while SDO2
and SDI2 are named from the microcontroller perspective.
PMODA pin
Function
PIC32 pin
Needed mapping for SPI2
JA1
SPI2_SS
RPC2/RC2
JA2
SPI2_SI
RPC1/RC1
RPC1R = 0x06; // SDO2 RC1
JA3
SPI2_SO
RPC4/CTED7/RC4
SDI2R = 0x0A; // SDI2 RC4