mirror of
https://github.com/micropython/micropython.git
synced 2025-08-13 22:22:03 +02:00
There should be no change to these tests for existing PYBV1x and PYBD_SFx boards. Signed-off-by: Damien George <damien@micropython.org>
25 lines
481 B
Python
25 lines
481 B
Python
# check basic functionality of the timer class
|
|
|
|
import sys
|
|
from pyb import Timer
|
|
|
|
if "STM32WB" in sys.implementation._machine:
|
|
tim_id = 16
|
|
else:
|
|
tim_id = 4
|
|
|
|
tim = Timer(tim_id)
|
|
tim = Timer(tim_id, prescaler=100, period=200)
|
|
print(tim.prescaler())
|
|
print(tim.period())
|
|
tim.prescaler(300)
|
|
print(tim.prescaler())
|
|
tim.period(400)
|
|
print(tim.period())
|
|
|
|
# Setting and printing frequency
|
|
tim = Timer(2, freq=100)
|
|
print(tim.freq())
|
|
tim.freq(0.001)
|
|
print("{:.3f}".format(tim.freq()))
|