m051的p32, p33是int 0, int 1中斷,是專用的中斷向量
建議使用bsp裡面的例子
M051_Series_BSP_CMSIS_Rev3.00.001\SampleCode\RegBased\GPIO_EINTAndDebounce
void EINT0_IRQHandler(void)
{
/* For P3.2, clear the INT flag */
P3->ISRC = BIT2;
printf("P3.2 EINT0 occurred.\n");
}
void EINT1_IRQHandler(void)
{
/* For P3.3, clear the INT flag */
P3->ISRC = BIT3;
printf("P3.3 EINT1 occurred.\n");
}
SYS->P3_MFP |= (SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0 | SYS_MFP_P32_INT0 | SYS_MFP_P33_INT1);
/* Configure P3.2 as EINT0 pin and enable interrupt by falling edge trigger */
P3->PMD = P3->PMD & (~GPIO_PMD_PMD2_Msk) | (GPIO_PMD_INPUT << GPIO_PMD_PMD2_Pos);
P3->IMD |= (GPIO_IMD_EDGE << 2);
P3->IEN |= (BIT2 << GPIO_IEN_IF_EN_Pos);
NVIC_EnableIRQ(EINT0_IRQn);
/* Configure P3.3 as EINT1 pin and enable interrupt by rising and falling edge trigger */
P3->PMD = P3->PMD & (~GPIO_PMD_PMD3_Msk) | (GPIO_PMD_INPUT << GPIO_PMD_PMD3_Pos);
P3->IMD |= (GPIO_IMD_EDGE << 3);
P3->IEN |= ((BIT3 << GPIO_IEN_IR_EN_Pos) | (BIT3 << GPIO_IEN_IF_EN_Pos));
NVIC_EnableIRQ(EINT1_IRQn);
|