ADuCM320 Hardware Reference Manual
UG-498
Rev. C | Page 125 of 196
t
1
t
2
t
3
1
CLOCK
CYCLE
NUMBER
SPI CLOCK
(CPOL = 0)
SPI CLOCK
(CPOL = 1)
MOSI
(FROM
MASTER)
MISO
(FROM
SLAVE)
CS
2
3
4
5
6
7
8
XX
6
5
4
3
2
1
LSB
XX
6
5
4
3
2
1
LSB
XX
XX
MSB
MSB
1
1
17
6-
02
5
Figure 22. SPI Transfer Protocol CPHA = 0
t
1
t
2
t
3
1
CLOCK
CYCLE
NUMBER
SPI CLOCK
(CPOL = 0)
SPI CLOCK
(CPOL = 1)
MOSI
(FROM
MASTER)
MISO
(FROM
SLAVE)
2
3
4
5
6
7
8
XX
6
5
4
3
2
1
XX
6
5
4
3
2
1
XX
XX
MSB
MSB
LSB
LSB
CS
1
1
17
6-
0
26
Figure 23. SPI Transfer Protocol CPHA = 1
SPI Data Underrun and Overflow
If the transmit zeros enable bit, ZEN (SPIxCON[7]), is cleared, the last byte from the previous transmission is shifted out when a transfer
is initiated with no valid data in the FIFO. If ZEN is set to 1, 0s are transmitted when a transfer is initiated with no valid data in the FIFO.
If the Rx overflow overwrite enable bit, RXOF (SPIxCON[8]), is set, the valid data in the Rx FIFO is overwritten by the new serial byte
received if there is no space left in the FIFO. If RXOF is cleared, the new serial byte received is discarded if there is no space left in the FIFO.
When the RXOF is set, the contents of the SPI Rx FIFO are undefined and its contents should be discarded by user code.
Full Duplex Operation
Simultaneous reads/writes are supported on the SPI.
When implementing full duplex transfers in master mode, use the following procedure:
1.
Initiate a transfer sequence via a transmit on the MOSI pin. Set SPIxCON[6] = 1. If interrupts are enabled, interrupts are triggered
when a transmit interrupt occurs but not when a byte is received.
2.
If you are using interrupts, the SPI Tx interrupt indicated by SPIxSTA[5] or the Tx FIFO underrun interrupt (SPIxSTA[4]) is asserted
approximately 3 × SPICLK to 4 × SPICLK periods into the transfer of the first byte. Reload a byte into the Tx FIFO, if necessary, by
writing to SPIxTX.
3.
The first byte received via the MISO pin does not update the Rx FIFO status bits (SPIxSTA[10:8]) until 12 × SPICLK periods after CS
has gone low. Therefore, two transmit interrupts may occur before the first receive byte is ready to be handled.
4.
After the last transmit interrupt has occurred, it may be necessary to read two more bytes. It is recommended that SPIxSTA[10:8] are
polled outside of the SPI interrupt handler after the last transmit interrupt is handled.