Multiple GPIO interrupts

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

Multiple GPIO interrupts

Jump to solution
3,641 Views
albt
Contributor II

Hi everyone,

I am a bit lost with the GPIO interrupts configuration, I hope you can guide me. (I actually use the KL02Z32VFM4 processor and IAR as a Software Tool)

I would like to activate two different input pins with different interrupt routines, specifically PTB3 and PTB4 pins.

At this moment I have one of the interrupt pins working (PTB3) with its own interrupt routine. I use the PORTB_IRQHandler, but I do not know how to configure the processor to distinguish between the two interrupt port pins.

Are there different IRQHandlers to differentiate between these two GPIO pins? Do I have to check the specific inturrupted pin in the same IRQHandler routine? What is the proper way of doing it?

Thanks a lot for your help.

Labels (1)
1 Solution
2,118 Views
lucianomoretti
Contributor IV

My understanding is there is only one interrupt for the port and then in the Port ISR you have to read the Interrupt Status Flag Register for the port to figure out what pin caused the interrupt.

View solution in original post

0 Kudos
3 Replies
2,118 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Andres L. Bleda

Yes, as mentioned Luciano you have to differenciate the pin by the interrupt status Flag, for example for the PORTB that you mentioned

void PORTB_IRQHandler(void){

    if (PORTB_ISFR & (1<<3)){

        PORTB_ISFR |= (1<<3);

        /* your code here */

    }

    if (PORTB_ISFR & (1<<4)){

        PORTB_ISFR |= (1<<4);

        /* your code here */

    }

}

Hope this helps
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,119 Views
lucianomoretti
Contributor IV

My understanding is there is only one interrupt for the port and then in the Port ISR you have to read the Interrupt Status Flag Register for the port to figure out what pin caused the interrupt.

0 Kudos
2,117 Views
mjbcswitzerland
Specialist V

Hi

I have attached the port interface from the uTasker project which shows how to handle individual interrupts (or DMA) on each GPIO.

For an overview of the interface see: http://www.utasker.com/kinetis/LLWU.html (which also shows how LLWU ports can be defined if required)

This works on all K, KL, KE, etc. parts (with some restrictions in case some devices don't support specific capabilities).

You can also take a complete IAR project and simulate the behaviour (for cheking or analysis of detailed operation) in its KL simulator if highest developent efficiency is of concern: http://www.utasker.com/kinetis/FRDM-KL02Z.html

Regards

Mark