Ahaaa...
I had utterly wrong notion of all counters having the same fixed maximum value, ticking at some internal maximum frequency, and wrapping to zero when the max value is reached.
I like this notion of having my own, per instance, counter's max value and wrapping to zero when triggered, more.
The discrepancy in values observed is due to the fact that I typed those lines in the REPL, so by the time I assigned callback function interrupt is already pending and my function is called immediately. (slight gotcha to keep in mind)
After a soft reboot I went on trying to set callback before initializing timer, and come with this little oddity:
Code: Select all
PYB: sync filesystems
PYB: soft reboot
Micro Python v1.3.9-6-g2f8c409-dirty on 2015-01-26; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import pyb
>>> tim = pyb.Timer(4)
>>> tim.deinit()
>>> tim.callback(lambda t: print(t.counter()))
>>> 0
0
0
0
0
0
0