RM0033
In slave mode, the continuity of the communication is decided by the SPI master device. In
any case, even if the communication is continuous, the BSY flag goes low between each
transfer for a minimum duration of one SPI clock cycle (see
Figure 260. TXE/BSY behavior when transmitting (BIDIRMODE=0 and RXONLY=0)
Example with CPOL=1, CPHA=1
SCK
MOSI (out)
b0 b1 b2 b3 b4 b5 b6 b7
TXE flag
Tx buffer
(write to SPI_DR)
BSY flag
software writes 0xF1
software waits until TXE=1 but is
into SPI_DR
late to write 0xF2 into SPI_DR
25.3.6
CRC calculation
A CRC calculator has been implemented for communication reliability. Separate CRC
calculators are implemented for transmitted data and received data. The CRC is calculated
using a programmable polynomial serially on each bit. It is calculated on the sampling clock
edge defined by the CPHA and CPOL bits in the SPI_CR1 register.
Note:
This SPI offers two kinds of CRC calculation standard which depend directly on the data
frame format selected for the transmission and/or reception: 8-bit data (CR8) and 16-bit data
(CRC16).
CRC calculation is enabled by setting the CRCEN bit in the SPI_CR1 register. This action
resets the CRC registers (SPI_RXCRCR and SPI_TXCRCR). In full duplex or transmitter
only mode, when the transfers are managed by the software (CPU mode), it is necessary to
write the bit CRCNEXT immediately after the last data to be transferred is written to the
SPI_DR. At the end of this last data transfer, the SPI_TXCRCR value is transmitted.
In receive only mode and when the transfers are managed by software (CPU mode), it is
necessary to write the CRCNEXT bit after the second last data has been received. The CRC
is received just after the last data reception and the CRC check is then performed.
At the end of data and CRC transfers, the CRCERR flag in the SPI_SR register is set if
corruption occurs during the transfer.
If data are present in the TX buffer, the CRC value is transmitted only after the transmission
of the data byte. During CRC transmission, the CRC calculator is switched off and the
register value remains unchanged.
SPI communication using the CRC is possible through the following procedure:
in case of discontinuous transfers
DATA 1 = 0xF1
b0 b1 b2 b3 b4 b5 b6 b7
0xF1
software waits until TXE=1 but
is late to write 0xF3 into
RM0033 Rev 8
Serial peripheral interface (SPI)
D
A
T
A
2
=
0
x
F
2
0xF2
software waits
until TXE=1
SPI_DR
Figure
258).
D
A
T
A
3
=
0
x
F
3
b0 b1 b2 b3 b4 b5 b6 b7
0xF3
software waits until BSY=0
ai17348
701/1378
735
Need help?
Do you have a question about the STM32F205 series and is the answer not in the manual?
Questions and answers