Hi all
The MAXIMUM value is 6870947 (1:54:30.947). I tested and verified on uPython 1.9.4 ESP8266. >=6870948 does NOT work. (My source came from Lua:
https://nodemcu.readthedocs.io/en/maste ... mer-module. Lua Timer (tmr.interval) initialises in a similar way to uPython.)
I wanted a 12 hour timer (~42610000).
What I'd like to know and understand is what is limiting it.
By my reading (and I'm not a C coder), "period" is defined as a 32bit integer. That makes the decimal number approx 4.3G, somewhat larger than necessary.
https://github.com/micropython/micropyt ... dmachine.c
STATIC mp_obj_t esp_timer_init_helper(esp_timer_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum {
ARG_mode,
ARG_callback,
ARG_period,
ARG_tick_hz,
ARG_freq,
};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_mode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
{ MP_QSTR_callback, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_period, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0xffffffff} },
{ MP_QSTR_tick_hz, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1000} },
So, perhaps there's a hardware limit somewhere, but I couldn't find anything about it at Espressif or their forums. Hopefully someone knows the significance of this hard limit, and is willing to explain.
Looking at the MicroPython C code for the ESP32 Timers, looks like the Timer Periods are 64 bit integers:
https://github.com/micropython/micropyt ... ne_timer.c
typedef struct _machine_timer_obj_t {
mp_obj_base_t base;
mp_uint_t group;
mp_uint_t index;
mp_uint_t repeat;
// ESP32 timers are 64-bit
uint64_t period;
mp_obj_t callback;
intr_handle_t handle;
Has anyone discovered a hard limit to the Timer Period on the ESP32?
Peter