pyb.Timer unhappy with period > 0x7fffffff
Posted: Sat Sep 05, 2015 9:35 pm
Trying to initialize a counter for QEI to get the full 32 bit range from it:
Seems to be unhappy with any number > 0x7fffffff.
Likewise unhappy with negative numbers: (not surprising....)
In practice in my current application it may not matter much.... given my wheel diameter, I suspect the batteries will be flat before the robot has driven 2,000 kilometers, so a 31 bit counter will do....
Code: Select all
>>> tim=pyb.Timer(2,prescaler=0,period=0xffffffff)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word
Likewise unhappy with negative numbers: (not surprising....)
Code: Select all
>>> tim=pyb.Timer(2,prescaler=0,period=-1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must specify either freq, or prescaler and period