cancel
Showing results for 
Search instead for 
Did you mean: 

disabling interrupts for a moment

wadi
Associate II
Posted on March 14, 2012 at 23:48

Hello

I want to disable interrupt while I am putting data to buffer, but I dont want to loss any interrupts during this time - I want them to be autimatically trigged when enable interrupts back.

I have found in CMSIS __enable_irq(); and __disable_irq();

static __INLINE void __enable_irq()               { __ASM volatile (''cpsie i''); }

static __INLINE void __disable_irq()              { __ASM volatile (''cpsid i''); }

is it works as I want it to work ? Is interrupts that came in period between disable and enable will not be lost?

with best regards

1 REPLY 1
emalund
Associate III
Posted on March 15, 2012 at 17:00

if everything else is as it should be, disabling an interrupt will work as you want.

it is a common misconception that e.g. the UART generates an interrupt, it does not, it sets a bit that the interrupt processor, when the interrupt ios enabled will check.

so, the UART set a bit

The interrupt processor generates the interrupt.

the problem with disabling interrupts is that there is no ''counter'' so, if e.g. during interrupt disabled the UART receives two characters, you will only get ONE interrupt OOPS.

thus disabling interrupts should be done VERY prudently.

I am putting data to buffer sounds like something that may take too long

Erik