Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Nested enable/disable interrupt problem !!!

Nested enable/disable interrupt problem !!!

2006-05-14 by vlads4377

Hi,

Nested enable/disable interrupt problem !!!

f_1 ()
{ 
   __disable_interrupt()

   f_2 ();
A:
   __enablea_interrupt()
}

f_2 ()
{
      __disable_interrupt()

      __enable_interrupt()
}

The problem is that at point A: f_1() assumes that interrupts are 
disabled, but f_2() already enabled the interrupts.

Optional solution is something like this:

f_2 ()
{
    char int_ret = 0;
    int_ret =  disable_interrupt()

    enable_interrupt( int_ret )
}
int_ret holds interrupt status (CPSR interrupt bit) before the 
disable operation.

enable_interrupt( int_ret ) enables the interrupt just in case that 
int_ret == "interrupt was enabled"

1. Does any body has asm source for this solution ?.
2. Any better solution ?

Regards

Re: [lpc2000] Nested enable/disable interrupt problem !!!

2006-05-14 by Robert Adsett

At 08:51 AM 5/14/06 +0000, vlads4377 wrote:
>Nested enable/disable interrupt problem !!!
>
>f_1 ()
>{
>    __disable_interrupt()
>
>    f_2 ();
>A:
>    __enablea_interrupt()
>}
>
>f_2 ()
>{
>       __disable_interrupt()
>
>       __enable_interrupt()
>}
>
>The problem is that at point A: f_1() assumes that interrupts are
>disabled, but f_2() already enabled the interrupts.

This is one example showing why you should (almost) never use interrupt 
disable/enable but interrupt disable/restore.  See 
http://www.aeolusdevelopment.com/Articles/download.html  There is a set of 
disable/restore there that could be easily extracted from the rest of the 
library. There is documentation for using the routines at 
http://www.aeolusdevelopment.com/Articles/docandapp.html

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.