How to configure a GPIO pin as an interrupt

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

How to configure a GPIO pin as an interrupt

1,537 Views
anurag16doshi
Contributor II

I am working on FreeRTOS for the m7 core of imx8mn. I currently need to enable a GPIO pin as an interrupt pin. I want to do this so that I can enable an ISR that makes my m7 do stuff related to my project. I am having a difficult time trying to figure out a lot of stuff as listed below:

  • Where to write the ISR?
  • How and where to associate the ISR with the right interrupt vector?
  • How and where to configure which GPIO event wanted to be triggered?
  • How and where to enable the interrupt for the pin inside the GPIO?
  • How and where to enable interrupt inside the interrupt controller?

If there is an example of GPIO interrupt for imx8mn out there, i would highly appreciate someone referencing it to me. I would also appreciate if I can understand this in terms of the MCUXpresso SDK examples.

 

TIA,

Anurag

0 Kudos
1 Reply

1,534 Views
jacquely
Contributor I

Answer 1.
You write the ISR as if it were an ordinary function. But you need to alert the compiler that this function is an interrupt handler, not a regular function. You alert the compiler using a pre-compiler directive known as a pragma. A listing of the OC4 handler is shown below. The ISR has the name OC4han(). This listing shows the correct way of declaring an ISR using the Imagecraft ICC11 compiler.

#pragma interrupt_handler OC4han()
void OC4han(void){
TOC4 = TOC4 + 256;
_Time = _Time + 1;
TFLG1 |= OC4F;
}

Answer 2.
Interrupt vectors
The interrupt vectors and vector table are crucial to the understanding of hardware and software interrupts. Interrupt vectors are addresses that inform the interrupt handler as to where to find the ISR (interrupt service routine, also called interrupt service procedure). All interrupts are assigned a number from 0 to 255, with each of these interrupts being associated with a specific interrupt vector.

Answer 3.
We are designing power source for RPI and we would like to be compatible to the HAT description.
The DT is kind of complex to us, but we are studying and trying to do our best to understand.
I understand how to set the GPIO output to provide signal for external watchdog for example.
viewtopic.php?f=29&t=108134

0 Kudos