2020-11-26 01:52 AM
Hello,
I have a global variable, wich is accessed by multiple ISRs.
Can I safely disable and re-enable the interrupts within an ISR using __disable_irq() and __enable_irq()?
Or is there a more elegant way of protecting the variable access?
best regards,
Michael Schmid
2020-11-26 02:16 AM
You can disable IRQs in an ISR, at the cost of increased jitter for the other ISRS. Ypu can also consider LDREX and STREX
2020-11-26 02:39 AM
If you have a C11 or C++11 compliant compiler you could use the provided atomic ops and data types.
2020-11-26 02:59 AM
nested __disable_irq() and __enable_irq() can cause issues.
2020-11-26 04:48 AM
Have the interrupts at the same priority so they don't interfere with each other, and be brief?
2020-11-26 05:05 AM
Hi,
the Interrupts have different prios. I don't want to use complicated assembler code if not neccessary, and the delay for the high prio task is not critical.
Nesting of the functions should not be a problem as well, as long as I call them only once in the ISR (if the ISR is called, i can be sure the interrupts are not disabled yet by the main task).
So then I will just use these functions, that seems to be easiest solution.
Thanks for your help =)