-
Notifications
You must be signed in to change notification settings - Fork 173
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
Counting pin interrupts no longer possible with 0.42.5? #349
Comments
Is there any reason why you want to count the edge interrupts in the interrupt routine? If not, then the routine can just notify a regular (yet maybe high priority) task/thread which can do the counting and the re-enablement of the interrupt for you? |
I'm using this for checking a fan tachometer signal generating one pulse per revolution. I don't know why I ended up using Using a separate task for counting and re-enabling the interrupt would add two context switches for each interrupt. I have not done the exact numbers yet. But wouldn't this be an an order of magnitude more instructions which need to be executed in this case? What's the reason behind making it no longer possible to re-enable an interrupt from its handler? Nevertheless, this was already a workaround in the first place on the ESP32-C3. As I don't need to monitor fan speed continuously, I would nowadays go for using the RMT peripheral in time sharing mode between driving the smart LED and checking the pulses from the fan tachometer in my application. And with the new ESP32-C6 i would just use the dedicated pulse counter. |
@ivmarkov I think this is not the intended use-case here by sirhcel. While it is possible to do that with a notify_and_yield(), the former way of just let it run and get notified eventually with notify is effected here. He wants to count it fast with as little overhead as possible, but don't need live updates for it, just wants to receive it sometime later ( using our async code would also relight on notify_and_yield so no direct option). IIRC you introduced the changes to automatically disable interrupts, because of LEVEL_INTERRUPTS correct? Because a level interrupt will always trigger as long as the pin is held in that defined level ( That can lead to the system crashing if one stays in isr for to long). I personally think we just crippled EDGE_INTERRUPTS, to make LEVEL_INTERRUPTS work like you would expect form a EDGE_INTERRUPT. But i think that is wrong because the initial assumption, that one just can use LEVEL_INTERRUPTS willy nilly is wrong. The purpose of them is they force the mcu in an interrupt as long as the line is hold and in my opinion serve a pretty specific niche. Obviously we can do with them whatever we want, as long as we make it workable. If i understand correctly your use-case is you want to trigger on something where you know that the line did potentially already switched level before you enabled the routine and just want to asynchronously now the level once? I see three paths forward here:
|
The problem with these two is that if - for whatever reason - the user would like to disable/enable interrupts from the I think these two can only work if we extend the signature of the Other than that, I have to look whether the async code will continue to work correctly under the new constellation of not disabling the interrupts once the first one hits. |
I'm struggling with this too. Admittedly, I'm rather new to ESP32 and Rust and esp-idf-hal, so it is entirely possible I'm misunderstanding how to use the APIs and how the board works, etc.. Apologies in advance if that is the case. However, what I want to do is fairly simple, and the decision to make There is an independently changing variable ( If the interrupt was not auto-disabled after firing, I could just have the Perhaps I'm also a little curious about the intended behavior of |
Upgrading esp-idf-svc from 0.40.1 to 0.42.5 breaks my attempt for counting edges on a GPIO pin. I'm running an application on an ESP32-C3 where the RMT is used for driving LEDs. So I'm using interrupt handler as follows:
Enabling this interrupt from "main" and re-enabling it from the interrupt handler does not work out as I can't share the
PinDriver
mutably by reference between them. Moving it to the handler prevents enabling the interrupt from "main".If and if yes, how is this supposed to work with esp-idf-hal 0.42.5?
The text was updated successfully, but these errors were encountered: