STM32CubeMX, STM32F34R8 autogenerated project for TrueStudio. Prescaler for APB2 is setting the prescaler for APB1
Hello All,
I tried to generate a test project with STM32CubeMX version 6.1.2 for micro STM32F334R8. I setup my project to generate mostly LL libraries, when setting the clock configuration, HSI (8MHz RC) is enabled, AHB prescaler is /8, then APB2 prescaler is set to /2. My intention is to have Pclk2 set to 500KHz here.
When I generate the code from STM32CubeMX with these settings, the below SystemClock_Config function is generated. Line 32 is setting again APB1 prescaler, instead of APB2.
Is it a known bug? I have no problem in updating the generated code, but everytime I regenerate the code, I would have to update this line of code. It would be nice also that other people do not have to spend some time trying to debug this.
Is there a more recent version or should I do something different with my STM32CubeMX?
Thanks,
void SystemClock_Config(void)
{
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0)
{
}
LL_RCC_HSI_Enable();
/* Wait till HSI is ready */
while(LL_RCC_HSI_IsReady() != 1)
{
}
LL_RCC_HSI_SetCalibTrimming(16);
LL_RCC_LSI_Enable();
/* Wait till LSI is ready */
while(LL_RCC_LSI_IsReady() != 1)
{
}
LL_PWR_EnableBkUpAccess();
if(LL_RCC_GetRTCClockSource() != LL_RCC_RTC_CLKSOURCE_LSI)
{
LL_RCC_ForceBackupDomainReset();
LL_RCC_ReleaseBackupDomainReset();
LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSI);
}
LL_RCC_EnableRTC();
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_8);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB1_DIV_2);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
/* Wait till System clock is ready */
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
{
}
LL_Init1msTick(1000000);
LL_SetSystemCoreClock(1000000);
}