blob: add8c2993770e4e131141ebcdf8341344ca9eaec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# 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()))
|