1 year, 9 months ago.

Is there a function pair for disarming and rearming all interrupts

Typically, the disarm function returns the interrupt state before the call, and the rearm function uses that state for the restoration.

I assume that arithmetic on long long variables is an interruptible sequence of instructions.

1 Answer

1 year, 9 months ago.

Hello Alfred,

Maybe this could help you:


core_util_critical_section_enter(); // disables all interrupts

...  // code section that is not going to be interrupted

core_util_critical_section_exit();   // re-enables all interrupts


Wow! Thanks. I never found that. Documentation says you can have nested calls of this pair.

I saw an article where someone was having a problem in which core_util_critical_section_enter/exit was being used. This scares the heck out of me.

posted by Alfred Hume 26 Mar 2018

Don't be afraid. Since these functions are used for the implementation of many mbed APIs, if it was like that almost each program built with mbed would crash.

posted by Zoltan Hudak 27 Mar 2018

There is also a C++ interface for this. You can use either RAII or the static enable/disable members. Code within these blocks should be very small and fast. If misused, you can miss system wide interrupt events. https://os.mbed.com/docs/v5.8/reference/criticalsectionlock.html

posted by Sam Grove 27 Mar 2018