# 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.
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.