Skip to main content
DBroo.1
Associate III
September 26, 2019
Solved

STM32G070CB: STM32CubeMX V5.3.0 with STM32Cube_FW_G0_V1.3.0 fails to configure SYSCLK above 16MHz via the PLL

  • September 26, 2019
  • 4 replies
  • 1048 views

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(), when argument ticks=64,000,000 which exceeds SysTick_LOAD_RELOAD_Msk of 0xFF'FFFF, a HAL_ERROR occurs.

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 either. Is this a Cube issue or am I doing something wrong?

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

This topic has been closed for replies.
Best answer by DBroo.1

​I found the problem. As mentioned above, uwTickFreq was incorrect. On the debugger with the Memory Window open, I noticed that clicking Reset did not reset uwTickFreq or any surrounding addresses. Note that I am porting code from an LPC844 to the ST part. So I went back to the new linker file. The old linker file did the following, although I am not sure why as I have not found any manual initialization code:

initialize manually { section .textrw };

initialize manually { section .textrw };

So, I replaced these lines with the usual:

initialize by copy { readwrite };

RAM is now being initialized and the problem has been resolved.

4 replies

DBroo.1
DBroo.1Author
Associate III
September 27, 2019

​Hey All, I could use some help with this. Something wrong with the post?

TDK
September 28, 2019

What clock setting are you trying to use? The question isnt super clear to me. Did you forget to include the statement you refer to in the first sentence?

"If you feel a post has answered your question, please click ""Accept as Solution""."
DBroo.1
DBroo.1Author
Associate III
September 30, 2019

​The clock in Cube is set up as follows: HSI, PLLM=1, PLLN=8, PLLR=2 resulting in SYSCLK =64MHz. The statement I am referring to is:

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

DBroo.1
DBroo.1AuthorBest answer
Associate III
October 1, 2019

​I found the problem. As mentioned above, uwTickFreq was incorrect. On the debugger with the Memory Window open, I noticed that clicking Reset did not reset uwTickFreq or any surrounding addresses. Note that I am porting code from an LPC844 to the ST part. So I went back to the new linker file. The old linker file did the following, although I am not sure why as I have not found any manual initialization code:

initialize manually { section .textrw };

initialize manually { section .textrw };

So, I replaced these lines with the usual:

initialize by copy { readwrite };

RAM is now being initialized and the problem has been resolved.