2019-09-24 07:47 AM
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?
2019-09-24 08:40 AM
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?
2019-09-24 02:21 PM
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)
2019-09-26 12:05 PM
Closed: too much information. Opened new thread.