Skip to main content
Nikita91
Lead II
January 30, 2020
Question

STM32CubeMX: generate buggy SystemClock_Config() ?

  • January 30, 2020
  • 1 reply
  • 699 views

Using STM32Cube MX 5.5.0 and STM32Cube FW_H7 V1.6.0 I observed two curious things

1) When I use LL drivers to generate a project, the function SystemClock_Config() contains:

/* Intermediate AHB prescaler 2 when target frequency clock is higher than 80 MHz */
 LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2);
 
 LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL1);
 LL_RCC_SetSysPrescaler(LL_RCC_SYSCLK_DIV_1);
 LL_RCC_SetAHBPrescaler(LL_RCC_AHB_DIV_2);
 LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
 LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2);
 LL_RCC_SetAPB3Prescaler(LL_RCC_APB3_DIV_2);
 LL_RCC_SetAPB4Prescaler(LL_RCC_APB4_DIV_2);
 
 LL_Init1msTick(400000000);
 
 LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
 LL_SetSystemCoreClock(200000000);

The line 2 contain the constant LL_RCC_SYSCLK_DIV_2 which is not related to register RCC->D1CFGR. The value should be LL_RCC_AHB_DIV_2, as in line 6.

This hang randomly the MCU. It kept me busy for a while.

2) Is about system core clock frequency. The line 12 use 400 MHz, but line 15 use 200 MHz. In addition the function SystemCoreClockUpdate() sets SystemCoreClock to 400MHz.

Is there an inconsistency?

Best regards

This topic has been closed for replies.

1 reply

Nesrine.JLASSI
Visitor II
February 18, 2020

Hello @Nikita91​ ,

Thanks for the feedback,

It will be fixed next CubeMX version.

Regards,

Nesrine