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.

TMS320C6678: GPIO interrupt detection from the external hardware.

Part Number: TMS320C6678

Hi TI Team,

We want suggestions on the matrix keypad interface with the GPIO interrupt-based at the TMS320C6678. Because there is low power(1.8V).

If there is any need for additional hardware or IC during the implementation, Please guide us.

Warmest regards,

Krishn Singh Chauhan

  • Krishn Singh Chauhan,

    As a first step, with the following code,

    Check whether the GPIO interrupt works for you. Once works, you can feed the interrupt externally through the matrix keypad interface.

    By this way, you can verify that the GPIO interrupt portion is working on your custom board. And then focus on the matrix keypad.

    #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 <ti/csl/csl_tsc.h> // check the path where the csl_tsc.h is located. Accordingly include the path of the file.
    
    #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;
    
    extern cregister volatile unsigned int TSCL;
    extern cregister volatile unsigned int TSCH;
    /*Throughput calculation initialization */
    
    uint64_t volatile StartTime = 0;
    uint64_t volatile EndTime = 0;
    uint64_t volatile Total_cycle_ticks = 0;
    
    /*Throughput calculation initialization Ends */
    
    
    
    uint32_t utilReadTime32 ()
    {
        uint32_t low = 0;
    
        low = TSCL;
        return low;
    
    }
    
    interrupt void intIsr()
    {
        a = 1;
    
    
    }
    
    uint64_t utilReadTime64 ()
    {
        uint32_t low = 0;
        uint32_t high = 0;
    
        low = TSCL;
        high = TSCH;
        return (_itoll(high,low));
    
    
    }
    
    int main(void)
    {
        int pinNum = 0;
        int bankNum = 0;
    
    
        TSCH = 0;
        TSCL = 0;
        /* Enable the time stamp counter. */
        CSL_tscEnable();
    
    
        /************************************************
         *************** 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
        StartTime = utilReadTime64();
    #endif
        // 3. Wait for entering into ISR
        while(a!=1){}
        EndTime = utilReadTime64();
    
        printf("a = %d\n",a);
        printf("GPIO interrupt occurs\n");
    
    
        Total_cycle_ticks = EndTime - StartTime;
        printf("Started at cpu cycle = %llu cycles \n", StartTime);
        printf("Ended at cpcu cycle = %llu cyclces \n", EndTime);
    
        printf("Total_cpu_cycle = %llu cycles\n", Total_cycle_ticks);
        return 0;
    }
    
     

    Reply me with your results.

    Regards

    Shankari G

  • Hi Shankari G,

    OK, We'll update you soon.

    Warmest regards,

    Krishn Sigh Chauhan

  • Hi Shankari G,

    PFA for the same.

     

    Warmest regards,

    Krishn Sigh Chauhan

  • Hi,

    Very Good progress....

    Now try with the matrix keypad and check whether the interrupt occurs in GPIO.

    I mean now, trigger the GPIO interrupt externally using your matrix keypad by just modifying the same code.

    Regards

    Shankari G

  • Hi,

    Thanks for your support.

    Warmest regards,

    Krishn Sigh Chauhan