2014-07-16 03:22 AM
In the old standard drivers, you could use TIM_GetCounter(TIM2) and TIM_SetCounter(TIM2, 0) to read or modify the timer counter values. Is there a similar thing within the HAL drivers? I can't seem to find any replacement functions for these. Should I just access the register directly? TIM2->CNT
#hal-diver #timers #stm32f42014-07-16 05:12 AM
Hi h.hammer,
You can use the following Macros available under stm32f4xx_hal_tim.h file in order to Set/Get the TIM Counter Register value:#define __HAL_TIM_SetCounter(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
#define __HAL_TIM_GetCounter(__HANDLE__) ((__HANDLE__)->Instance->CNT)
With regards.