2021-04-24 01:02 PM
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);
}
Solved! Go to Solution.
2021-08-04 05:57 AM
Hi @ClaudiaP ,
Good news :smiling_face_with_smiling_eyes: I am pleased to inform you that this issue is fixed in the latest STM32CubeMX version 6.3.0.
Now, LL_RCC_SetAPB2Prescaler is taking correctly LL_RCC_APB2_DIV_2.
Thanks for your contribution.
Khouloud.
2021-04-24 01:38 PM
Found out that there is a newer version for STM32CubeMX> 6.2.1. The issue is still there.
2021-04-26 04:46 AM
Hello @ClaudiaP ,
First let me welcome you to the STM32 Community :smiling_face_with_smiling_eyes:
Thanks for your feedback and for raising this issue. You're right LL_RCC_SetAPB2Prescaler should take LL_RCC_APB2_DIV_2 prescaler instead of LL_RCC_APB1_DIV_2.
This will be reported internally to be reviewed and fixed. I'll surely keep you posted with updates.
Sorry for any inconvenience that this may cause.
Thanks a lot for you contribution.
Khouloud.
2021-04-26 06:14 AM
Thanks for your prompt reply, Khouloud!
2021-08-04 05:57 AM
Hi @ClaudiaP ,
Good news :smiling_face_with_smiling_eyes: I am pleased to inform you that this issue is fixed in the latest STM32CubeMX version 6.3.0.
Now, LL_RCC_SetAPB2Prescaler is taking correctly LL_RCC_APB2_DIV_2.
Thanks for your contribution.
Khouloud.