29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

RM0008<br />

Serial peripheral interface (SPI)<br />

DMA access is requested when the enable bit in the SPI_CR2 register is enabled. There are<br />

separate requests for the Tx buffer <strong>and</strong> the Rx buffer.<br />

DMA capability with CRC<br />

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

transmission <strong>and</strong> reception of the CRC bytes at the end of communication are done<br />

automatically.<br />

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

occurs during the transfer.<br />

23.3.8 Error flags<br />

Master mode fault (MODF)<br />

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

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

fault affects the SPI peripheral in the following ways:<br />

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

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

interface.<br />

● The MSTR bit is reset, 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 <strong>and</strong> MSTR bits can<br />

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

As a security, hardware does not allow the setting of the SPE <strong>and</strong> 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 <strong>and</strong> the slave<br />

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

When an overrun condition occurs:<br />

● OVR bit is set <strong>and</strong> 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 to 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 of the SPI_DR register followed by a read access to<br />

the SPI_SR register.<br />

Doc ID 13902 Rev 9 597/995

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

Saved successfully!

Ooh no, something went wrong!