Page 1 of 1

Using PLL for I2S on STM32F411cEu6 Black Pill

Posted: Fri Jun 27, 2025 6:25 am
by seedx
Hi and sorry if my question is too trivial.

On the said board, I am have an issue when trying to use PLL for I2S clock souce. The program got stuck waiting for PLL lock in this block of code from the os/hal/ports/STM32/STM32F4xx/hal_lld.c file:

Code: Select all

...
#if STM32_ACTIVATE_PLLI2S
  /* PLLI2S activation.*/
  RCC->PLLI2SCFGR = STM32_PLLI2SR | STM32_PLLI2SN | STM32_PLLI2SP |
                    STM32_PLLI2SSRC | STM32_PLLI2SQ | STM32_PLLI2SM;
  RCC->CR |= RCC_CR_PLLI2SON;

  /* Waiting for PLL lock.*/
  while (!(RCC->CR & RCC_CR_PLLI2SRDY))
    ;
#endif /* STM32_ACTIVATE_PLLI2S */
...

My HAL driver settings is:

Code: Select all

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0
#define STM32_BKPRAM_ENABLE                 FALSE
#define STM32_HSI_ENABLED                   TRUE
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_CLOCK48_REQUIRED              TRUE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSE
#define STM32_PLLM_VALUE                    25
#define STM32_PLLN_VALUE                    192
#define STM32_PLLP_VALUE                    2
#define STM32_PLLQ_VALUE                    4
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE1                         STM32_PPRE1_DIV2
#define STM32_PPRE2                         STM32_PPRE2_DIV1
#define STM32_RTCSEL                        STM32_RTCSEL_LSI
#define STM32_RTCPRE_VALUE                  8
#define STM32_MCO1SEL                       STM32_MCO1SEL_HSI
#define STM32_MCO1PRE                       STM32_MCO1PRE_DIV1
#define STM32_MCO2SEL                       STM32_MCO2SEL_SYSCLK
#define STM32_MCO2PRE                       STM32_MCO2PRE_DIV5
#define STM32_I2SSRC                        STM32_I2SSRC_PLLI2S
#define STM32_PLLI2SM_VALUE                 25
#define STM32_PLLI2SN_VALUE                 192
#define STM32_PLLI2SR_VALUE                 2

Also, the HSE is defined

Code: Select all

#if !defined(STM32_HSECLK)
#define STM32_HSECLK                25000000U
#endif


Can someone please help. Iam using ChibiOS 21.11 Thanks.

Re: Using PLL for I2S on STM32F411cEu6 Black Pill

Posted: Fri Jun 27, 2025 7:27 am
by Giovanni
Hi,

PLLI2S uses exactly the same parameters of the other PLL, PLL activation code is also similar, this is strange. I don't have HW to test this currently.

Try looking at the CR and I2SCFGR registers just before activation and see if the values in there are as expected.

Giovanni

Re: Using PLL for I2S on STM32F411cEu6 Black Pill

Posted: Fri Jun 27, 2025 9:16 am
by seedx
Thank you for your guidance, Giovani. I will look at the registers.