09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>RM0090</strong> Serial peripheral interface (SPI)<br />

DMA capability with CRC<br />

When SPI communication is enabled with CRC communication and DMA mode, the<br />

transmission and reception of the CRC at the end of communication are automatic that is<br />

without using the bit CRCNEXT. After the CRC reception, the CRC must be read in the<br />

SPI_DR register to clear the RXNE flag.<br />

At the end of data and CRC transfers, the CRCERR flag in SPI_SR is set if corruption<br />

occurs during the transfer.<br />

27.3.10 Error flags<br />

Master mode fault (MODF)<br />

Master mode fault occurs when the master device has its NSS pin pulled low (in NSS<br />

hardware mode) or SSI bit low (in NSS software mode), this automatically sets the MODF<br />

bit. Master mode fault affects the SPI peripheral in the following ways:<br />

● The MODF bit is set and an SPI interrupt is generated if the ERRIE bit is set.<br />

● The SPE bit is cleared. This blocks all output from the device and disables the SPI<br />

interface.<br />

● The MSTR bit is cleared, thus forcing the device into slave mode.<br />

Use the following software sequence to clear the MODF bit:<br />

1. Make a read or write access to the SPI_SR register while the MODF bit is set.<br />

2. Then write to the SPI_CR1 register.<br />

To avoid any multiple slave conflicts in a system comprising several MCUs, the NSS pin<br />

must be pulled high during the MODF bit clearing sequence. The SPE and MSTR bits can<br />

be restored to their original state after this clearing sequence.<br />

As a security, hardware does not allow the setting of the SPE and MSTR bits while the<br />

MODF bit is set.<br />

In a slave device the MODF bit cannot be set. However, in a multimaster configuration, the<br />

device can be in slave mode with this MODF bit set. In this case, the MODF bit indicates that<br />

there might have been a multimaster conflict for system control. An interrupt routine can be<br />

used to recover cleanly from this state by performing a reset or returning to a default state.<br />

Overrun condition<br />

An overrun condition occurs when the master device has sent data bytes and the slave<br />

device has not cleared the RXNE bit resulting from the previous data byte transmitted.<br />

When an overrun condition occurs:<br />

● the OVR bit is set and an interrupt is generated if the ERRIE bit is set.<br />

In this case, the receiver buffer contents will not be updated with the newly received data<br />

from the master device. A read from the SPI_DR register returns this byte. All other<br />

subsequently transmitted bytes are lost.<br />

Clearing the OVR bit is done by a read from the SPI_DR register followed by a read access<br />

to the SPI_SR register.<br />

Doc ID 018909 Rev 3 814/1416

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!