Serial interfaces
STM32W108CB, STM32W108HB
Doc ID 16252 Rev 3
conditions will clear the error indication: setting the appropriate SC_TX/RXDMARST bit in
the SCx_DMACTRL register, or loading the appropriate DMA buffer after it has unloaded.
To receive a character, you must transmit a character. If a long stream of receive characters
is expected, a long sequence of dummy transmit characters must be generated. To avoid
software or transmit DMA initiating these transfers and consuming unnecessary bandwidth,
the SPI serializer can be instructed to retransmit the last transmitted character or to transmit
a busy token (0xFF), which is determined by the SC_SPIRPT bit in the SCx_SPICFG
register. This functionality can only be enabled or disabled when the transmit FIFO is empty
and the transmit serializer is idle, indicated by a cleared SC_SPITXIDLE bit in the
SCx_SPISTAT register.
Every time an automatic character transmission starts, a transmit underrun is detected as
there is no data in transmit FIFO, and the INT_SCTXUND bit in the INT_SC2FLAG register
is set. After automatic character transmission is disabled, no more new characters are
received. The receive FIFO holds characters just received.
Note:
The Receive DMA complete event does not always mean the receive FIFO is empty.
The DMA Channels section describes how to configure and use the serial receive and
transmit DMA channels.
9.3.3
Interrupts
SPI master controller second level interrupts are generated by the following events:
●
Transmit FIFO empty and last character shifted out (depending on SCx_INTMODE,
either the 0 to 1 transition or the high level of SC_SPITXIDLE)
●
Transmit FIFO changed from full to not full (depending on SCx_INTMODE, either the 0
to 1 transition or the high level of SC_SPITXFREE)
●
Receive FIFO changed from empty to not empty (depending on SCx_INTMODE, either
the 0 to 1 transition or the high level of SC_SPIRXVAL)
●
Transmit DMA buffer A/B complete (1 to 0 transition of SC_TXACTA/B)
●
Receive DMA buffer A/B complete (1 to 0 transition of SC_RXACTA/B)
●
Received and lost character while receive FIFO was full (receive overrun error)
●
Transmitted character while transmit FIFO was empty (transmit underrun error)
To enable CPU interrupts, set the desired interrupt bits in the second level INT_SCxCFG
register, and enable the top level SCx interrupt in the NVIC by writing the INT_SCx bit in the
INT_CFGSET register.
9.4
SPI slave mode
Both SC1 and SC2 SPI controllers include a SPI slave controller with these features:
●
Full duplex operation
●
Up to 5 Mbps data transfer rate
●
Programmable clock polarity and clock phase
●
Selectable data shift direction (either LSB or MSB first)
●
Slave select input