程序摘要如下:
#define PWMCOMP (1ul << 2)
#define B1MAT1 (1ul << 10)
void PINInit( void )
{
LPC_IOCON->PIO2_2 &= (~0x07);
LPC_GPIO2->DIR &= (~PWMCOMP); /* 输入 */
LPC_GPIO2->IS = 0; /* P2.2为边沿中断 */
LPC_GPIO2->IEV |= PWMCOMP; /* 上升沿中断 */
LPC_GPIO2->IE |= PWMCOMP; /* P2.2中断不屏蔽 */
NVIC_EnableIRQ(EINT2_IRQn);
}
void PIOINT1_IRQHandler(void)
{
LPC_GPIO1->DATA |= B1MAT1;
LPC_GPIO2->IC |= PWMCOMP; /* 此语句要放到中断处理退出前 */
}
int main()
{
....
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 16);
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 6);
PINInit( );
// 显示程序
while(1)
{...}
}
调试发现,屏蔽NVIC_EnableIRQ(EINT2_IRQn); 显示和按键及定时器PWM功能都正常
|