This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/OMAP-L138: GPIO interrupt issue

Part Number: OMAP-L138


Tool/software: TI-RTOS

Hello,

I use pdk 1_0_6 and I know GPIO_LedBlink exmaple but I have problem with GPIO interrupt when I should use more then 1 input pin to interrupt:

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <stdio.h>

#include <ti/board/board.h>
#include <ti/drv/gpio/GPIO.h>
#include <ti/drv/gpio/soc/GPIO_soc.h>

#include "usm_gpio.h"

/**********************************************************************
 ************************** GPIO  *************************************
 **********************************************************************/
/* GPIO Driver board specific pin configuration structure */
GPIO_PinConfig gpioPinConfigs[] =
{
    //MMCSD
    GPIO_DEVICE_CONFIG(GPIO_MMC_SDCD_PORT_NUM, GPIO_MMC_SDCD_PIN_NUM) | GPIO_CFG_IN_INT_BOTH_EDGES | GPIO_CFG_INPUT,
    //BUZZER
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_BUZZER_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    //LED_ARRX
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_LED_EXT0_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_LED_EXT1_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_LED_EXT2_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_LED_EXT4_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_LED_EXT5_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    //S4 ->SW1-SW6
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW1_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_INPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW2_PIN_NUM) | GPIO_CFG_IN_INT_BOTH_EDGES| GPIO_CFG_INPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW3_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_INPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW4_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_INPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW5_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_INPUT,
    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW6_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_INPUT,
};

/* GPIO Driver call back functions */
GPIO_CallbackFxn gpioCallbackFunctions[] =
{
    //MMCSD
    AppGpioCallbackFxn,
    //BUZZER
    NULL,
    //LED_ARRX
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    //S4 ->SW1-SW6
NULL, AppGpioCallbackFxn2, NULL, NULL, NULL, NULL, }; GPIO_v0_Config GPIO_v0_config = { gpioPinConfigs, gpioCallbackFunctions, sizeof(gpioPinConfigs) / sizeof(GPIO_PinConfig), sizeof(gpioCallbackFunctions) / sizeof(GPIO_CallbackFxn), 0, }; void usm_board_initGPIO(void) { GPIO_v0_HwAttrs gpio_cfg; /* Get the default SPI init configurations */ GPIO_socGetInitCfg(GPIO_MMC_SDCD_PORT_NUM, &gpio_cfg); /* Modify the default GPIO configurations if necessary */ //***/ /* Set the default GPIO init configurations */ GPIO_socSetInitCfg(GPIO_MMC_SDCD_PORT_NUM, &gpio_cfg); /* Setup GPIO interrupt configurations */ GPIO_socSetBankInt(GPIO_MMC_SDCD_PORT_NUM, GPIO_MMC_SDCD_PIN_NUM, NULL); GPIO_socSetBankInt(GPIO_MMC_SDCD_PORT_NUM, GPIO_S4_SW2_PIN_NUM, NULL); /* GPIO initialization */ GPIO_init(); /* Enable GPIO interrupt on the specific gpio pin */ GPIO_enableInt(GPIO_PIN_MMC_SDCD); GPIO_enableInt(GPIO_PIN_S4_SW2); }

AppGpioCallbackFxn and AppGpioCallbackFxn2 I have in other file but intterupt form GPIO_PIN_MMC_SDCD is correct but GPIO_PIN_S4_SW2 not interrupt...
When I changed the order in gpioPinConfigs this works correctly GPIO_PIN_S4_SW2 abut not GPIO_PIN_MMC_SDCD ...

When I checked in GPIO Interrupt Status the interrupt status is 1.
Where is the problem?

Best regards,
Patryk

  • Hello Patryk,

    Did you set the callback function using GPIO_setCallback()? For example,

    GPIO_setCallback(GPIO_PIN_S4_SW2, AppGpioCallbackFxn2);

    EDIT: Nevermind, just saw that you are statically configuring it in the GPIO_CallbackFxn array.

  • Yes, I tried but it did not change anything.

  • What port # is GPIO_MMC_SDCD_PORT_NUM? I see that you are using GPIO_PORT_NUM0 here,

    GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW2_PIN_NUM)

    but GPIO_MMC_SDCD_PORT_NUM here,

    GPIO_socSetBankInt(GPIO_MMC_SDCD_PORT_NUM, GPIO_S4_SW2_PIN_NUM, NULL);
    

  • Yes, I used different definitions but GPIO_PORT_NUM0 = 0 and GPIO_MMC_SDCD_PORT_NUM also = 0

  • You are missing one NULL entry in the GPIO_CallbackFxn array. Due to this, the callback function for GPIO_S4_SW2_PIN_NUM is set to NULL.

  • Thanks Sahin but I think that I made the mistake while editing the text.

    I will check tomorrow and I will write the result here.

  • Hello,

    I checked my code and this didn't solve the problem.

    /* GPIO Driver board specific pin configuration structure */
    GPIO_PinConfig gpioPinConfigs[] =
    {
        //MMCSD
        GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_S4_SW2_PIN_NUM) | GPIO_CFG_IN_INT_BOTH_EDGES | GPIO_CFG_INPUT,
        GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_MMC_SDCD_PIN_NUM) | GPIO_CFG_IN_INT_BOTH_EDGES | GPIO_CFG_INPUT,
        GPIO_DEVICE_CONFIG(GPIO_PORT_NUM0, GPIO_BUZZER_PIN_NUM) | GPIO_CFG_IN_INT_NONE | GPIO_CFG_OUTPUT,
    };
    
    /* GPIO Driver call back functions */
    GPIO_CallbackFxn gpioCallbackFunctions[] =
    {
        AppGpioCallbackFxn,
        AppGpioCallbackFxn
    };
    
    GPIO_v0_Config GPIO_v0_config =
    {
        gpioPinConfigs,
        gpioCallbackFunctions,
        sizeof(gpioPinConfigs) / sizeof(GPIO_PinConfig),
        sizeof(gpioCallbackFunctions) / sizeof(GPIO_CallbackFxn),
        0,
    };
    
    void usm_board_initGPIO(void)
    {
    
        GPIO_v0_HwAttrs gpio_cfg;
        /* Get the default SPI init configurations */
        GPIO_socGetInitCfg(GPIO_PORT_NUM0, &gpio_cfg);
        /* Modify the default GPIO configurations if necessary */
        //***/
        /* Set the default GPIO init configurations */
        GPIO_socSetInitCfg(GPIO_PORT_NUM0, &gpio_cfg);
        /* Setup GPIO interrupt configurations */
        GPIO_socSetBankInt(GPIO_PORT_NUM0, GPIO_MMC_SDCD_PIN_NUM, NULL);
        GPIO_socSetBankInt(GPIO_PORT_NUM0, GPIO_S4_SW2_PIN_NUM, NULL);
    
        /* GPIO initialization */
        GPIO_init();
        /* Enable GPIO interrupt on the specific gpio pin */
        GPIO_enableInt(GPIO_PIN_MMC_SDCD);
        GPIO_enableInt(GPIO_PIN_S4_SW2);
    
    }

    When I changed the order in gpioPinConfige and changed GPIO_PIN_MMC_SDCD and GPIO_PIN_S4_SW2 index I noticed that the index 0 interrupt always works correctly. The rest of the indexes don't work. But in GPIO Interrupt Status Register it is visible.

    Regards,

    Patryk

  • Hi Patryk,

    I'm sorry for the delay here. Were you able to resolve this or do you still need help with this issue?

  • Hi Sahin,

    I solved this issue, probably I had bug in my cod. Thank you for your support.

    Regards,

    Patryk