2019-06-14 08:21 AM
If the PLL3 is selected as I2C peripheral source clock, the Bits RCC_D2CCIP2R_I2C123SEL are not initialized correctly.
In function HAL_RCCEx_PeriphCLKConfig() the PLL3 R Divider gets updated but the clock selection is not set to "1". In my opinion, this should be fixed as written below:
original code:
/*------------------------------ I2C1/2/3 Configuration ------------------------*/
if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2C123) == RCC_PERIPHCLK_I2C123)
{
/* Check the parameters */
assert_param(IS_RCC_I2C123CLKSOURCE(PeriphClkInit->I2c123ClockSelection));
if ((PeriphClkInit->I2c123ClockSelection )== RCC_I2C123CLKSOURCE_PLL3 )
{
if(RCCEx_PLL3_Config(&(PeriphClkInit->PLL3),DIVIDER_R_UPDATE)!= HAL_OK)
{
status = HAL_ERROR;
}
}
else
{
__HAL_RCC_I2C123_CONFIG(PeriphClkInit->I2c123ClockSelection);
}
}
Fixed code:
/*------------------------------ I2C1/2/3 Configuration ------------------------*/
if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2C123) == RCC_PERIPHCLK_I2C123)
{
/* Check the parameters */
assert_param(IS_RCC_I2C123CLKSOURCE(PeriphClkInit->I2c123ClockSelection));
if ((PeriphClkInit->I2c123ClockSelection )== RCC_I2C123CLKSOURCE_PLL3 )
{
if(RCCEx_PLL3_Config(&(PeriphClkInit->PLL3),DIVIDER_R_UPDATE)!= HAL_OK)
{
status = HAL_ERROR;
}
}
__HAL_RCC_I2C123_CONFIG(PeriphClkInit->I2c123ClockSelection);
}
I use the STM32Cube_FW_H7_V1.4.0 HAL