2020-11-06 9:25 AM
Hi
I noticed on my STM32G071.. that the "LL_mDelay(1000)" function did not produce a steady 1000ms delay if I vary the HCLK frequency (code generated by CubeIDE)...
I did not have this problem with other MCUs code generated, it worked out of the box (F103/F407).
Then I stumbled upon the "LL_Init1msTick(uint32_t HCLKFrequency)" function which seemed to have solved my problem.
But what is the proper (dynamic) way to get the HCLK frequency for the function?
I currently use this in my main.c:
/* USER CODE BEGIN SysInit */
LL_Init1msTick(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
/* USER CODE END SysInit */This seems to pass a valid HCLK to the function. But CubeIDE tells me a warning that:
../Core/Src/main.c: In function 'main':
../Core/Src/main.c:85:18: warning: implicit declaration of function 'RCC_GetHCLKClockFreq'; did you mean 'LL_RCC_GetCECClockFreq'? [-Wimplicit-function-declaration]
LL_Init1msTick(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
^~~~~~~~~~~~~~~~~~~~
LL_RCC_GetCECClockFreq
../Core/Src/main.c:85:39: warning: implicit declaration of function 'RCC_GetSystemClockFreq'; did you mean 'LL_RCC_GetSystemClocksFreq'? [-Wimplicit-function-declaration]
LL_Init1msTick(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
^~~~~~~~~~~~~~~~~~~~~~
LL_RCC_GetSystemClocksFreqWhats the problem here?
Solved! Go to Solution.
2020-11-06 9:48 AM
The proper LL way is to call LL_RCC_GetSystemClocksFreq and use the HCLK value it returns. RCC_GetHCLKClockFreq is a private function, for whatever reason.
You could also just put the function declaration for RCC_GetHCLKClockFreq in your header and use it directly, but using a private function is probably not the proper way.
2020-11-06 9:48 AM
The proper LL way is to call LL_RCC_GetSystemClocksFreq and use the HCLK value it returns. RCC_GetHCLKClockFreq is a private function, for whatever reason.
You could also just put the function declaration for RCC_GetHCLKClockFreq in your header and use it directly, but using a private function is probably not the proper way.
2020-11-06 9:51 AM
Thanks, already figured it out :)
LL_RCC_ClocksTypeDef RCC_CLOCKS;
LL_RCC_GetSystemClocksFreq(&RCC_CLOCKS);
LL_Init1msTick(RCC_CLOCKS.HCLK_Frequency);
2020-11-06 12:47 PM
A "private" functions, which are not private - not declared as static... There wouldn't be this misunderstanding if those "private" functions would actually be private. The HAL team's incompetence level is top notch!
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.