-
Notifications
You must be signed in to change notification settings - Fork 344
timer
Boris Lovosevic edited this page Jan 18, 2018
·
8 revisions
This class includes support for using ESP32 hardware timer peripheral
The ESP32 chip contains two hardware timer groups. Each group has two general-purpose hardware timers. They are all 64-bit generic timers based on 16-bit prescalers and 64-bit auto-reload-capable up / down counters.
Several timer types are available:
Type | Description |
---|---|
ONE_SHOT | When timer is started, it runs for defined time and stops. The given callback function is executed when thedefined time elapses. |
PERIODIC | Timer runs repeatedly until explicitly stopped. When defined time expires the given callback function is executed |
CHRONO | Used for measuring the elapsed time with us precision. Can be started, paused, resumed and stopped |
EXTBASE | Base timer for extended timers. Only timer 0 can be used for this type. |
EXTENDED | Up to 8 extended timers can be used if timer 0 is configured as EXTBASE type timer. That way total of 11 timers can be used. Extended timers can operate only as ONE_SHOT or PERIODIC timers. |
tm = machine.Timer(timer_no)
timer_no
argument is the timer number to be used for the timer.
It can be 0 - 3 for 4 hardware timers or 4 - 11 for extended timers.
If extended timer is selected, timer 0 mus already be configured as EXTBASE type timer.