2021-02-17 06:59 AM
Hello everyone, i would like to know the HAL function that allows to reset the value of a simple counter. I don't find the HAL function to reset my counter to 0 before a next counting.
So all i want to do is to count, read my counter value and reput it to zero for the next count.
Thank for your help !
Solved! Go to Solution.
2021-02-17 08:50 AM
TIM2->CNT = 0;
There's probably a macro, try grep
2021-02-17 08:41 AM
there is some info missing here. "counter" is ambiguous.
Are you reffering to the counter of a timer?
2021-02-17 08:50 AM
TIM2->CNT = 0;
There's probably a macro, try grep
2021-02-17 09:46 AM
Yes sorry, it's the value of my timer.
I use a Nucleo board (F401RE) and i would like to know if a function "HAL_TIM_......" to reset the value of the counter to zero exists or not.
But the solution proposed by "Tesla Delorean" just behind works very well : TIMx ->CNT = 0;
It's not the most proper solution but it works.
Best regards
2021-02-17 09:46 AM
It works !
Thank very much
2021-02-17 10:00 AM
/**
* @brief Set the TIM Counter Register value on runtime.
* @param __HANDLE__ TIM handle.
* @param __COUNTER__ specifies the Counter register new value.
* @retval None
*/
#define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
2024-06-19 07:46 AM
Message moved to new thread