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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,068 Views
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 Kudos
3 Replies

844 Views
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 Kudos

844 Views
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 Kudos

844 Views
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