Skip to main content
Visitor II
February 17, 2021
Solved

How to reset counter value ?

  • February 17, 2021
  • 3 replies
  • 13261 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

    3 replies

    Graduate II
    February 17, 2021

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

    Are you reffering to the counter of a timer?

    LHerm.1Author
    Visitor 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

    Graduate II
    February 17, 2021

    TIM2->CNT = 0;

    There's probably a macro, try grep

    LHerm.1Author
    Visitor II
    February 17, 2021

    It works !

    Thank very much

    Super User
    June 19, 2024
    Message moved to new thread