我已经为外部中断 EINT1 编写了代码。这行得通,但如果我想添加第二个中断(EINT3),只有新的作品。我可以两者兼得。
下面是我的代码,可能是我错了,但我看不到在哪里。你能帮助我吗?
printuart(14,"SLEEP MODE ON");
EINTInit();
LPC_SC->PCON &= ~(0x03 <<0);
flagwakeup=0;
while(flagwakeup==0)
checkwdt_ev(); //reset watchdog
NVIC_DisableIRQ(EINT1_IRQn);
LPC_PINCON->PINSEL4 &= ~(0x03 << 22); //as gpio
LPC_GPIO2->FIODIR &= ~(0x01 <<11); // as input
LPC_PINCON->PINSEL2 &= ~(0x03<<26); // P2.13 as GPIO
LPC_GPIO2->FIODIR &=~(1<<13); //P2.13 as input
printuart(16,"SLEEP MODE OFF");
uint32_t EINTInit( void )
{
LPC_PINCON->PINSEL4 &= ~(3UL<<22); // Reset P2.11 to GPIO
LPC_PINCON->PINSEL4 |= (0x01<<22); // P2.11 as external interupt
LPC_PINCON->PINSEL4 &= ~(3UL<<26); // Reset P2.13 to GPIO
LPC_PINCON->PINSEL4 |= (0x01<<26); // P2.13 as external interupt
LPC_GPIOINT->IO2IntEnF = ((0x01 <<11) | (0x01 <<13)); //Port2.11 and P2.13 are falling edge.
LPC_SC->EXTMODE = (EINT1_EDGE | EINT3_EDGE) ; //INT1 and INT3 edge trigger
LPC_SC->EXTPOLAR = 0; //INT1 and INT3 is falling edge by default
NVIC_EnableIRQ(EINT1_IRQn);
return( TRUE );
}
void EINT1_IRQHandler (void)
{
LPC_SC->EXTINT = EINT1; /* clear interrupt */
LPC_SC->PCONP |= (0x01 <<3); //power on uart0
LPC_SC->PCONP |= (0x01 <<4); //power on uart1
LPC_SC->PCONP |= (0x01 <<7); //power on i2c0
LPC_SC->PCONP |= (0x01 <<8); //power on SPI
LPC_SC->PCONP |= (0x01 <<10); //power on SSP1
LPC_SC->PCONP |= (0x01 <<19); //power on i2c1
LPC_SC->PCONP |= (0x01 <<21); //ppower on SSP0
LPC_SC->PCONP |= (0x01 <<26); //power on i2c2
//test2_count_fhn(15,"SLEEP MODE OFF");
flagwakeup=1;
}
我也尝试过另一个,结果相同:
printuart(14,"SLEEP MODE ON");
EINTInit(); //external interrupt for wake up after sleep mode
EINT3Init();
LPC_SC->PCON &= ~(0x03 <<0);
flagwakeup=0;
while(flagwakeup==0)
checkwdt_ev(); //reset watchdog
NVIC_DisableIRQ(EINT1_IRQn);
NVIC_DisableIRQ(EINT3_IRQn);
LPC_PINCON->PINSEL4 &= ~(0x03 << 22); //as gpio
LPC_GPIO2->FIODIR &= ~(0x01 <<11); // as input
LPC_PINCON->PINSEL2 &= ~(0x03<<26); // P2.13 as GPIO
LPC_GPIO2->FIODIR &=~(1<<13); //P2.13 as input
printuart(16,"SLEEP MODE OFF");
uint32_t EINTInit( void )
{
LPC_PINCON->PINSEL4 &= ~(3UL<<22); // Reset P2.11 to GPIO
LPC_PINCON->PINSEL4 |= (0x01<<22); // P2.11 as external interupt
LPC_GPIOINT->IO2IntEnF = (0x01 <<11); //Port2.11 is falling edge.
LPC_SC->EXTMODE = EINT1_EDGE ; // INT1 edge trigger
LPC_SC->EXTPOLAR = 0; // INT1 is falling edge by default
NVIC_EnableIRQ(EINT1_IRQn);
return( TRUE );
}
uint32_t EINT3Init( void )
{
LPC_PINCON->PINSEL4 &= ~(3UL<<26); // Reset P2.13 to GPIO
LPC_PINCON->PINSEL4 |= (0x01<<26); // P2.13 as external interupt
LPC_GPIOINT->IO2IntEnF |= (0x01 <<13); //Port2.13 is falling edge.
LPC_SC->EXTMODE |= EINT3_EDGE; // INT3 edge trigger
LPC_SC->EXTPOLAR = 0; //INT1 is falling edge by default */
NVIC_EnableIRQ(EINT3_IRQn);
return( TRUE );
}
void EINT3_IRQHandler (void)
{
LPC_SC->EXTINT = EINT3; //clear interrupt
LPC_SC->PCONP |= (0x01 <<3); //power on uart0
LPC_SC->PCONP |= (0x01 <<4); //power on uart1
LPC_SC->PCONP |= (0x01 <<7); //power on i2c0
LPC_SC->PCONP |= (0x01 <<8); //power on SPI
LPC_SC->PCONP |= (0x01 <<10); //power on SSP1
LPC_SC->PCONP |= (0x01 <<19); //power on i2c1
LPC_SC->PCONP |= (0x01 <<21); //ppower on SSP0
LPC_SC->PCONP |= (0x01 <<26); //power on i2c2
flagwakeup=1;
}
void EINT1_IRQHandler (void)
{
LPC_SC->EXTINT = EINT1; //clear interrupt
LPC_SC->PCONP |= (0x01 <<3); //power on uart0
LPC_SC->PCONP |= (0x01 <<4); //power on uart1
LPC_SC->PCONP |= (0x01 <<7); //power on i2c0
LPC_SC->PCONP |= (0x01 <<8); //power on SPI
LPC_SC->PCONP |= (0x01 <<10); //power on SSP1
LPC_SC->PCONP |= (0x01 <<19); //power on i2c1
LPC_SC->PCONP |= (0x01 <<21); //ppower on SSP0
LPC_SC->PCONP |= (0x01 <<26); //power on i2c2
flagwakeup=1;
}
我想我的问题出在中断的初始化(?)
如果有人可以帮助我,
谢谢