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.

Serial peripheral interface (SPI)<br />

RM0008<br />

Figure 208. Single master/ single slave application<br />

Master<br />

Slave<br />

MSBit LSBit MSBit LSBit<br />

MISO MISO<br />

8-bit shift register<br />

8-bit shift register<br />

MOSI<br />

MOSI<br />

SPI clock<br />

generator<br />

SCK<br />

SCK<br />

NSS (1) NSS (1)<br />

V DD<br />

Not used if NSS is managed<br />

by software<br />

ai14745<br />

1. Here, the NSS pin is configured as an input.<br />

The MOSI pins are connected together <strong>and</strong> the MISO pins are connected together. In this<br />

way data is transferred serially between master <strong>and</strong> slave (most significant bit first).<br />

The communication is always initiated by the master. When the master device transmits<br />

data to a slave device via the MOSI pin, the slave device responds via the MISO pin. This<br />

implies full-duplex communication with both data out <strong>and</strong> data in synchronized with the<br />

same clock signal (which is provided by the master device via the SCK pin).<br />

Slave select (NSS) pin management<br />

There are two NSS modes:<br />

● Software NSS mode: this mode is enabled by setting the SSM bit in the SPI_CR1<br />

register (see Figure 209). In this mode, the external NSS pin is free for other<br />

application uses <strong>and</strong> the internal NSS signal level is driven by writing to the SSI bit in<br />

the SPI_CR1 register.<br />

● Hardware NSS mode: there are two cases:<br />

– NSS output is enabled: when the STM32F20xxx is operating as a Master <strong>and</strong> the<br />

NSS output is enabled through the SSOE bit in the SPI_CR2 register, the NSS pin<br />

is driven low <strong>and</strong> all the NSS pins of devices connected to the Master NSS pin see<br />

a low level <strong>and</strong> become slaves when they are configured in NSS hardware mode.<br />

When an SPI wants to broadcast a message, it has to pull NSS low to inform all<br />

others that there is now a master for the bus. If it fails to pull NSS low, this means<br />

that there is another master communicating, <strong>and</strong> a Hard Fault error occurs.<br />

– NSS output is disabled: the multimaster capability is allowed.<br />

Figure 209. Hardware/software slave select management<br />

SSM bit<br />

SSI bit<br />

NSS external pin<br />

1<br />

0<br />

NSS Internal<br />

ai14746<br />

590/995 Doc ID 13902 Rev 9

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

Saved successfully!

Ooh no, something went wrong!