Timer Counter not counting

I’m new to OpenMV and I’m just starting to get familiar with it. I modified the example Timer code.

# Timer Control Example
# This example shows how to use a timer for callbacks.

import time
from pyb import Pin, Timer

def tick(timer):                # we will receive the timer object when being called
    print(timer.counter())      # show current timer's counter value
tim = Timer(4, freq=1)      # create a timer object using timer 4 - trigger at 1Hz
tim.callback(tick)              # set the callback to our tick function

while (True):

The callback works fine but the printed value is always zero. What am I doing wrong?


Is this on the H7? It’s probably a bug in the HAL. Ibrahim can debug it.

It is an M4.

I tried changing the freq and prescaler and I can see it count down. I though default was count up. Is there any other documentation on how this counter works?

I’m very familiar with STM32FXXX counters - just not clear on how it is implemented through OpenMV.

Thanks for any help you can provide.

Um, it would be via how MicroPython implements these:

how to debug it on OpenMV H7 ? timer not working

Which timer? On which pin?