No Clear interrupt for EINTx in 17xx_40xx in lpcOpen- Show Stopper

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

No Clear interrupt for EINTx in 17xx_40xx in lpcOpen- Show Stopper

1,124 Views
walterbuttazzo
Contributor II

Huge lack in GPIOINT lpcopen library

I searched really a lot but I did not find any function or setting in order to clear external interrupt.

Every example and application note shows how to set e GPIO as external interrupt using EINT3 as collector, but if you want to use EINT0,1,2 as dedicated pin per external interrupt, there is no way to clear interupt flag at the bottom of interrupt routine.

Function Chip_GPIOINT_ClearIntStatus does NOT work because pin is not GPIO but EINT (Function 1 in IOCONF).

Very simple code:

#define INT_PORT 2
#define INT_PIN 12

void EINT2_IRQHandler(void)
{
Chip_GPIOINT_ClearIntStatus(LPC_GPIOINT, INT_PORT, (1 << INT_PIN));
}

int main(void)
{
Chip_IOCON_PinMuxSet(LPC_IOCON, INT_PORT, INT_PIN, IOCON_FUNC1); //EINT2
Chip_GPIO_SetPinDIRInput(LPC_GPIO, INT_PORT, INT_PIN);
/* Configure channel interrupt as edge sensitive and falling edge interrupt */
Chip_GPIOINT_SetIntFalling(LPC_GPIOINT, INT_PORT, INT_PIN);
/* Clear Interrupt */
Chip_GPIOINT_ClearIntStatus(LPC_GPIOINT, INT_PORT, (1 << INT_PIN));
NVIC_EnableIRQ(EINT2_IRQn);

while(1);

}

Running code is in loop inside EINT2_IRQHandler because (once again) interrupt flag is not clear.

This is valid for every EINT0,1,2

Please, I need help to fix this serious problem.

Thank you so muck

Labels (3)
1 Reply

584 Views
walterbuttazzo
Contributor II

Well, I've got a temporary fix, adding function in LPCOpen library

Structure created to handle native External Interrupt is located in clock_17xx_40xx.c

and is LPC_SYSCTL

so, I added those 3 functions

void Chip_Clock_ClearEXTInterrupt(uint32_t ext_int)
{
LPC_SYSCTL->EXTINT = (1<<ext_int); /* Clear Interrupt Flag */
}

void Chip_Clock_EdgeTriggerEXTInterrupt(uint32_t ext_int)
{
LPC_SYSCTL->EXTMODE = (1<<ext_int); /* Edge Trigger */
}

void Chip_Clock_PolarityEXTInterrupt(uint32_t ext_int)
{
LPC_SYSCTL->EXTPOLAR = (1<<ext_int); /* Falling edge */
}

and in gpioint_17xx_40xx.c I added

void Chip_GPIOINT_ClearEXTInterrupt(uint32_t ext_int)
{
Chip_Clock_ClearEXTInterrupt(ext_int);
}

void Chip_GPIOINT_EdgeTriggerEXTInterrupt(uint32_t ext_int)
{
Chip_Clock_EdgeTriggerEXTInterrupt(ext_int);
}


void Chip_GPIOINT_PolarityEXTInterrupt(uint32_t ext_int)
{
Chip_Clock_PolarityEXTInterrupt(ext_int);
}

So, my main code is now

#define EINT_TEST 2

void EINT2_IRQHandler(void)
{
Chip_GPIOINT_ClearEXTInterrupt(EINT_TEST);
}


int main(void)
{
Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 12, IOCON_FUNC1); //EINT2
Chip_GPIOINT_EdgeTriggerEXTInterrupt(EINT_TEST);
Chip_GPIOINT_PolarityEXTInterrupt(EINT_TEST);
Chip_GPIOINT_ClearEXTInterrupt(EINT_TEST);
NVIC_EnableIRQ(EINT2_IRQn);

while(1);

}

It was quite hard, I used this example to understand

LPC1768: External Interrupts - Tutorials 

I hope one day NXP will fix this issue and provide a useful GPIOINT library