i.mx8mq M4 GPIO interrupt setting

cancel
Showing results for 
Search instead for 
Did you mean: 

i.mx8mq M4 GPIO interrupt setting

162 Views
Contributor I

將GPIO2_PIN20設為Input,也有將中斷開啟,可以讀到輸入腳位接收到的狀態,但是進不了中斷,不清楚那邊有設錯或是沒有設定到。

void GPIO2_Combined_16_31_IRQHandler()
{
  PRINTF("\r\n Interrupt\r\n");
}

/*!
 * @brief Main function
 */
int main(void)
{
    gpio_pin_config_t led_config = {kGPIO_DigitalInput, 1, kGPIO_IntRisingEdge};
    BOARD_RdcInit();

    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    BOARD_InitMemory();
    PRINTF("\r\n GPIO Driver example\r\n");
    PRINTF("\r\n The LED is blinking.\r\n");
    GPIO_PinInit(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, &led_config);
    GPIO_PinSetInterruptConfig(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, kGPIO_IntRisingEdge);
    GPIO_PortEnableInterrupts(EXAMPLE_LED_GPIO, 1u << EXAMPLE_LED_GPIO_PIN);

    while(1);

}

0 Kudos
2 Replies

8 Views
Contributor I

HI Sun :

                目前已經可以使用了,

                但還有一個問題,

                請問GPIO1_12中斷在Uboot底下,

                GPIO有變化都可以進入中斷,

                但是A53開始跑BootKernel之後,

                GPIO有變化,

                但 GPIO中斷就不能夠使用,

                查過A53都沒有人使用這隻GPIO

                不清楚是不是A53開始跑BootKernel時要加入什麼指令才可以繼續進入到中斷使用?

0 Kudos

8 Views
NXP TechSupport
NXP TechSupport

Hello Jiaqi,

    你要这样做,打个比方:

#define MY_IRQn GPIO1_Combined_16_31_IRQn
#define MY_GPIO_IRQHandler GPIO1_Combined_16_31_IRQHandler


void MY_GPIO_IRQHandler(void)
{
      PRINTF("\r\n Interrupt\r\n");
}

int main()
{

......

      GPIO_PinInit(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, &led_config);
      GPIO_PinSetInterruptConfig(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, kGPIO_IntRisingEdge);
      GPIO_PortEnableInterrupts(EXAMPLE_LED_GPIO, 1u << EXAMPLE_LED_GPIO_PIN);
      EnableIRQ(MY_IRQn);

......

}

try it , please!

have a nice day!

BR,

Weidong

0 Kudos