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.

TDA4VM: How to implement GPIO interrupt function on TDA4VM?

Part Number: TDA4VM
Other Parts Discussed in Thread: SYSCONFIG

Hello, I want to implement the GPIO interrupt function on the R5F MCU of the main domain on TDA4VM. My version info is:
Linux: ti-processor-sdk-linux-j7-evm-08_02_00_03-Linux-x86-Install.bin
RTOS: ti-processor-sdk-rtos-j721e-evm-08_02_00_05.tar.gz

Question 1:
If the GPIO belongs to the main domain, how should I configure it?
Here I take GPIO0_99(w23) and GPIO0_100(W28) as examples, and make the following configuration:
Step 1: Generate the following configuration through sysconfig_gui:
/* MyGPIO1 -> GPIO0_99 -> W23 */
{
PIN_RGMII6_TD3, PIN_MODE(7) | ((PIN_PULL_DISABLE | PIN_INPUT_ENABLE) & ~PIN_PULL_DIRECTION))
},
/* MyGPIO1 -> GPIO0_100 -> W28 */
{
PIN_RGMII6_TD2, PIN_MODE(7) | ((PIN_PULL_DISABLE | PIN_INPUT_ENABLE) & (~PIN_PULL_DIRECTION))
},

Note: I added the above code to the rtos\pdk_jacinto_08_02_00_21\packages\ti\board\src\j721e_evm\J721E_pinmux_data.c file and made sure that the corresponding GPIO is not used by other peripherals.
Step 2: I configured the GPIO_PinConfig global variable:

#define TEST_GPIO_INT_FUN_W23 (99)
#define TEST_GPIO_INT_FUN_W28 (100)


typedef enum {
ENUM_TEST_GPIO_INT_FUN_W23=0,
ENUM_TEST_GPIO_INT_FUN_W28,
}BOARD_CAMERA_GPIO_CTL;


GPIO_PinConfig gpioPinConfigs[] =
{
GPIO_DEVICE_CONFIG(GPIO_MAIN_DOMAIN_0, TEST_GPIO_INT_FUN_W23) | GPIO_CFG_IN_INT_RISING | GPIO_CFG_INPUT,
GPIO_DEVICE_CONFIG(GPIO_MAIN_DOMAIN_0, TEST_GPIO_INT_FUN_W28) | GPIO_CFG_IN_INT_RISING | GPIO_CFG_INPUT,
};

GPIO_CallbackFxn gpioCallbackFunctions[] =
{
NULL,
NULL
};


GPIO_v0_Config GPIO_v0_config =
{
gpioPinConfigs,
gpioCallbackFunctions,
sizeof(gpioPinConfigs) / sizeof(GPIO_PinConfig),
sizeof(gpioCallbackFunctions) / sizeof(GPIO_CallbackFxn),
0x8U
};

void AppGpioCallbackFxn_W23(void)
{
printf("%s %s %d\n", __FILE__, __func__, __LINE__);
}
void AppGpioCallbackFxn_W28(void)
{
printf("%s %s %d\n", __FILE__, __func__, __LINE__);
}

Step 3: Call the API for initialization
Board_initCfg boardCfg;
boardCfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_UART_STDIO | BOARD_INIT_MODULE_CLOCK;
Board_init(boardCfg);
GPIO_init();
GPIO_setCallback(ENUM_TEST_GPIO_INT_FUN_W23, AppGpioCallbackFxn_W23);
GPIO_setCallback(ENUM_TEST_GPIO_INT_FUN_W28, AppGpioCallbackFxn_W28);
GPIO_enableInt(ENUM_TEST_GPIO_INT_FUN_W23);
GPIO_enableInt(ENUM_TEST_GPIO_INT_FUN_W28);

After completing the above steps, I gave a 25Hz PWM pulse to GPIO0_99(w23) and GPIO0_100(W28), but the corresponding GPIO interrupt did not respond. What is wrong with my configuration?

Question 2:
If the GPIO belongs to the wkup domain, how should I configure it?

  • Hi qidong liu,

    I think you would have to change SoC Config and provide GPIO0 base address (GPIO_socGetInitCfg and GPIO_socSetInitCfg).. Then you also have to configure GPIO interrupt. 

    I would suggest to refer to the PDK example in ti-processor-sdk-rtos-j721e-evm-08_02_00_05\pdk_jacinto_08_02_00_21\packages\ti\drv\gpio\test\led_blink\src\main_led_blink.c and make similar changes for GPIO0. 

    I would also suggest search on the TI e2e forum, you could find many references for GPIO interrupt implementation. 

    Regards,

    Brijesh 

  • Hello, the code above is based on ti-processor-sdk-rtos-j721e-evm-08_02_00_05\pdk_jacinto_08_02_00_21\packages\ti\drv\gpio\test\led_blink\src\main_led_blink.c and the information on the TI E2E forum written. But now my GPIO interrupt is still not working. Please help to confirm, what is wrong with my configuration above?

  • The code in ti-processor-sdk-rtos-j721e-evm-08_02_00_05\pdk_jacinto_08_02_00_21\packages\ti\drv\gpio\test\led_blink\src\main_led_blink.c, I see the feedback on the TI E2E forum is running on MCU1_0 . I now want to implement GPIO interrupts on mcu2_0 above the main domain. I don't understand the interrupt routing relationship in the middle. Do you have a more intuitive demo?

  • I think there are many missing points, like you are not changing GPIO0 base address using get/set Soc Config. Also you are not configuring interrupt. 

    So please go through this example and call these missing APIs.

    Regards,

    Brijesh

  • Hello, if I want to configure the interrupt function of GPIO0_99, how should I set the idx of GPIO_socGetInitCfg? During the configuration process, is the baseAddr in the GPIO_v0_HwAttrs structure corresponding to the idx of GPIO_socGetInitCfg? Taking GPIO0_99 as an example, how should the variables in GPIO_IntCfg be configured?

  • //Configure GPIO0_99(W23) as interrupt
    typedef enum {
        ENUM_TEST_GPIO_INT_FUN_W23 = 0,
    }GPIO_CTL;
    
    GPIO_PinConfig gpioPinConfigs[] =
    {
        GPIO_DEVICE_CONFIG(0, 99) | GPIO_CFG_IN_INT_BOTH_EDGES | GPIO_CFG_INPUT,
    };
    
    GPIO_CallbackFxn gpioCallbackFunctions[] =
    {
        NULL,
    };
    
    GPIO_v0_Config GPIO_v0_config =
    {
        gpioPinConfigs,
        gpioCallbackFunctions,
        sizeof(gpioPinConfigs) / sizeof(GPIO_PinConfig),
        sizeof(gpioCallbackFunctions) / sizeof(GPIO_CallbackFxn),
        0x8U
    };
    
    app_init()
    {
    	boardCfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_UART_STDIO | BOARD_INIT_MODULE_CLOCK;  
        Board_init(boardCfg);
    	int pinNum = 99;
    	int bankNum = pinNum/16;									//bankNum=99/16	Is this calculation correct?
        GPIO_v0_HwAttrs gpio_cfg;
        GPIO_socGetInitCfg(bankNum, &gpio_cfg);    					//The idx here uses the bankNum variable, is that correct?
        gpio_cfg.baseAddr = CSL_GPIO6_BASE;    						//How should the baseAddr be determined here?
    	gpio_cfg.intCfg[pinNum].intNum = 256 + bankNum;				//How to determine the intNum here?
        gpio_cfg.intCfg[pinNum].intcMuxNum = INVALID_INTC_MUX_NUM;	//How to determine the intcMuxNum here?
        gpio_cfg.intCfg[pinNum].intcMuxInEvent = 0;					//How to determine the intcMuxInEvent here?
        gpio_cfg.intCfg[pinNum].intcMuxOutEvent = 0;				//How to determine the intcMuxOutEvent here?
    	GPIO_socSetInitCfg(bankNum, &gpio_cfg);						//The idx here uses the bankNum variable, is that correct?
    	GPIO_init();
        GPIO_setCallback(ENUM_TEST_GPIO_INT_FUN_W23, AppGpioCallbackFxn_W23);
        GPIO_enableInt(ENUM_TEST_GPIO_INT_FUN_W23);
    }

    This is my configuration code, please help to check where is the configuration problem? Regarding the determination of variable values in the code, please help to explain.

  • Hi qidong liu,

    Any further update/questions on this ticket? 

    Regards,

    Brijesh