STM32Cube  Version 2.0
Create Projects for STM32F0 Series with STM32Cube HAL and STM32CubeMX
 All Files Pages
CMSIS-Driver SPI Setup

The CMSIS-Driver SPI requires:

  • Setup of SPIx input clock
  • Setup of SPIx in Full-Duplex Master/Slave mode with optional DMA for Rx and Tx transfers

Valid settings for various evaluation boards are listed in the table below:

Peripheral Resource STM32091C-EVAL STM32072B-EVAL
SPI Peripheral SPI1 SPI1
SPI Mode Full-Duplex Master Full-Duplex Master
MOSI Pin PE15 PE15
MISO Pin PE14 PE14
SCK Pin PE13 PB3

For different boards, refer to the hardware schematics to reflect correct setup values.

The STM32CubeMX configuration for STMicroelectronics STM32091C-EVAL Board with steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout tab

  1. Configure peripheral
    • Peripherals SPI1: Mode=Full-Duplex Master, Hardware NSS Signal=Disable
  2. Configure pins PE13 .. PE15 as SPI1 peripheral alternative pins
    • Click in chip diagram on pin PE13 and select SPI1_SCK
    • Click in chip diagram on pin PE14 and select SPI1_MISO
    • Click in chip diagram on pin PE15 and select SPI1_MOSI

Clock Configuration tab

  1. Configure APB1 Clock (maximum frequency is 48 MHz)
    • Setup "APB1 peripheral clocks (MHz)" to match application requirements

Configuration tab

  1. Under Connectivity open SPI1 Configuration:
    • Parameter Settings: not used
    • User Constants: not used
    • NVIC Settings: enable interrupts
      Interrupt Table Enabled Preemption Priority
      DMA1 channel 2 to 3 and DMA2 channel 1 .. ON 0
      SPI1 global interrupt ON 0
    • optional DMA Settings: setup DMA transfers for Rx and Tx (DMA is optional)
      Add - Select SPI1_RX: Stream=DMA1 Channel 2, Direction=Peripheral to Memory, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      . Data Width Byte Byte
      Add - Select SPI1_TX: Stream=DMA1 Channel 3, Direction=Memory to Peripheral, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      . Data Width Byte Byte
    • GPIO Settings: review settings
      Pin Name Signal on Pin GPIO output..GPIO mode GPIO Pull-up/Pull..Maximum out Fast Mode User Label
      PE13 SPI1_SCK n/a Alternate ..No pull-up and no..High n/a .
      PE14 SPI1_MISO n/a Alternate ..No pull-up and no..High n/a .
      PE15 SPI1_MOSI n/a Alternate ..No pull-up and no..High n/a .
      Click OK to close the SPI1 Configuration dialog