class Timer – control internal timers

Note

Memory can’t be allocated inside irq handlers (an interrupt) and so exceptions raised within a handler don’t give much information. See micropython.alloc_emergency_exception_buf() for how to get around this limitation.

Constructors

class machine.Timer(id, ...)

Methods

Timer.deinit()

Deinitialises the timer. Disables all channels and associated IRQs. Stops the timer, and disables the timer peripheral.

class TimerChannel — setup a channel for a timer

Timer channels are used to generate/capture a signal using a timer.

TimerChannel objects are created using the Timer.channel() method.

Methods

Constants

Timer.ONE_SHOT
Timer.PERIODIC
Timer.PWM

Selects the timer operating mode.

Timer.A
Timer.B

Selects the timer channel. Must be ORed (Timer.A | Timer.B) when using a 32-bit timer.

Timer.POSITIVE
Timer.NEGATIVE

Timer channel polarity selection (only relevant in PWM mode).

Timer.TIMEOUT
Timer.MATCH

Timer channel IRQ triggers.