AnsweredAssumed Answered

CubeMX 4.23.0 PPLI2S Configuration Issue for Stm32f7xx

Question asked by Sebastian Herber on Nov 24, 2017

There is an issue with the PLLI2S initialization in generated Code from CubeMx 4.23.0. It is skipped under certain conditions detailed below.


The clock network given in the picture is initialized with the following struct field in SystemClock_Config():



The PeriphClkInitStruct is then passed to HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef  *PeriphClkInit) in stm32f7xx_hal_rcc_ex.c. This function checks each bit of the bitfield and initializes the corresponding clock if necessary. However, the bit for PLLI2S is not checked properly. Here is the faulty code:


  /*-------------------------------------- PLLI2S Configuration ---------------------------------*/
  /* PLLI2S is configured when a peripheral will use it as source clock : SAI1, SAI2, I2S or SPDIF-RX */
  if((plli2sused == 1) || (PeriphClkInit->PeriphClockSelection == RCC_PERIPHCLK_PLLI2S))


In this case, plli2sused is 0, but the bitfield contains several 1s, therefore the test evaluates to false. A correct implementation would be:

f((plli2sused == 1) || ((PeriphClkInit->PeriphClockSelection & RCC_PERIPHCLK_PLLI2S)  == RCC_PERIPHCLK_PLLI2S))