pyb.Timer unhappy with period > 0x7fffffff

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
dbc
Posts: 89
Joined: Fri Aug 28, 2015 11:02 pm
Location: Sunnyvale, CA

pyb.Timer unhappy with period > 0x7fffffff

Post by dbc » Sat Sep 05, 2015 9:35 pm

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

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: pyb.Timer unhappy with period > 0x7fffffff

Post by dhylands » Sat Sep 05, 2015 9:49 pm

I filed an issue: https://github.com/micropython/micropython/issues/1454 to discuss this further.

Post Reply