CH552如何同时检测两路GPIO中断

现在研究你们CH552单片机,SOP16封装,测试GPIO中断,因为要实现编码器,P1.4和P1.5同时设置为下降沿中断,代码如下,请问在GPIOInterrupt中断服务函数里面,怎么判断是哪个GPIO产生了下降沿中断呢?目前示例程序只有一句打印printf("GPIO_STATUS: %02x\n",(UINT16)(PIN_FUNC&bIO_INT_ACT)); 似乎只能知道是有下降沿产生了,具体是哪个GPIO,从哪里知道呢


void GPIOInterruptCfg()
{
   GPIO_IE &= ~bIE_IO_EDGE;
   GPIO_IE |= bIE_IO_EDGE;                                                     // edge trigger
   GPIO_IE |= bIE_P1_4_LO;                                                     // GPIO P1.4 falling edge
   GPIO_IE |= bIE_P1_5_LO;                                                     // GPIO P1.5 falling edge
	 GPIO_IE |= bIE_P3_1_LO;                                                     // GPIO P3.1 falling edge(button pressed)

   IE_GPIO  = 1;                                                               //GPIO????????
}


另外,看到所有CH552所有的GPIO在边沿中断时,好像只支持下降沿(falling)中断,不支持上升沿(rising)中断,是不是根本就没法支持编码器?


使用RST引脚的上升沿中断+INT0或者INT1的下降沿中断,分别属于两个不同的中断源。


就是说,没办法使用上升沿,下降沿中断来实现编码器了,是吧


well usually for simple (mechanical) encoders timer will be used. This has the advatage that debouncing can be done easily. Pin interrupts are too fast for that. 

There is however one exeption:

For Hi Res Hispeed Encoders external interrupts may be used. These types are often optical and dont bounce.


只有登录才能回复,可以选择微信账号登录