Hello.
As you can read in the title, I am trying to change the polarity of the edge which causes the external interrupt. I am using an LPC2129.
Firstly I configure it as rising edge sensitive and the VIC vectors registers:
PINSEL1 |= (0<<1) | (1<<0); //Pin P0.16 as EINT0
EXTMODE |= (1<<0) |; //Edge sensitive
EXTPOLAR |= (1<<0) ; //Rising edge
VICVectCntl1 = 0x20 |14;
VICVectAddr1 =(unsigned)EINT0_isr;
VICIntEnable |= (1<<14);
EXTINT |= (1<<0);
Then, in the irq routine I want to change to falling edge sensitive, as the following code:
void EINT0_isr (void) __irq {
EXTINT |= (1<<0); //Clear flag
...
EXTPOLAR &= ~(1<<0); //Change to falling edge
...}
This does not work and the program crash.
Then I read this in the manual but I do not understand how to do it:
Note: Software should only change a bit in this register when its interrupt is
disabled in the VICIntEnable register, and should write the corresponding 1 to the
EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear
the EXTINT bit that could be set by changing the polarity.
So I tried to change the code like this but did not work:
VICIntEnClr |= (1<<14);
EXTINT |= (1<<0);
EXTPOLAR &= ~(1<<0);
VICIntEnable |= (1<<14);
Which is the correct way to change edge polarity inside the irq routine of an EINT?
Best regards,
Alessandro
P.S.: sorry for my english.