The Timer object seems to want to be initialized either with a frequency or a prescaler/divisor, which then starts it running as a timer. So, for the QEI modes, isn't it necessary to init the counter without setting either a frequency or prescaler/divisor? But with a bare call to pyb.Timer(<n>), is the timer correctly initialized for encoder mode?
The following code prints zeroes, so the counter isn't moving for me:
Code: Select all
import pyb
from pyb import Timer
from time import sleep
tim = pyb.Timer(8)
c1 = pyb.Pin('Y1',pyb.Pin.IN)
c2 = pyb.Pin('Y2',pyb.Pin.IN)
tim.channel(1,Timer.ENC_AB)
while True:
print(tim.counter())
sleep(1)
Also tried with:
Code: Select all
tim.channel(1,Timer.ENC_AB, pin=c1)
-dave