IMX8MM cortex-m4 GPIO interrupt example

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

IMX8MM cortex-m4 GPIO interrupt example

Jump to solution
1,387 Views
Bruno_Eztronic
Contributor I

Hello NXP,


recently I was developing an application for imx8mm cortex-m4 and a GPIO interrupt was needed. I haven't found any examples available that show how to properly configure the GPIO interrupt.

Do you have imx8MM M4 MCU GPIO input interrupt example code?

Thank you,

 

Bruno 

Labels (1)
0 Kudos
Reply
1 Solution
1,369 Views
Alejandro_Salas
NXP TechSupport
NXP TechSupport

Hello @Bruno_Eztronic 

I hope you are doing well.

I know, in SDK is not an GPIO input interrupt example.

I made a little program to use an interrupt in GPIO5_12 (I connected a push button) and I used the GPIO5_11 to toggle a LED in each interrupt.

Keep in mind the interrupts in SDK has a "number of IRQ (GPIOn_Combined_0_15_IRQn or GPIOn_Combined_16_31_IRQn)" and for an IRQHandler.

Alejandro_Salas_0-1705714945518.png

There you can see the simple definition of GPIO5_IO12 pin and the GPIO5_Combined_0_15_IRQn and  GPIO5_Combined_0_15_IRQHandler, this handler is only a "pointer" to our IRQHandler function:

Alejandro_Salas_1-1705715099007.png

If you require more information about of IRQs you can see the Reference Manual Table 7-1 ARM Domain Interrupt Summary. 

Alejandro_Salas_2-1705715255753.png

That is the reason why we need GPIO5_Combined_0_15_IRQn.

 

Any way, I will attach the gpio_led_output.c, there is the example of using interrupt in GPIO5_IO12 and toggle led in GPIO5_IO11.

In serial terminal you will see:

CM4_IRQ.png

I hope this can helps to you.

 

Best regards!

 

Salas.

 

 

View solution in original post

4 Replies
1,280 Views
deepakbeniya
Contributor III

That gpio_led_output.c file which you have provided , how do I compile for M4 and where to place inside the SDK .
I have imx8m mini board , I have compiled the hello_world, ping_pong examples and tested in M4 . 
I am using linux enviornment in my pc to compile the code.

Now I want to write my specific code for M4 and compile it , How can i do that ?
Is there any document available then please share it.

As you have provided the gpio_led_output.c file and it works for you , please let me know how you have done it.

Thanks and Regards
Deepak Kumar Beniya

0 Kudos
Reply
1,253 Views
Alejandro_Salas
NXP TechSupport
NXP TechSupport

Hello @deepakbeniya ,

I hope you a re doing well.

In this case, I cloned the gpio_led_output example that is in folder /driver_examples/gpio/gpio_led_output and then I modified the code there.

You can start your own project from a project template that is include in the SDK folder but you need to do several modifications.

Cloning the example you will be able to compile in the same way that you compile an example but with your own code.

I hope this can helps to you to compile your own code.

 

Best regards!

 

Salas.

0 Kudos
Reply
1,370 Views
Alejandro_Salas
NXP TechSupport
NXP TechSupport

Hello @Bruno_Eztronic 

I hope you are doing well.

I know, in SDK is not an GPIO input interrupt example.

I made a little program to use an interrupt in GPIO5_12 (I connected a push button) and I used the GPIO5_11 to toggle a LED in each interrupt.

Keep in mind the interrupts in SDK has a "number of IRQ (GPIOn_Combined_0_15_IRQn or GPIOn_Combined_16_31_IRQn)" and for an IRQHandler.

Alejandro_Salas_0-1705714945518.png

There you can see the simple definition of GPIO5_IO12 pin and the GPIO5_Combined_0_15_IRQn and  GPIO5_Combined_0_15_IRQHandler, this handler is only a "pointer" to our IRQHandler function:

Alejandro_Salas_1-1705715099007.png

If you require more information about of IRQs you can see the Reference Manual Table 7-1 ARM Domain Interrupt Summary. 

Alejandro_Salas_2-1705715255753.png

That is the reason why we need GPIO5_Combined_0_15_IRQn.

 

Any way, I will attach the gpio_led_output.c, there is the example of using interrupt in GPIO5_IO12 and toggle led in GPIO5_IO11.

In serial terminal you will see:

CM4_IRQ.png

I hope this can helps to you.

 

Best regards!

 

Salas.

 

 

1,317 Views
Bruno_Eztronic
Contributor I

Hello @Alejandro_Salas ,

Yes this helped me a lot. Your example worked perfectly. But it's important to mention that when you're working on a system that runs Linux on the main processor and you try use the GPIO interrupts on the M4 core you can face some issues and conflicts.

Best Regards,

 

Bruno