Content originally posted in LPCWare by ethan_kao on Mon Jan 26 00:23:20 MST 2015
Dear all,
I use the LPC1113 MCU, 2 IO for HW IRQ, it's PIO0_11 and PIO1_11
1. Set this 2 IO is input
2. Use GPIOSetInterrupt(0,11,0,0,1); and GPIOSetInterrupt(1,11,0,0,1); to define HW trigger condition
3. NVIC_EnableIRQ(EINT0_IRQn); and NVIC_EnableIRQ(EINT1_IRQn);
4. PIOINT0_IRQHandler function as below, especial use PIO1_3 for debug.
Then...I never see the PIO1_3 change to LOW, it means this IRQ not triggered...
Is anything or setting miss?
In LPC11xx.h
EINT3_IRQn = 28, /*!< External Interrupt 3 Interrupt */
EINT2_IRQn = 29, /*!< External Interrupt 2 Interrupt */
EINT1_IRQn = 30, /*!< External Interrupt 1 Interrupt */
EINT0_IRQn = 31, /*!< External Interrupt 0 Interrupt */
In startup_LPC11xx.s
DCD PIOINT3_IRQHandler ; 16+28: PIO INT3
DCD PIOINT2_IRQHandler ; 16+29: PIO INT2
DCD PIOINT1_IRQHandler ; 16+30: PIO INT1
DCD PIOINT0_IRQHandler ; 16+31: PIO INT0
void GPIOInit( void )
{
/* Enable AHB clock to the GPIO domain. */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
LPC_IOCON->R_PIO0_11 = 0x01;// set AD0 pin as gpio
LPC_IOCON->PIO1_11 = 0x00; // set AD7 is GPIO
LPC_IOCON->R_PIO1_1 = 0x01;
LPC_IOCON->R_PIO1_2 = 0x01;
LPC_IOCON->SWDIO_PIO1_3 = 0x01; // for debug IO, default is output HIGH
LPC_IOCON->PIO1_4 = 0x00;
LPC_IOCON->PIO0_2 = 0x00;
LPC_IOCON->PIO0_3 = 0x00;
LPC_IOCON->PIO0_4 = 0x00;
LPC_IOCON->PIO0_5 = 0x00;
LPC_IOCON->PIO0_6 = 0x00;
LPC_IOCON->PIO0_7 = 0x00;
LPC_IOCON->PIO0_9 = 0x00;
LPC_IOCON->PIO3_2 = 0x00;
LPC_IOCON->PIO3_5 = 0x00;
//LPC_IOCON->PIO1_8 &= ~0x07;
LPC_IOCON->PIO1_8 = 0x00;
//LPC_IOCON->PIO1_9 &= ~0x07;
LPC_IOCON->PIO1_9 = 0x00;
GPIOSetDir(1,8,1);
//GPIOSetValue(1,8,0);
GPIOSetDir(1,9,0);
//GPIOSetValue(1,9,1);
LPC_IOCON->R_PIO1_0 = 0x01;//set p1_0 pin as gpio
GPIOSetDir(0,11,0);//AD0 is input GPIO, detect square wave __compare time
GPIOSetDir(1,11,0); //AD7 is input GPIO, detect PWM square _/
GPIOSetDir(1,3,1);
GPIOSetDir(1,4,1);
GPIOSetValue(1,3,1);
GPIOSetValue(1,4,1);
GPIOSetDir(1,0,1);//
GPIOSetValue(1,0,1);//Set default output HIGH
GPIOSetDir(3,2,1);//Set PIO3_2 be output
GPIOSetValue(3,2,1);//Set default input HIGH
GPIOSetDir(3,5,0);//Set PIO3_5 be input
GPIOSetValue(3,5,1);//Set default input HIGH
GPIOSetInterrupt(0,11,0,0,1); // set port_0/bit_11 as interrupt/edge trigger/single edge/falling edge
GPIOSetInterrupt(1,11,0,0,1);
GPIOSetDir(1,5,1);// set p1_5 output
GPIOSetValue(1,5,1);// set p1_5 high
GPIOSetDir(0,2,1); // a
GPIOSetValue(0,2,1);
GPIOSetDir(0,3,1);// b
GPIOSetDir(0,4,1);// c
GPIOSetDir(0,5,1);// d
GPIOSetDir(0,6,1);// e
GPIOSetDir(0,7,1);// f
GPIOSetDir(0,9,1);// g
GPIOSetValue(1,8,0);
/* Set up NVIC when I/O pins are configured as external interrupts. */
NVIC_EnableIRQ(EINT0_IRQn);
NVIC_EnableIRQ(EINT1_IRQn);
GPIOIntEnable(0,11);
GPIOIntEnable(1,11);
return;
}
void PIOINT0_IRQHandler(void)
{
uint32_t regVal;
//gpio0_counter++;
regVal = GPIOIntStatus( PORT0, 11 );
if ( regVal )
{
GPIOSetValue(1,3,0); // debug IO, if IRQ occured, set output LOW
PIO0_FLAG = 1;
//p0_1_counter++;
GPIOIntClear( PORT0, 11 );
GPIOIntDisable( PORT0, 11 );
}
return;
}
Regards, Ethan