cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MXCube V5.3.0 is not generating SysTick code. SYSCLK and HCLK not updating.

DBroo.1
Associate III

I'm using the STM32G070CBTx​. The Cube Clock Configuration window is set up for HSI RC and PLLCLK. SYSCLK and HCLK are both set to 64MHz. The code generated by SystemClock_config() appears correct. But calls to HAL_RCC_GetHCLKFreq() and HAL_RCC_GetSysClockFreq() return 16MHz. What am I missing?

3 REPLIES 3
DBroo.1
Associate III

​The first time I run the debugger, the afformentioned calls return 16MHz. If I reset the debugger and run again, they return 64MHz. I saw the comments in the HAL Manual about calling these functions to update any changes to these clocks. Although I expected SystemClock_Config() would do this, I added calls to these functions well prior to their usage, but that did not solve the problem. What am I missing?

Second question, is it true that Cube does not generate the code necessary to init and start the SysTick Timer within SystemClock_Config() for this processor like it does for other processors?

DBroo.1
Associate III

​Update:

This all occurs when SystemClock_Config() tries to change the clock source to the PLL and set SystemCoreClock to 64Mhz.

The following statement inside HAL_InitTick() is not dividing SystemCoreClock by 1000, as it should be. It's dividing by 1. So later, in SysTick_Config(), argument ticks=64,000,000 which exceeds SysTick_LOAD_RELOAD_Msk, which ultimately results in the error. The compiler also thinks uwTickFreq = 3550975298. It should be 1. But that value in the following statement should result in a divide by 0, which doesn't happen. Is this a Cube issue or am I doing something wrong?

   if (HAL_SYSTICK_Config(SystemCoreClock / (1000U /uwTickFreq)) == 0U)

DBroo.1
Associate III

Closed: too much information. Opened new thread.​