-
Hi, I'm trying to use interrupts with ESP32. Once I enable interrups when using clocks, after some time (consistently 18 seconds of simple looping and logging) the device stops/hangs. This to related to the combination of clocks enabling interrupts because if I disable all interrupts or don't create the clocks (ClockControl) then device continues to work.
This is the code that reproduces the issue, nothing special about it:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
Basically Those interrupts are unhandled. There is currently no good way to notice that (while unhandled peripheral interrupts should give you a log message). But for using interrupts calling
This wouldn't make sense giving my explanation above and indeed it will freeze but without the delay the counter gets to One question: Where did you find |
Beta Was this translation helpful? Give feedback.
-
I found this here - https://dev.to/apollolabsbin/esp32-embedded-rust-at-the-hal-gpio-button-controlled-blinking-1p93 (under Enable global interrupts). That doesn't seem to be your material, but jumps high on google The article refers to ESP32C so maybe there's a difference between how things should be done there? I tried your guidelines now to enable only the GPIO interrupt, this is what I ended up with, is that the correct way to enable the interrupts? function name was different from
It's indeed working, but I'm not sure I fully understand how that would work in the general case:
But how can I tell which gpio triggered if several could and I want to trigger on |
Beta Was this translation helpful? Give feedback.
-
Oh yes apollolabsbin is quite popular but we are in loose contact to the author so we probably should get that changed. Thanks! There is only one GPIO interrupt, that is right.
So basically, when the interrupt is enabled but no pin is listening nothing will happen. The other way around, call In fact, there was an API for checking if a specific pin did raise the interrupt but it seems it got lost during some refactoring. I will create an issue for getting it back - thanks for bringing this up |
Beta Was this translation helpful? Give feedback.
-
Issue created: #923 BTW a good source of information is also the examples folder in this repository: https://github.com/esp-rs/esp-hal/tree/main/esp32-hal/examples |
Beta Was this translation helpful? Give feedback.
-
Found another reference to the use of that unsafe code in an example on your repo: |
Beta Was this translation helpful? Give feedback.
Basically
hal::xtensa_lx::interrupt::enable()
just enables all CPU interrupts (see TRM chapter "2.3.2 CPU Interrupt") which includes interrupts Timer,0, Timer.1, Timer.2 which are CPU internal timers. One of them will wrap/overflow shortly after your counter gets to 18.Those interrupts are unhandled. There is currently no good way to notice that (while unhandled peripheral interrupts should give you a log message).
But for using interrupts calling
hal::xtensa_lx::interrupt::enable()
yourself is unnecessary sinceenable_interrupt
will enable the correct interrupt for you.This wouldn't make sens…