
If clock phase (CPHA) is 0, bits are sampled on the leading clock edge and if CPHA is 1, bits are sampled on the trailing clock edge. A clock polarity (CPOL) of 0 means that the clock line idles low whereas a CPOL of 1 means the clock line idles high. These modes refer to how data is sampled with the clock pulses. The final peripheral’s SDO pin should be connected back to the controller. The SDO pin of the first peripheral should be connected to the SDI pin of the next peripheral in the chain. This is popular with things like LED drivers. Sometimes, you’ll come across parts that work in a daisy chain configuration. Note that CS lines are active low, meaning they idle high, and we individually pull them low when we want to talk to a device. You will need to dedicate one pin on your controller as a separate CS line for each peripheral you wish to communicate with. All of the lines are shared except for the CS line. SPI is a bus, which means you can use multiple peripheral devices for one controller.

Note that for STM32 parts, the shared data line for half-duplex communication should be connected to the SDO (or MOSI) pin.
Stm32 blue pill schematic clock serial#
The shared data line might be labeled as serial in/out (SI/O, SIO) or serial data in/out (SDIO). Sometimes, you will come across devices that only support half-duplex mode in order to save pins.


However, you will often run into transmission line issues (cross talk, spurious signals, weak signals, etc.) when working above a few MHz. Because SPI is a synchronous communication scheme (there is a separate clock line), it can theoretically work up to any speed. SPI is often used when a simple communication scheme is needed with faster speeds than what UART and I2C can provide.

As a result, it has become a de facto standard in the industry. It was never formalized into a standard, but other companies started using it soon after. Serial Peripheral Interface (SPI) was created by Motorola in the 1980s as a way to communicate between a microcontroller and various peripherals. Please refer to this tutorial if you need a refresher on using STM32CubeIDE and working with GPIO in HAL.
