The following describes the necessary
steps to enable and initialize the SPI.
TI recommends using the SPI driver in
the SimpleLink™ CC35xx Software Development Kit (SDK) when using the SPI.
- Ensure the power domain is
powered up properly.
- Enable the SPI module clock in CLKCTL by setting the CLKCTL.CLKCFG0[10] SPI0
bit.
- Configure the IO Mux module to
route the PICO, POCI, CS, and SCLK functionality from I/Os to the SPI module.
IOCFGn.PORTCFG must be written to the correct IDs.
For each of the frame formats, the SPI is configured using the following steps:
- Make sure that the SPI.CTL1[0] ENABLE bit is cleared before making any
configuration changes
- Configure the clock pre-scaler divisor by writing to the SPI.CLKCFG0[2:0] PRESC
and SPI.CLKCFG1[9:0] SCR bit fields
- Write the SPI.CTL0 register with the following configuration:
- Desired clock phase and polarity, if using Motorola™ SPI mode (SPH and
SPO)
- The protocol mode: Motorola SPI (4-wire or 3-wire) , TI SSF, MICROWIRE
(FRF)
- The data size (DSS)
- Select whether the SPI is a controller or peripheral:
- For controller operations, SPI.CTL1[2] MS is 1
- For peripheral mode (output enabled), SPI.CTL1[2] MS bit is 0
- For peripheral mode (output disabled), clear the SPI.CTL1[2] MS bit to 0
and set the SPI.CTL1[3] POD bit to 1
- Optionally, configure the Host
DMA channel (see Chapter 11) and enable the Host DMA
options in the SPI.DMACR register
- Enable the SPI by setting the EN bit in the SPI.CTL1 register
As an example, assume that the SPI configuration is required to operate with the
following parameters:
- Controller operation
- Texas Instruments Synchronous SPI mode
- 1-Mbps bit rate
- 8 data bits
Assuming the system clock is 80 MHz, the
bit-rate calculation is shown in Equation 8
Equation 8.
Example: 1000000 bps = 80000000 Hz /
[(1+3) × (2 × (1 + 9))]
In this case, if PRESC = 0x3, SCR must
be 0x09.
The configuration sequence is:
- Verify that the EN bit in the SPI.CTL1 register is cleared
- Write the SPI.CLKCFG0 register
with a value of 0x00000003
- Write the SPI.CLKCFG1 register
with a value of 0x00000009
- Write the SPI.CTL0 register with a value of 0x00000047
- Write the SPI.CTL1 register with a value of 0x00000004
- The SPI is then enabled by setting the EN bit in the SPI.CTL1 register