Page 1 of 1

pyb.Timer unhappy with period > 0x7fffffff

Posted: Sat Sep 05, 2015 9:35 pm
by dbc
Trying to initialize a counter for QEI to get the full 32 bit range from it:

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
Seems to be unhappy with any number > 0x7fffffff.

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
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....

Re: pyb.Timer unhappy with period > 0x7fffffff

Posted: Sat Sep 05, 2015 9:49 pm
by dhylands
I filed an issue: https://github.com/micropython/micropython/issues/1454 to discuss this further.