GPIO Interrupt on MIMX8X imx8dx

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

GPIO Interrupt on MIMX8X imx8dx

Jump to solution
1,543 Views
Cillex
Contributor I

Hello,

I am currently trying to get a photo array running on an IMX8DX. (I am using SDK_2_9_0_MIMX8UX5xxxFZ)

For that i need a PWM (currently build via TPM) and falling edge detection.

My plan would be to use a GPIO as INPUT, in mode: falling edge detection (as example: H14 -> LSIO.GPIO4.IO04) connected to the PWM PIN, but I don't understand how to correctly setup the Interrupt of the GPIO.

Can someone help me with an example?

My current (not working) solution:

@main.c

#define PWM_INTERRUPT_GPIO                LSIO__GPIO4
#define PWM_INTERRUPT_GPIO_PIN         4U
#define PWM_INTERRUPT_GPIO_IRQ        LSIO_GPIO_INT0_IRQn
#define PWM_INTERRUPT_GPIO_IRQ_HANDLER_FUNC        PWM_INTERRUPT_HANDLER

void PWM_INTERRUPT_HANDLER(void)
{
      GPIO_ClearPinsInterruptFlags(PWM_INTERRUPT_GPIO, 1U); //mask?
      PRINTF("INSIDE GPIO INTERRUPT\n\r");

      SDK_ISR_EXIT_BARRIER; //PREDEFINED: Fix for interrupt too slow for clock
}

 

int main(void)

{

      sc_ipc_t ipc;
      ipc = BOARD_InitRpc();
      BOARD_InitPins(ipc);
      BOARD_BootClockRUN();
      BOARD_InitDebugConsole();
      BOARD_InitMemory();

      gpio_pin_config_t pwm_int_config = {kGPIO_DigitalInput, 0, kGPIO_IntFallingEdge};

      sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_0,  SC_PM_PW_MODE_ON);
      EnableIRQ(PWM_INTERRUPT_GPIO_IRQ); //How to connect GPIO to corr IRQ?

      GPIO_PinInit(PWM_INTERRUPT_GPIO, PWM_INTERRUPT_GPIO_PIN, &pwm_int_config);

       GPIO_PortEnableInterrupts(PWM_INTERRUPT_GPIO, 1U <<          PWM_INTERRUPT_GPIO_PIN); //How to correctly enable?

 

@pin_mux.h

/* PWM_INTERRUPT_GPIO at GPIO133 corresponding with H14 ALT4*/
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_GPIO LSIO_GPIO4
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_GPIO_PIN 4U
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_NAME USB_SS3_TC1
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_FUNCTION_ID SC_P_USB_SS3_TC1
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_LABEL "PWM_INTERRUPT_SODIMM_133"
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_NAME "PWM_INTERRUPT_SODIMM_133"

 

@pin_mux.c

err = sc_pad_set_all(ipc, BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_FUNCTION_ID, 4U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);
if (SC_ERR_NONE != err)
{
     assert(false);
}

0 Kudos
Reply
1 Solution
1,512 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport
Hi @Cillex ,

I hope you are doing well.

Please add power mode for SC_R_GPIO_4 resource using sc_pm_set_resource_power_mode().

=>Please initializes IRQSteer with GPIO interrupt.

IRQSTEER_Init(IRQSTEER);
IRQSTEER_EnableInterrupt(IRQSTEER, LSIO_GPIO_INT4_IRQn);
NVIC_EnableIRQ(IRQSTEER_2_IRQn);

GPIO_PinSetInterruptConfig(LSIO__GPIO4,PWM_INTERRUPT_GPIO_PIN,kGPIO_IntRisingEdge);

GPIO_EnableInterrupts(LSIO__GPIO4, 1U << PWM_INTERRUPT_GPIO_PIN);

EnableIRQ(LSIO_GPIO_INT0_IRQn);


Please make sure PWM_INTERRUPT_HANDLER is defined as below.
#define PWM_INTERRUPT_HANDLER LSIO_GPIO_INT4_IRQHandler
 
Thanks & Regards,
Sanket Parekh

View solution in original post

0 Kudos
Reply
4 Replies
1,513 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport
Hi @Cillex ,

I hope you are doing well.

Please add power mode for SC_R_GPIO_4 resource using sc_pm_set_resource_power_mode().

=>Please initializes IRQSteer with GPIO interrupt.

IRQSTEER_Init(IRQSTEER);
IRQSTEER_EnableInterrupt(IRQSTEER, LSIO_GPIO_INT4_IRQn);
NVIC_EnableIRQ(IRQSTEER_2_IRQn);

GPIO_PinSetInterruptConfig(LSIO__GPIO4,PWM_INTERRUPT_GPIO_PIN,kGPIO_IntRisingEdge);

GPIO_EnableInterrupts(LSIO__GPIO4, 1U << PWM_INTERRUPT_GPIO_PIN);

EnableIRQ(LSIO_GPIO_INT0_IRQn);


Please make sure PWM_INTERRUPT_HANDLER is defined as below.
#define PWM_INTERRUPT_HANDLER LSIO_GPIO_INT4_IRQHandler
 
Thanks & Regards,
Sanket Parekh
0 Kudos
Reply
1,505 Views
Cillex
Contributor I

Hi @Sanket_Parekh

 

Thank you very much for your help.

I got it working like that and the interrupt works now as intended.

 

I still ave a few other questions on PWMs/TPMs and multi Channel ADC but I will open new topics since it doesn't belong here.

 

Best Regards, 

Cillex

0 Kudos
Reply
1,477 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Cillex ,

I hope you are doing well.

As the issue seems resolved, can I mark this case as close?

Thanks & Regards,
Sanket Parekh

0 Kudos
Reply
1,439 Views
Cillex
Contributor I

Yes, thank you very much

0 Kudos
Reply