Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New timer code for esp32c3 #51

Open
Eszartek opened this issue Apr 20, 2023 · 1 comment
Open

New timer code for esp32c3 #51

Eszartek opened this issue Apr 20, 2023 · 1 comment

Comments

@Eszartek
Copy link

Eszartek commented Apr 20, 2023

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.

@Eszartek
Copy link
Author

I just tried timer 1, which didn't work, but timer 2 does, so I made a mistake. I'll verify and correct the timer_init bits above shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant