Skip to content

New timer code for esp32c3 #51

@Eszartek

Description

@Eszartek

Since the new timer code in 7.0.7.10 now uses the Arduino libs for initialization and register setup, there are just two minor adjustments that need to be made for the esp32c3.

First, the RISCv esp32c3 only has 2 timers available versus the 4 timers in the Xtensa variants. Initialization of the second two timers results in a harmless error:

E (6611) timer_group: timer_init(273): HW TIMER NUM ERROR
E (6615) timer_group: timer_init(273): HW TIMER NUM ERROR

This could be remedied with something like

0 0 timer_init_null
0 1 timer_init_null
# !defined(CONFIG_IDF_TARGET_ESP32C3) 
1 0 timer_init_null
1 1 timer_init_null
#endif

Second, since the esp32c3 doesn't support edge triggered interrupts, I just changed the definition of onalarm to use ESP_INTR_FLAG_IRAM instead of ESP_INTR_FLAG_EDGE

: onalarm ( xt t ) swap >r t>nx r>
                   0 ESP_INTR_FLAG_IRAM timer_isr_callback_add throw ;

and the interval timer works as intended on this chip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions