先看看频率,还有就是一定要及时在上升沿判断吗?
其实可以再主循环里调用,通过电平判断,e.g.
#define LOW_LEVEL 0
#define GET_PIN(PORTn, index) (PINn & (1<<index))? (!LOW_LEVEL):LOW_LEVEL
BYTE is_rising_edge(void)
{
static BYTE last_status = DEFAULT_LEVEL;
BYTE curStatus = GET_PIN(PORTn, index);
result = FALSE;
if(last_status != curStatus )
{
if(last_status == LOW_LEVEL)
result = TRUE;
last_status = curStatus;
}
return result;
}
|