STM32L4xx_HAL_Driver  1.14.0

Functions

__STATIC_INLINE void LL_InitTick (uint32_t HCLKFrequency, uint32_t Ticks)
 This function configures the Cortex-M SysTick source of the time base. More...
 
void LL_Init1msTick (uint32_t HCLKFrequency)
 This function configures the Cortex-M SysTick source to have 1ms time base. More...
 
void LL_mDelay (uint32_t Delay)
 This function provides accurate delay (in milliseconds) based on SysTick counter flag. More...
 

Detailed Description

Function Documentation

◆ LL_Init1msTick()

void LL_Init1msTick ( uint32_t  HCLKFrequency)

This function configures the Cortex-M SysTick source to have 1ms time base.

Note
When a RTOS is used, it is recommended to avoid changing the Systick configuration by calling this function, for a delay use rather osDelay RTOS service.
Parameters
HCLKFrequencyHCLK frequency in Hz
Note
HCLK frequency can be calculated thanks to RCC helper macro or function LL_RCC_GetSystemClocksFreq
Return values
None

Definition at line 170 of file stm32l4xx_ll_utils.c.

171 {
172  /* Use frequency provided in argument */
173  LL_InitTick(HCLKFrequency, 1000U);
174 }
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
This function configures the Cortex-M SysTick source of the time base.

◆ LL_InitTick()

__STATIC_INLINE void LL_InitTick ( uint32_t  HCLKFrequency,
uint32_t  Ticks 
)

This function configures the Cortex-M SysTick source of the time base.

Parameters
HCLKFrequencyHCLK frequency in Hz (can be calculated thanks to RCC helper macro)
Note
When a RTOS is used, it is recommended to avoid changing the SysTick configuration by calling this function, for a delay use rather osDelay RTOS service.
Parameters
TicksNumber of ticks
Return values
None

Definition at line 279 of file stm32l4xx_ll_utils.h.

280 {
281  /* Configure the SysTick to have interrupt in 1ms time base */
282  SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */
283  SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
284  SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
285  SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */
286 }

◆ LL_mDelay()

void LL_mDelay ( uint32_t  Delay)

This function provides accurate delay (in milliseconds) based on SysTick counter flag.

Note
When a RTOS is used, it is recommended to avoid using blocking delay and use rather osDelay service.
To respect 1ms timebase, user should call LL_Init1msTick function which will configure Systick to 1ms
Parameters
Delayspecifies the delay time length, in milliseconds.
Return values
None

Definition at line 186 of file stm32l4xx_ll_utils.c.

187 {
188  __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */
189  uint32_t tmpDelay = Delay;
190 
191  /* Add this code to indicate that local variable is not used */
192  ((void)tmp);
193 
194  /* Add a period to guaranty minimum wait */
195  if(tmpDelay < LL_MAX_DELAY)
196  {
197  tmpDelay++;
198  }
199 
200  while (tmpDelay != 0U)
201  {
202  if((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
203  {
204  tmpDelay--;
205  }
206  }
207 }