I have a section of code where it is impossible for an interrupt to work. How can this be implemented? For example, the
instruction 1
instruction 2
disable interrupt
main instruction
enable interrupt
...
How to work with atomic esp32 operations (disabling interrupts)
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to work with atomic esp32 operations (disabling interrupts)
You would use a critical section (docs).
Re: How to work with atomic esp32 operations (disabling interrupts)
Great! But if I need to block the interrupt only on the GPIO13 and do not touch the rest and it should be in the task
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to work with atomic esp32 operations (disabling interrupts)
instruction 1
instruction 2
gpio_set_intr_type(irqPin, GPIO_INTR_DISABLE);
main instruction
gpio_set_intr_type(irqPin, GPIO_INTR_HIGH_LEVEL);
instruction 2
gpio_set_intr_type(irqPin, GPIO_INTR_DISABLE);
main instruction
gpio_set_intr_type(irqPin, GPIO_INTR_HIGH_LEVEL);
Re: How to work with atomic esp32 operations (disabling interrupts)
Thanks for the explanation!
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to work with atomic esp32 operations (disabling interrupts)
Note that on an ESP32, a critical section tends to be better for this, as disabling the IRQ has the race condition that the IRQ may already be in the process of being serviced on the other core. (Additionally, gpio_set_intr_type goes over a shared bus; I'm not sure if without a write fence that write is guaranteed to arrive before the next instruction.)
Who is online
Users browsing this forum: No registered users and 76 guests