#include "bat32g137.h"
int main(void)
{
// 配置为下降沿触发
INTM->EGN0 = 0x01;
INTM->EGP0 = 0x00;
// 配置为输入模式
/* Set INTP0 pin */
PORT->PM13 |= 0x40U;
// 内部给P136上拉
PORT->PU13 |= (1<<6);
//清除中断挂起
INTC_ClearPendingIRQ(INTP0_IRQn);/* clear INTP0 interrupt flag */
// 开启中断
INTC_EnableIRQ(INTP0_IRQn);/* enable INTP0 interrupt */
PORT->POM0 &= ~(1<<5); // P05
PORT->PMC0 &= ~(1<<5);
PORT->PM0 &= ~(1<<5);
PORT->POM3 &= 0xFEU; // P30
PORT->PM3 &= 0xFEU;
while(1)
{
uint32_t t = 0;
t = 1000000;
while(t--);
PORT->P0 |= (1<<5);
t = 1000000;
while(t--);
PORT->P0 &= ~(1<<5);
}
}
void IRQ01_Handler(void) __attribute__((alias("intc0_intc6_interrupt")));
static void intc0_intc6_interrupt(void)
{
if (1U == INTC_GetPendingIRQ(INTP0_IRQn))
{
PORT->P3 ^= 0x01;
INTC_ClearPendingIRQ(INTP0_IRQn);
}
}
137 外部中断。
最新推荐文章于 2022-10-27 11:11:25 发布