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 />

23.3 SPI functional description<br />

23.3.1 General description<br />

The block diagram of the SPI is shown in Figure 207.<br />

Figure 207. SPI block diagram<br />

Address <strong>and</strong> data bus<br />

Read<br />

Rx buffer<br />

MOSI<br />

SPI_CR2<br />

MISO<br />

Shift register<br />

LSB first<br />

TXE RXNE<br />

IE IE<br />

SPI_SR<br />

ERR<br />

IE<br />

0<br />

0 SSOE<br />

TXDM<br />

AEN<br />

RXDM<br />

AEN<br />

Tx buffer<br />

BSY OVR MOD CRC<br />

ERR 0 0 TXE RXNE<br />

F<br />

Write<br />

SCK<br />

Baud rate generator<br />

BR[2:0]<br />

Communication<br />

control<br />

0<br />

1<br />

Master control logic<br />

LSB<br />

FIRST<br />

BIDI BIDI<br />

MODE OE<br />

SPE BR2 BR1 BR0 MSTR CPOL CPHA<br />

CRC<br />

EN<br />

SPI_CR1<br />

CRC<br />

Next<br />

DFF<br />

RX<br />

ONLY<br />

SSM<br />

SSI<br />

NSS<br />

ai14744<br />

Usually, the SPI is connected to external devices through 4 pins:<br />

● MISO: Master In / Slave Out data. This pin can be used to transmit data in slave mode<br />

<strong>and</strong> receive data in master mode.<br />

● MOSI: Master Out / Slave In data. This pin can be used to transmit data in master<br />

mode <strong>and</strong> receive data in slave mode.<br />

● SCK: Serial Clock output for SPI masters <strong>and</strong> input for SPI slaves.<br />

● NSS: Slave select. This is an optional pin to select master/ slave mode. This pin acts as<br />

a ‘chip select’ to let the SPI master communicate with slaves individually <strong>and</strong> to avoid<br />

contention on the data lines. Slave NSS inputs can be driven by st<strong>and</strong>ard I/O ports on<br />

the master Device. The NSS pin may also be used as an output if enabled (SSOE bit)<br />

<strong>and</strong> driven low if the SPI is in master configuration. In this manner, all NSS pins from<br />

devices connected to the Master NSS pin see a low level <strong>and</strong> become slaves when<br />

they are configured in NSS hardware mode.<br />

A basic example of interconnections between a single master <strong>and</strong> a single slave is<br />

illustrated in Figure 208.<br />

Doc ID 13902 Rev 9 589/995

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

Saved successfully!

Ooh no, something went wrong!