cancel
Showing results for 
Search instead for 
Did you mean: 

SAI: Won't stay enabled (H7 and WB)

DOCon.1
Senior

Hi - I'm having a real struggle with the SAI peripheral. I've tried on both H742, and WB55 module, and am running into the same problem.

I have the source set up in the clock config (Tried both PLL1 and PLL2, and using PLLSA1P on WB), and made sure I correctly configured and enabled the appropriate PLLs). Enabled the SAI peripheral, with what seemed like reasonable defaults in the SAI registers. Configured the SAI pins as AF6. (PE4, 5, 6 on H7) Anywhere you'd troubleshoot first?

Surface level problem: SAI SA_xDR reads 0. Deeper: Scope shows no signals on the SCK line. Most fundamental: The SAI_xCR1, SAIEN field shows 0, even if read immediately after setting it

Here's a selection of register readings from H742 after (attempting to) enabling SAI1:

  • SAI1 source (RCC_D2CCIP1R, SAI1SEL): 1 (PLL2P)
  • PLL2 ready (RCC_CR, PLL2RDY): 1 (Ready)
  • PLL2P enabled (RCC_PLLCFGR, DIVP2EN): 1 (Enabled)
  • SAI periph clock enabled (RCC_APB2ENR, SAI1EN): 1 (Enabled)
  • SAI1 mode(SAI_ACR1, MODE): 1 (Master receiver)
  • SAI1 enabled (SAI_ACR1, SAIEN): 0 (Not enabled)

Any ideas where to troubleshoot? The clearest way to solve this: What would block the SAI from enabling entirely? Of note, the other writes I do to the same reg (eg MODE above) work. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Amel NASRI
ST Employee

Hi @DOCon.1​ ,

Is your code generated with STM32CubeMX?

Did you tried to debug your code? For some peripherals, the enable bit shouldn't be set before completing some setup.

With debug, you can check which function call prevents SAIEN from being set.

You can also have a look to some examples provided in dedicated STM32Cube packages (depends on the exact product you selected):

  • STM32Cube_FW_H7\Projects\STM32H743I-EVAL\Examples\SAI
  • STM32Cube_FW_H7\Projects\STM32H735G-DK\Examples\SAI
  • STM32Cube_FW_WB\Projects\STM32WB5MM-DK\Examples\SAI

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Amel NASRI
ST Employee

Hi @DOCon.1​ ,

Is your code generated with STM32CubeMX?

Did you tried to debug your code? For some peripherals, the enable bit shouldn't be set before completing some setup.

With debug, you can check which function call prevents SAIEN from being set.

You can also have a look to some examples provided in dedicated STM32Cube packages (depends on the exact product you selected):

  • STM32Cube_FW_H7\Projects\STM32H743I-EVAL\Examples\SAI
  • STM32Cube_FW_H7\Projects\STM32H735G-DK\Examples\SAI
  • STM32Cube_FW_WB\Projects\STM32WB5MM-DK\Examples\SAI

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

DOCon.1
Senior

No. I'm making the reg writes in Rust. It turns out, this was caused by not properly offsetting the FRL bits by 1, leading to an odd-numbered value. (I was setting the frame length directcly, when the proper code is frame length - 1, as annotated by the register description) So, error on my part. Thank you.

And this led to SAIEN remaining zero after being set?

JW

DOCon.1
Senior

Correct.