21ic问答首页 - HC32L110C6UA端口中断问题
HC32L110C6UA端口中断问题
lynliiiiii2021-01-04
华大HC32L110C6UA芯片配置P03端口输入下降沿中断,一旦触发中断就会一直进入端口中断,有对M0P_GPIO->P3ICLR写入0操作,并读取M0P_GPIO->P3ICLR和M0P_GPIO->P0STAT_f 寄存器发现值并没有变化。不知道是有哪里没有设置好,各位大神帮忙看看!如下是程序过程:
void Gpio_IRQHandler(uint8_t u8Param){
uint32_t read_stat=0;
switch(u8Param)
{
case 0:
{
}
break;
case 1:
{
}
break;
case 2:
{
}
break;
case 3:
{
}
break;
default:;
break;
}
*((uint32_t *)((uint32_t)&M0P_GPIO->P3ICLR + u8Param * 0x40)) = 0;
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P3ICLR + u8Param * 0x40));
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P0STAT_f + u8Param * 0x40));
}
int32_t main(void)
{
Gpio_InitIOExt(0, 3, GpioDirIn, FALSE, FALSE, FALSE, FALSE);
Gpio_ClearIrq(0, 3);
//上升沿
Gpio_EnableIrq(0, 3, GpioIrqFalling);
EnableNvic(PORT0_IRQn, DDL_IRQ_LEVEL_DEFAULT, TRUE);
while(1)
{
}
}
void Gpio_IRQHandler(uint8_t u8Param){
uint32_t read_stat=0;
switch(u8Param)
{
case 0:
{
}
break;
case 1:
{
}
break;
case 2:
{
}
break;
case 3:
{
}
break;
default:;
break;
}
*((uint32_t *)((uint32_t)&M0P_GPIO->P3ICLR + u8Param * 0x40)) = 0;
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P3ICLR + u8Param * 0x40));
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P0STAT_f + u8Param * 0x40));
}
int32_t main(void)
{
Gpio_InitIOExt(0, 3, GpioDirIn, FALSE, FALSE, FALSE, FALSE);
Gpio_ClearIrq(0, 3);
//上升沿
Gpio_EnableIrq(0, 3, GpioIrqFalling);
EnableNvic(PORT0_IRQn, DDL_IRQ_LEVEL_DEFAULT, TRUE);
while(1)
{
}
}
赞0
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P3ICLR + u8Param * 0x40));
read_stat=*((uint32_t *)((uint32_t)&M0P_GPIO->P0STAT_f + u8Param * 0x40));
这几个操作,在GPIO.c里面有对应库函数,建议不要用上述的方式操作寄存器,很容易写错
评论
2021-01-04
赞0
评论
2021-01-04
您需要登录后才可以回复 登录 | 注册