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.

C6678 - GPIO interrupt

Hi Champs,

I'd like to clarify the following situation. I have configured GPIO for external interrupt generation. Therefore the GPIO pin needs to be configured as input. Now the User's guide states the following:

" The direction of the GPIO pin does not need to be input when using the pin to generate
the interrupt and EDMA event. When the GPIO pin is configured as input, transitions
on the pin trigger interrupts and EDMA events. When the GPIO pin is configured as
output, software can toggle the GPIO output register to change the pin state and in turn
trigger the interrupt and EDMA event.
"

Now my question is if I configure the GPIO pin as output does it output buffer actually drive high/low?

Background is that the GPIO pin used for interrupt generation will be connected to a MCU/FPGA's output on the board, which means if you want to trigger the GPIO interrupt from the DSP itself like described in the User's Guide you'd potentially have two outputs driving against each other.

Kind regards,
one and zero

  • Hi One and Zero,

    I am working with experts to answer this post. Thank you for your patience.

     

  • Hi,

    Please take a look at below thread, here the reference code is provided for GPIO out is used for interrupt.

    http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/160712/586767.aspx#586767

    Thanks,

  • Hi Ganapathi,


    that doesn't answer my question. It's clear how to configure the GPIO's for interrupt. The question is about the behavior of the pin in case the it's configured as an output. As already pointed out the User's Guide explains software can toggle the GPIO output register to change the pin state and in turn trigger the interrupt and EDMA event."

    Question: If I configure the GPIO pin as output in 'interrupt mode' (BINTEN = 1) does the output buffer actually drive high/low?

    Kind regards,

    one and zero

  • Hi,

    The output buffer can be driven high as well as low in interrupt mode (BINTEN = 1). We have tested both conditions, refer below test code.

    #include "ti/csl/csl_chip.h"
    #include "ti/csl/csl_chipAux.h"
    #include "ti/csl/src/intc/csl_intc.h"
    #include "ti/csl/csl_gpio.h"
    #include "ti/csl/csl_gpioAux.h"
    
    #include <stdio.h>
    
    CSL_IntcContext             intcContext;
    CSL_IntcEventHandlerRecord  EventHandler[30];
    CSL_IntcObj                 intcObj;
    CSL_IntcHandle              hTest;
    CSL_IntcGlobalEnableState   state;
    CSL_IntcEventHandlerRecord  EventRecord;
    CSL_IntcParam               vectId;
    
    CSL_GpioHandle  hGpio;
    
    
    volatile int a = 0;
    
    interrupt void intIsr()
    {
    	a = 1;
    
    }
    
    int main(void)
    {
    	int pinNum = 0;
    	int bankNum = 0;
    
        /************************************************
         *************** INTC Configuration *************
         ************************************************/
    
        printf ("Debug: GEM-INTC Configuration...\n");
    
        /* INTC module initialization */
        intcContext.eventhandlerRecord = EventHandler;
        intcContext.numEvtEntries      = 10;
        if (CSL_intcInit(&intcContext) != CSL_SOK)
        {
            printf("Error: GEM-INTC initialization failed\n");
            return 0;
        }
    
        /* Enable NMIs */
        if (CSL_intcGlobalNmiEnable() != CSL_SOK)
        {
            printf("Error: GEM-INTC global NMI enable failed\n");
            return 0;
        }
    
        /* Enable global interrupts */
        if (CSL_intcGlobalEnable(&state) != CSL_SOK)
        {
            printf ("Error: GEM-INTC global enable failed\n");
            return 0;
        }
    
        /* Open the INTC Module for Vector ID: 4 and Event ID: 90 (GPIO_n in C6678)*/
        vectId = CSL_INTC_VECTID_4;
        hTest = CSL_intcOpen (&intcObj, 90, &vectId , NULL);
        if (hTest == NULL)
        {
            printf("Error: GEM-INTC Open failed\n");
            return 0;
        }
    
        /* Register an call-back handler which is invoked when the event occurs. */
        EventRecord.handler = &intIsr;
        EventRecord.arg = 0;
        if (CSL_intcPlugEventHandler(hTest,&EventRecord) != CSL_SOK)
        {
            printf("Error: GEM-INTC Plug event handler failed\n");
            return 0;
        }
    
        /* Enabling the events. */
        if (CSL_intcHwControl(hTest,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK)
        {
            printf("Error: GEM-INTC CSL_INTC_CMD_EVTENABLE command failed\n");
            return 0;
        }
    
        printf ("Debug: GEM-INTC Configuration Completed\n");
    
    
    	// 1. Init Flag
    	a = 0;
    	printf("a = %d\n",a);
    
    	// 2. Trigger GPIO_0 in Core0
    	pinNum = 0;
    	bankNum = 0;
    
    	// Open the CSL GPIO Module 0
    	hGpio = CSL_GPIO_open (0);
    
    	// Set GPIO pin number 0 as an output pin
    	CSL_GPIO_setPinDirOutput (hGpio, pinNum);
    #if 0
    	// Set interrupt detection on GPIO pin 0 to rising edge
        CSL_GPIO_setRisingEdgeDetect (hGpio, pinNum);
    #else
    	// Set interrupt detection on GPIO pin 0 to rising edge
        CSL_GPIO_setFallingEdgeDetect (hGpio, pinNum);
    #endif
        // Enable GPIO per bank interrupt for bank zero
        CSL_GPIO_bankInterruptEnable (hGpio, bankNum);
    #if 0
        // Toggle GPIO_0 pin to trigger GPIO interrupt
        CSL_GPIO_clearOutputData (hGpio, pinNum);	//GPIO_0=0
        CSL_GPIO_setOutputData (hGpio, pinNum);		//GPIO_0=1
    #else
        // Toggle GPIO_0 pin to trigger GPIO interrupt
        CSL_GPIO_setOutputData (hGpio, pinNum);		//GPIO_0=1
        CSL_GPIO_clearOutputData (hGpio, pinNum);	//GPIO_0=0
    #endif
    	// 3. Wait for entering into ISR
    	while(a!=1){}
    
    
    	printf("a = %d\n",a);
    	printf("GPIO interrupt occurs\n");
    
    	return 0;
    }
    
    

    Thanks,

  • Hi Ganapathi,

    thanks for confirming.

    That makes the feature basically useless for most part. If you have designed your board in a way that a GPIO pin should serve as an interrupt input it means your GPIO pin is connected to an output. Now if you want to test your SW without having the external pin triggering you can't use the feature (of triggering the interrupt by SW) because an output would be driving against an output.

    Kind regards,

    one and zero