Code: Select all
import time
import machine
from pyb import LED, Timer, UART, ADC, Pin
pin_a = pyb.Pin("A1", pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF1_TIM2)
pin_b = pyb.Pin("A15", pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF1_TIM2)
enc_timer = pyb.Timer(2, prescaler=1, period=100000)
enc_channel = enc_timer.channel(2, pyb.Timer.ENC_B)
enc_timer.counter(0)
while True:
time.sleep_ms(100)
print(enc_timer.counter())
Are there some additional configs for the timer settings to increase the counts on GPIO change?