cancel
Showing results for 
Search instead for 
Did you mean: 

The name of HAL_GetTickFreq() function and its description is misleading, or the function returns wrong value?

Lazac
Associate

From the function name of 'HAL_GetTickFreq()' function, I expect that it returns tick frequency in Hz.

But I experienced that it returns tick period in milliseconds. If tick frequency is 1000 Hz, then it returns 1, that value comes from HAL_TICK_FREQ_1KHZ macro.

'Period' and 'frequency' terms are not the same, but of course, they are closely related to each other. Period is expressed in a time unit, like seconds or milliseconds, while frequency is expressed in Hz.

The function's doxygen brief definition says ' "@brief Return tick frequency." - and this is displayed on help files. It should say "Return tick period". The "@retval tick period in Hz" doxygen definition should be also corrected to "tick period in millisecond".

The names and descriptions of the related macro values in stm32l1xx_hal.h file are also misleading:

#define HAL_TICK_FREQ_10HZ        100U

#define HAL_TICK_FREQ_100HZ       10U

#define HAL_TICK_FREQ_1KHZ        1U

#define HAL_TICK_FREQ_DEFAULT     HAL_TICK_FREQ_1KHZ

These values are periods in milliseconds, and not tick frequencies. So something like 'HAL_TICK_10HZ_TICK_PERIOD_MSEC' would be better.

  

0 REPLIES 0