[Microbit-Python] set_analog_period

Jim Mussared jim at groklearning.com
Tue Dec 12 17:19:46 EST 2017


Hi Brin,

Yes, 1000 ms is the maximum -- see
https://github.com/bbcmicrobit/micropython/blob/master/source/lib/pwm.c#L182

The PWM events internally use 16-bit tick counters -- each tick is 16
microseconds, so that means that 2^20 microseconds would be the
maximum it could support (but also rounded to 1e6).

I don't know if there's any particular reason these have to be 16-bit
counters other than to save RAM.

Jim


On 13 December 2017 at 04:16, Brin Cooke <brincooke at brincooke.plus.com> wrote:
> I cannot make set_analog_period accept a value >1000. The response is ‘Value Error invalid period’. The documentation I’ve seen specifies a minimum of 1 but no maximum. Can anyone explain please?
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit


More information about the Microbit mailing list