STM32L4xx_HAL_Driver  1.14.0

Functions

void TIM6_DAC_IRQHandler (void)
 This function handles TIM interrupt request. More...
 
HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
 This function configures the TIM6 as a time base source. The time source is configured to have 1ms time base with a dedicated Tick interrupt priority. More...
 
void HAL_SuspendTick (void)
 Suspend Tick increment. More...
 
void HAL_ResumeTick (void)
 Resume Tick increment. More...
 
void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef *htim)
 Period elapsed callback in non blocking mode. More...
 

Variables

TIM_HandleTypeDef TimHandle
 

Detailed Description

Function Documentation

◆ HAL_InitTick()

HAL_StatusTypeDef HAL_InitTick ( uint32_t  TickPriority)

This function configures the TIM6 as a time base source. The time source is configured to have 1ms time base with a dedicated Tick interrupt priority.

Note
This function is called automatically at the beginning of program after reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
Parameters
TickPriorityTick interrupt priority.
Return values
HALstatus

Definition at line 70 of file stm32l4xx_hal_timebase_tim_template.c.

71 {
72  RCC_ClkInitTypeDef clkconfig;
73  uint32_t uwTimclock, uwAPB1Prescaler = 0U;
74  uint32_t uwPrescalerValue = 0U;
75  uint32_t pFLatency;
76 
77  /* Configure the TIM6 IRQ priority */
78  HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority, 0U);
79 
80  /* Enable the TIM6 global Interrupt */
81  HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
82 
83  /* Enable TIM6 clock */
84  __HAL_RCC_TIM6_CLK_ENABLE();
85 
86  /* Get clock configuration */
87  HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
88 
89  /* Get APB1 prescaler */
90  uwAPB1Prescaler = clkconfig.APB1CLKDivider;
91 
92  /* Compute TIM6 clock */
93  if (uwAPB1Prescaler == RCC_HCLK_DIV1)
94  {
95  uwTimclock = HAL_RCC_GetPCLK1Freq();
96  }
97  else
98  {
99  uwTimclock = 2*HAL_RCC_GetPCLK1Freq();
100  }
101 
102  /* Compute the prescaler value to have TIM6 counter clock equal to 1MHz */
103  uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
104 
105  /* Initialize TIM6 */
106  TimHandle.Instance = TIM6;
107 
108  /* Initialize TIMx peripheral as follow:
109  + Period = [(TIM6CLK/1000) - 1]. to have a (1/1000) s time base.
110  + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
111  + ClockDivision = 0
112  + Counter direction = Up
113  */
114  TimHandle.Init.Period = (1000000U / 1000U) - 1U;
115  TimHandle.Init.Prescaler = uwPrescalerValue;
116  TimHandle.Init.ClockDivision = 0;
117  TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
118  TimHandle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
120  {
121  /* Start the TIM time Base generation in interrupt mode */
123  }
124 
125  /* Return function status */
126  return HAL_ERROR;
127 }
HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)
Starts the TIM Base generation in interrupt mode.
HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim)
Initializes the TIM Time base Unit according to the specified parameters in the TIM_HandleTypeDef and...
void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency)
Configure the RCC_ClkInitStruct according to the internal RCC configuration registers.
return HAL_OK
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
Enable a device specific interrupt in the NVIC interrupt controller.
RCC System, AHB and APB busses clock configuration structure definition.
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
Set the priority of an interrupt.
TIM_HandleTypeDef TimHandle
uint32_t HAL_RCC_GetPCLK1Freq(void)
Return the PCLK1 frequency.

◆ HAL_ResumeTick()

void HAL_ResumeTick ( void  )

Resume Tick increment.

Note
Enable the tick increment by enabling TIM6 update interrupt.
Parameters
None
Return values
None

Definition at line 147 of file stm32l4xx_hal_timebase_tim_template.c.

148 {
149  /* Enable TIM6 update interrupt */
150  __HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
151 }
TIM_HandleTypeDef TimHandle

◆ HAL_SuspendTick()

void HAL_SuspendTick ( void  )

Suspend Tick increment.

Note
Disable the tick increment by disabling TIM6 update interrupt.
Parameters
None
Return values
None

Definition at line 135 of file stm32l4xx_hal_timebase_tim_template.c.

136 {
137  /* Disable TIM6 update interrupt */
138  __HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
139 }
TIM_HandleTypeDef TimHandle

◆ HAL_TIM_PeriodElapsedCallback()

void HAL_TIM_PeriodElapsedCallback ( TIM_HandleTypeDef htim)

Period elapsed callback in non blocking mode.

Note
This function is called when TIM6 interrupt took place, inside HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment a global variable "uwTick" used as application time base.
Parameters
htim: TIM handle
Return values
None

Definition at line 161 of file stm32l4xx_hal_timebase_tim_template.c.

162 {
163  HAL_IncTick();
164 }
void HAL_IncTick(void)
This function is called to increment a global variable "uwTick" used as application time base...

◆ TIM6_DAC_IRQHandler()

void TIM6_DAC_IRQHandler ( void  )

This function handles TIM interrupt request.

Parameters
None
Return values
None

Definition at line 171 of file stm32l4xx_hal_timebase_tim_template.c.

172 {
174 }
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
This function handles TIM interrupts requests.
TIM_HandleTypeDef TimHandle

Variable Documentation

◆ TimHandle

TIM_HandleTypeDef TimHandle

Definition at line 56 of file stm32l4xx_hal_timebase_tim_template.c.