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,325件の閲覧回数
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,101件の閲覧回数
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,101件の閲覧回数
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,101件の閲覧回数
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