我为外部中断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;
}
我想我的问题是在中断的初始化(?)
如果有人可以帮助我,
感谢