I\'m new to using HAL functions. The description of the function HAL_GetTick()
says that it \"provides a tick value in millisecond
Although the question was already answered, I think it would be helpful to see how HAL uses HAL_GetTick()
to count milliseconds. This can be seen in HAL's function HAL_Delay(uint32_t Delay)
.
Implementation of HAL_Delay(uint32_t Delay)
from stm32l0xx_hal.c
:
/**
* @brief This function provides minimum delay (in milliseconds) based
* on variable incremented.
* @note In the default implementation , SysTick timer is the source of time base.
* It is used to generate interrupts at regular time intervals where uwTick
* is incremented.
* @note This function is declared as __weak to be overwritten in case of other
* implementations in user file.
* @param Delay specifies the delay time length, in milliseconds.
* @retval None
*/
__weak void HAL_Delay(uint32_t Delay)
{
uint32_t tickstart = HAL_GetTick();
uint32_t wait = Delay;
/* Add a period to guaranty minimum wait */
if (wait < HAL_MAX_DELAY)
{
wait++;
}
while((HAL_GetTick() - tickstart) < wait)
{
}
}