In some cases, you may want to ensure a section of code is not interrupted. For example, you might be talking to a peripheral where the whole transaction must happen in one go, and an interrupt could cause the operation to fail.
The simplest way to avoid this is to disable interrupts for the critical section of your code:
__disable_irq(); // Disable Interrupts
// do something that can't be interrupted
__enable_irq(); // Enable Interrupts
The interrupts that are received during the "do something..." block are processed after __enable_irq() ?
I'll see if I can dig up the details in the datasheet.
In case someone was wondering and didn't want to have to go research I thought I'd ask.
Many thanks!
The interrupts that are received during the "do something..." block are processed after ~__enable_irq() ?
I'll see if I can dig up the details in the datasheet.
In case someone was wondering and didn't want to have to go research I thought I'd ask.
Many thanks!
Who cares what the data sheet say? The mbed is designed for easy experimenting. So, why not write & run a simple test program who's result reveals whether/when interrupts are fired in the above situation, and post the results for us all. That sort of thing also helps reveal bugs between what the 'experts' think should/will happen from the library functions, and what really happens :-)!
Michael
Who cares what the data sheet say? The mbed is designed for easy experimenting. So, why not write & run a simple test program who's result reveals whether/when interrupts are fired in the above situation, and post the results for us all. That sort of thing also helps reveal bugs between what the 'experts' think should/will happen from the library functions, and what really happens :-)!
Your posted method has solved one of my stucking server issues forever!! I appreciate you saved lots of my time.
_disable_irq(); Disable Interrupts
do something that can't be interrupted
enable_irq(); Enable Interrupts
Simon:
Your posted method has solved one of my stucking server issues forever!! I appreciate you saved lots of my time.
_disable_irq(); // Disable Interrupts
// do something that can't be interrupted
__enable_irq(); // Enable Interrupts
Please login to post comments.