Tim = Timer(2, prescaler=83, period=4) ,source clock is 84Mhz,not 84Hz

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

import time , micropython
from pyb import Pin, Timer, LED#'Timer' has no attribute 'PERIODIC'

blue_led  = LED(3)
def tick(timer):
    global Timeout_counter
    blue_led.toggle()
    print('-T2 out-')

tim = Timer(2, prescaler=83, period=4)#<----------------clock is 84Hz, right?
tim.callback(tick)
Timeout_counter=0
while (True):
    time.sleep_ms(1000)
    Timeout_counter+=1

now i find the docs in english,
https://docs.openmv.io/library/pyb.Timer.html#pyb-timer

**

Timers 2-7 and 12-14 have a clock source of 84 MHz.

**
not 84Hz. :sweat:
https://docs.singtown.com/micropython/zh/latest/openmvcam/library/pyb.Timer.html

i change my code to:

from pyb import Timer
from pyb import Pin, LED

tim = Timer(2, prescaler=84000000-1, period=2)
tim.counter() # get counter value
tim.callback(lambda t: LED(1).toggle())

timer clock =84MHz/(84000000)=1,so timer2 should be overlope 2seconds later since period=2.
but the led don’t blink. why?
now i know that the 84000000 is out of range 65535.

Hi, can you not use the PYB module: class Timer – control hardware timers — MicroPython 1.20 documentation

Use the machine module instead. It looks like the documentation for that is valid for the Cortex M4.

The pyb module will be phased out.

roger that .thank you.

tim = Timer(2, prescaler=(84000000-1), period=10)
tim.callback(lambda t: LED(1).toggle())
print(tim.freq())#450.938

if code change to tim = Timer(2, prescaler=(84000-1), period=1000), the out put is 12.9853
what is the formula for tim.freq?

Depends on the camera you have. If it’s the H7 then it should be 240 MHz.