SPRUJ79 November 2024 F29H850TU
SPI 3-wire mode allows for SPI communication over three pins instead of the normal four pins.
In controller mode, if the TRIWIRE bit is set, enabling 3-wire SPI mode, SPIPICOx becomes the bi-directional SPICOCIx (SPI controller out, controller in) pin, and SPIPOCIx is no longer used by the SPI. In peripheral mode, if the TRIWIRE bit is set, SPIPOCIx becomes the bi-directional SPIPIPOx (SPI peripheral in, peripheral out) pin, and SPIPICOx is no longer used by the SPI.
Table 41-4 indicates the pin function differences between 3-wire and 4-wire SPI mode for a controller and peripheral SPI.
4-wire SPI | 3-wire SPI (Controller) | 3-wire SPI (Peripheral) |
---|---|---|
SPICLKx | SPICLKx | SPICLKx |
SPISTEx | SPISTEx | SPISTEx |
SPIPICOx | SPICOCIx | Free |
SPIPOCIx | Free | SPIPIPOx |
Because in 3-wire mode, the receive and transmit paths within the SPI are connected, any data transmitted by the SPI module is also received. The application software must take care to perform a dummy read to clear the SPI data register of the additional received data.
The TALK bit plays an important role in 3-wire SPI mode. The bit must be set to transmit data and cleared prior to reading data. In controller mode, to initiate a read, the application software must write dummy data to the SPI data register (SPIDAT or SPIRXBUF) while the TALK bit is cleared (no data is transmitted out the SPICOCI pin) before reading from the data register.
Figure 41-9 and Figure 41-10 illustrate 3-wire controller and peripheral mode.
Table 41-5 indicates how data is received or transmitted in the various SPI modes while the TALK bit is set or cleared.
Pin Mode | SPIPRI[TRIWIRE] | SPICTL[TALK] | SPIPICO | SPIPOCI |
---|---|---|---|---|
Controller Mode | ||||
4-wire | 0 | X | TX | RX |
3-pin mode | 1 | 0 | RX | Disconnect from SPI |
1 | TX/RX | |||
Peripheral Mode | ||||
4-wire | 0 | X | RX | TX |
3-pin mode | 1 | 0 | Disconnect from SPI | RX |
1 | TX/RX |