Skip to main content
LHerm.1
Associate II
February 17, 2021
Solved

How to reset counter value ?

  • February 17, 2021
  • 6 replies
  • 13355 views

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 !

This topic has been closed for replies.
Best answer by Tesla DeLorean

TIM2->CNT = 0;

There's probably a macro, try grep

6 replies

Javier1
Principal
February 17, 2021

there is some info missing here. "counter" is ambiguous.

Are you reffering to the counter of a timer?

hit me up in https://www.linkedin.com/in/javiermuñoz/
LHerm.1
LHerm.1Author
Associate II
February 17, 2021

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

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
February 17, 2021

TIM2->CNT = 0;

There's probably a macro, try grep

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
LHerm.1
LHerm.1Author
Associate II
February 17, 2021

It works !

Thank very much

Andrew Neil
Super User
June 19, 2024
Message moved to new thread
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.