Is it possible in the interrupt to see what edge (rising or falling) caused the interrupt?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Is it possible in the interrupt to see what edge (rising or falling) caused the interrupt?

1,436 次查看
markosiponen
Contributor III

I'm using a MK10FN1M0VLQ12.

I have enabled an interrupt on both falling and rising edge of a pin.

Is it possible in the interrupt to see what edge (rising or falling) caused the interrupt?

0 项奖励
回复
3 回复数

1,212 次查看
markosiponen
Contributor III

First I setup a interrupt on falling edge. Then in the interrupt I setup a interrupt when logic one, and so on. That way I cold detect the falling edge and also not miss the rising edge (if the interrupt was too slow to handle the interrupt). :smileyhappy:

0 项奖励
回复

1,212 次查看
Paul_Tian
NXP Employee
NXP Employee

Hi, Mark

You can use register GPIOx_PDIR to read GPIO data and check that bit is 1 or 0. Then you can know this interrupt is generated by rising edge or falling edge.

Best Regards

Paul

0 项奖励
回复

1,212 次查看
mjbcswitzerland
Specialist V

Hi

There is only a flag to say that the "event" occurred. You can read the pin's state to see what it is at after the interrupt routine is taken but this will only be sure if the input can't change too fast and multiple edges have occurred.

You could connect two port inputs in parallel, one set to rising edeg and the other to falling edge sensitivity.Then you would be sure which one occurred and whether two occured. Still you won't necessarily be sure that there weren't multiple edges and which one actually occurred first, but this may already be adequate.

Regards

Mark