Yahoo Groups archive

Lpc2000

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

Message

Re: external interrupt edge sensitive don't work

2005-03-17 by Mark Butcher

Hallo Sebastien

I didn't study your code because I'm not sure that it is the same 
for the LPC210x (which I know) as for the LPC22xx (which I don't 
know). However I did note this sentence towards the end which 
reminded me of an experince I had:

"I dont understand why IRQ is always active even when there's no 
edge ...."

These are my ideas

1. The interrupts are basically level sensitive and not specifically 
falling edge sensitive.

2. If an interrupt routine is called due to the iRQ line going low 
and doesn't do an action to cause the IRQ line to go high again [eg. 
reading a register from an external peripheral device] it can NOT 
clear the interrupt. It will reenter the IRQ routine as soon as it 
leaves it.
[Detail: It is not possible to clear an interrup by using the 
following code if the IRQ line stays low {EXTINT_bit.EINT2 = 1} 
beacsue the level sensitive interrupt simply causes it to be set 
again]

3. I wanted to have an interrupt on an input sensor and adopted the 
following code (which I call "one-shot" interrupt code) - example 
for IRQ2.

A: Prepare the "one shot" interrupt
  __disable_int();
  LPC210xInitExternalInterrupt2(fnEint2Interrupt);
  PINSEL0_bit.P0_15=0x2;  // Set pin function to EINT2
  EXTINT_bit.EINT2 = 1;   // try to clear any pending interrupt
  __enable_int();

void LPC210xInitExternalInterrupt2(void(*eint2_func)())
{
  eint2_function = eint2_func;     // Setup eint2 callback function.
  VICIntSelect &= ~VIC_EINT2_bit;  // IRQ on external int 2.
  VICVectAddr4 = (unsigned int)&ExternalInterrupt2;
  VICVectCntl4 = 0x20 | VIC_EINT2; // Enable vector interrupt.
  VICIntEnable = VIC_EINT2_bit;      // Enable EINT 2 interrupt.
}

B: When the IRQ occurs:

static void ExternalInterrupt2()   // IRQ 2 interrupt routine
{
  PINSEL0_bit.P0_15=0;    // Set pin function to normal input. 
  (*eint2_function)();    // Execute interrupt callback function.
  EXTINT_bit.EINT2 = 1;   // Reset external interrupt flag. 
}

You will see that the first thing which the IRQ routine does is to 
set the IRQ line back to normal input. This allows the IRQ flag to 
be reset even if the IRQ line remains low - hence the "One-shot" 
property.

C: If another interrupt is required A: can be performed again.
Note that if the IRQ line is already at a low level the IRQ routine 
will immediately be entered.

Maybe this was not exactly your problem but it may help.

Avec mes meilleurs salutations

Mark Butcher

www.mjbc.ch

Attachments

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.