Skip to main content
Arduino

Timeline for Disable interrupts when doing critical things?

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Nov 21, 2019 at 15:28 comment added romkey @EdgarBonet good point, with the hardware doing some of the work too,
Nov 21, 2019 at 15:09 comment added romkey @chrisl true! Although I think most people who know that are safe to do more in an interrupt handler than set a flag :)
Nov 21, 2019 at 15:07 comment added romkey @Alex Yes, you should not disable interrupts while you're doing housekeeping operations. It's important not to disable interrupts. If this were a problem, almost none of the Arduino code out there would work right.
Nov 21, 2019 at 9:53 vote accept Alex
Nov 21, 2019 at 9:11 comment added Edgar Bonet Excellent answer. Just a comment on "a properly written interrupt handler will save any necessary state": unless written in assembly, the code for saving and restoring the state is written by the compiler, and you can pretty much trust it to do it right.
Nov 21, 2019 at 8:31 comment added chrisl "just set a flag to indicate that the interrupt occurred, and let code in the loop() check for the flag." - Though then you don't need the ISR at all, since the MCU already has an interrupt flag build into it's register. You could also poll that flag.
Nov 21, 2019 at 6:28 comment added Alex to be clear: i am not using spiffs in the interrupt handler. the interrupt handler merely increments a counter in my case (on rainfall). i was just concerned if data would be corrupted or cause a crash if an interrupt triggered during some housekeeping operations I do with spiffs. you are saying i should be fine leaving out the noInterrupts .etc.?
Nov 21, 2019 at 5:45 history answered romkey CC BY-SA 4.0

AltStyle によって変換されたページ (->オリジナル) /