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

The CMSIS-Driver SAI requires:

  • Setup of SAI Block A and block B (Master, Master with master clock output, Asynchronous slave, synchronous slave)

The example below uses correct settings for STM32F746G-Discovery:

  • SAI2 A: Master with Master Clock Out
  • SAI2 B: Synchronous Slave

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

The STM32CubeMX configuration steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout tab

  1. Configure SAI2 mode
    • Peripherals SAI2
      • SAI2_A: Mode=Master with Master Clock Out
      • SAI2_B: Mode=Synchronous Slave
  2. Configure SAI2_MCLK_A pin (is not the default pin):
    • Click in chip diagram on pin PI4 and select SAI2_MCLK_A.

Clock Configuration tab

  1. Configure SAI2 Clock.

Configuration tab

  1. Under Multimedia open SAI2 Configuration:
    • optional DMA Settings: setup DMA transfers for SAI2_A and SAI2_B (DMA is optional)
      Add - Select SAI2_A: Stream=DMA2 Stream 4, DMA Request Settings: not used
      Add - Select SAI2_B: Stream=DMA2 Stream 6, DMA Request Settings: not used
    • GPIO Settings: review settings, no changes required
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out User Label
      PG10 SAI2_SD_B Alternate No Pull-up/down Low .
      PI4 SAI2_MCLK_A Alternate No Pull-up/down Low .
      PI5 SAI2_SCK_A Alternate No Pull-up/down Low .
      PI6 SAI2_SD_A Alternate No Pull-up/down Low .
      PI7 SAI2_FS_A Alternate No Pull-up/down Low .
      - NVIC Settings: enable interrupts
      Interrupt Table Enable Preemption Priority Sub Priority
      SAI2 global interrupt ON 0 0
      DMA2 stream4 global interrupt ON 0 0
      DMA2 stream6 global interrupt ON 0 0
      - Parameter Settings: not used
    • User Constants: not used
    • Click OK to close the SAI2 Configuration dialog