Skip to main content
Explorer
January 6, 2025
Solved

Generate 2MHz SAI Clock for PDM Microphone Using STM32G473VET6

  • January 6, 2025
  • 4 replies
  • 862 views

Dear ST Community member,

I hope you all are doing well.

We are using STM32G473VET6 and IMP34DT05TR for Audio acquisition. The PDM Microphone needs a 2 MHz clock signal to operate properly. However, we are getting an error after configuring PLLQ at 2 MHz for SAI. Please let us know how to fix it. Thanks!

IOT_Dev_0-1736142424955.png

 

best regards,

Neeraj

 

 

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    This will not work with your settings:

    • You have set the divider for PLLM to /16, which results in only 1.5MHz at 24MHz. However, CubeMX points out that PLLM must be between 2.66-16MHz.
    • You have set the factor for PLL *N to x8, which results in 12MHz for you, but must be between 96-344MHz.
    • You have set the divider PLL /Q to /6, which would generate your desired 2MHz (that you think you have to create) from 12MHz, but here too CubeMX points out that PLLQ must be between 8-170MHz. However, the generated SAI frequency is not the one that is output at the clock pin, but the one that clocks as sai_x_ker_ck the SAI block.

    If you solve the clock configuration problem in STM32CubeMX, this results in a PLLQ of 24MHz (PLLM=/2, PLLQ=x8/4), which you can easily divide to 2MHz with the MCKDIV contained in the SAI (RM0440, section 40.4.8). Your IOC contains a value of 11 for MCKDIV, which you only need to set to 12 at mentioned 24MHz.

    You should also take the opportunity to upgrade to the new version of STM32CubeMX.

    Regards
    /Peter

    4 replies

    Technical Moderator
    January 6, 2025

    Welcome @IOT_Dev, to the community!

    Please post your IOC so that people can try to understand it.

    Regards
    /Peter

    IOT_DevAuthor
    Explorer
    January 6, 2025

    Hi Peter,

    Thanks for your response.

    Please find the attached IOC.

    best regards

    Neeraj

    Technical Moderator
    January 6, 2025

    This will not work with your settings:

    • You have set the divider for PLLM to /16, which results in only 1.5MHz at 24MHz. However, CubeMX points out that PLLM must be between 2.66-16MHz.
    • You have set the factor for PLL *N to x8, which results in 12MHz for you, but must be between 96-344MHz.
    • You have set the divider PLL /Q to /6, which would generate your desired 2MHz (that you think you have to create) from 12MHz, but here too CubeMX points out that PLLQ must be between 8-170MHz. However, the generated SAI frequency is not the one that is output at the clock pin, but the one that clocks as sai_x_ker_ck the SAI block.

    If you solve the clock configuration problem in STM32CubeMX, this results in a PLLQ of 24MHz (PLLM=/2, PLLQ=x8/4), which you can easily divide to 2MHz with the MCKDIV contained in the SAI (RM0440, section 40.4.8). Your IOC contains a value of 11 for MCKDIV, which you only need to set to 12 at mentioned 24MHz.

    You should also take the opportunity to upgrade to the new version of STM32CubeMX.

    Regards
    /Peter

    IOT_DevAuthor
    Explorer
    January 6, 2025

    Hi Peter,

    Thanks for your reply.

    Is the parameter setting correct for 2 microphones in stereo mode?

    regards,

    Neeraj