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.

6678 interrupt in CSL

Other Parts Discussed in Thread: TMS320C6678

Hi,

I am trying to configure a interrupt of GPIO in CSL , but i do not how to do it. There is a example ?

Best regards!

bin chen

  • Bin,

    I put together one example test case (attached below) for the GPIO and CorePac INTC configuration for the GPIO interrupt.

    Please include both "ti.csl.ae66" and "ti.csl.intc.ae66" libraries in your project.

    Please refer to the CPINTC example in the C6678 CSL package "\pdk_C6678_1_0_0_17\packages\ti\csl\example\cpintc". It has the example of CorePac INTC setup and chip-level interrupt controller setup (which may not apply to GPIO example, but good for others).

    Please also refer to the CSL document as "csldocs.chm" in "\pdk_C6678_1_0_0_17\packages\ti\csl\docs".

    GPIO and CorePac user's guides are also good references.

    4214.main.zip

    Sincerely,

    Steven

  • Hello,

    Steven

    Thanks very much for your help!  my code is working now.

    But how can i get the  gpio pins state in ISR  when i set the gpio pins as input

    sincerely

    Bin

  • Bin,

    When GPIO pin is as input, you can get the state using the following CSL:

    CSL_IDEF_INLINE void CSL_GPIO_getInputData ( CSL_GpioHandle  hGpio,
    Uint8  pinNum,
    Uint8 *  inData  
    )

    Or you can just read the Input Data Register (IN_DATA) mentioned in the GPIO user's guide for the status of the corresponding GPIO pins.

    Sincerely,

    Steven

  • Hello,

    Steven

    Thanks very much for your help!  my code is working now.

    sincerely

    Bin

  • Hi,

    I follow the procedures above for producing gpio interrupt. But my code is stalling. When I pause it is running somewhere in _csl_intcIsrDispact.asm.

    Do you have any suggestion?

    Best Regards. 

  • Are you running the same code attached above on C6678 or do you have any modifications please?

  • Hi, My name is Ryan.

    I have a question about triggering gpio 15.

    I got a reference code from this forum and It works, definitely with gpio 0 the code i attached below.

    But, I just want to trigger the gpio 15. it doesn't work now.

    How to change this code for triggering gpio 15?

    For example, do I have to change the event id or vectid so on... ? where do I have to check such as which data sheets?

    Please check it out for me.

    Thanks a lot.

    -----------------------------------------------------------------------------------------------------------------

    #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;

    return ;
    }

    void main(void)
    {
    //GpioInit(); //GPIO Initialization
    int pinNum;
    int bankNum;

    /************************************************
    *************** 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;
    }

    /* Enable NMIs */
    if (CSL_intcGlobalNmiEnable() != CSL_SOK)
    {
    printf("Error: GEM-INTC global NMI enable failed\n");
    return;
    }

    /* Enable global interrupts */
    if (CSL_intcGlobalEnable(&state) != CSL_SOK)
    {
    printf ("Error: GEM-INTC global enable failed\n");
    return;
    }

    /* Open the INTC Module for Vector ID: 4 and Event ID: 90 (GPIO_n in C6678)*/
    vectId = CSL_INTC_VECTID_4;   // <=== do I have to change this for testing gpio 15 instead of gpio 0?
    hTest = CSL_intcOpen (&intcObj, 90, &vectId , NULL); //  <=== do I have to change this event id(90) for testing gpio 15 instead of gpio 0?
    if (hTest == NULL)
    {
    printf("Error: GEM-INTC Open failed\n");
    return;
    }

    /* 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;
    }

    /* 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;
    }

    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);

    // Set interrupt detection on GPIO pin 0 to rising edge
    CSL_GPIO_setRisingEdgeDetect (hGpio, pinNum);

    // Enable GPIO per bank interrupt for bank zero
    CSL_GPIO_bankInterruptEnable (hGpio, bankNum);

    // Toggle GPIO_0 pin to trigger GPIO interrupt
    CSL_GPIO_clearOutputData (hGpio, pinNum); //GPIO_0=0
    CSL_GPIO_setOutputData (hGpio, pinNum); //GPIO_0=1


    // 3. Wait for entering into ISR
    while(a!=1){}


    printf("a = %d\n",a);
    printf("GPIO interrupt occurs\n");

    return 0;

  • Ryan,

    You do not need to change the vectID, which is the input of the CorePac interrupt controller.

    But you need to change the system event interrupt ID (event ID) from 90 (GPINTn) to 89 (GPINT15) below:

    hTest = CSL_intcOpen (&intcObj, 89, &vectId , NULL);

    Please refer to System Event Mapping table of C66x CorePac (table 7-38) in C6678 data manual Rev.F.

    And you can also update the pin number from 0 to 15 as well for the GPIO configuration:

    pinNum = 15;


  • Hi,

    I have followed the example given and i am getting expected output, but when i want to set or clear other Gpio pin(like pin 1) it is affecting the interrupt which should only trigger  on Gpio0.

    Here is my 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 "emifa.h"
    #include "system_init.h"
    #include "pll.h"
    Bool Core0_init(void);

    #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 intIsr1()
    {
    unsigned chipID=0;
    Uint32 internalAddress = 0;
    EMIFA_runTest();
    a=2;
    //EMIFA_read(chipID, internalAddress);

    return ;
    }

    int main(void)
    {
    int pinNum = 0;
    int bankNum = 0;

    Core0_init();


    /************************************************
    *************** INTC Configuration *************
    ************************************************/


    printf ("Debug: GEM-INTC Configuration...\n");

    /* INTC module initialization */
    intcContext.eventhandlerRecord = EventHandler;
    intcContext.numEvtEntries = 10;
    CSL_intcInit(&intcContext);

    /* Enable NMIs */
    CSL_intcGlobalNmiEnable() ;

    /* Enable global interrupts */
    CSL_intcGlobalEnable(&state) ;

    /* 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);


    /* Register an call-back handler which is invoked when the event occurs. */
    EventRecord.handler = &intIsr1;
    EventRecord.arg = 0;
    CSL_intcPlugEventHandler(hTest,&EventRecord) ;

    /* Enabling the events. */
    CSL_intcHwControl(hTest,CSL_INTC_CMD_EVTENABLE, NULL) ;

    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);

    // Set interrupt detection on GPIO pin 0 to rising edge
    CSL_GPIO_setRisingEdgeDetect (hGpio, pinNum);

    // Enable GPIO per bank interrupt for bank zero
    CSL_GPIO_bankInterruptEnable (hGpio, bankNum);

    // Toggle GPIO_0 pin to trigger GPIO interrupt
    CSL_GPIO_clearOutputData (hGpio, pinNum); //GPIO_0=0
    CSL_GPIO_setOutputData (hGpio, pinNum); //GPIO_0=1

    // Toggle GPIO_1 pin to trigger GPIO interrupt
    CSL_GPIO_clearOutputData (hGpio, 1); //GPIO_1=0
    CSL_GPIO_setOutputData (hGpio, 1); //GPIO_1=1


    // 3. Wait for entering into ISR
    while(a!=2){}
    CSL_GPIO_clearOutputData (hGpio, 0); //GPIO_0=0

    printf("a = %d\n",a);


    printf("GPIO interrupt occurs\n");

    return 0;
    }

    Bool Core0_init(void) {

    printf("Hello, I am core 0 and about the initialize the processor\r\n");
    PLL_init(COREPAC_FREQ_1000MHZ);
    system_init();

    EMIFA_init();

    printf("Status: init\n");
    regs_setStatusInit();
    return TRUE;
    }

  • Hi,

    In C6678 DSP CorePac[n] will receive GPINTn(Defaultly configure CorePac[n] to GPINTn). eg: corepac0 will receive GPINT0, corepac1 will receive GPINT1.

    You are not able to configure GPINT1 to corepac0. If you want to use another configure GPINT to corepack0 means Please use Local GPIO interrupt (GPINT8-GPINT15). This Local GPIO interrupt are not defaltly confiure for specific corepack.

    Thanks,

  • For more information refer section 7.9 Interrupts and Table 7-38 TMS320C6678 System Event Mapping — C66x CorePac Primary Interrupts (Part 3 of 4) on C6678 data manual(SPRS691C).

    Thanks,

  • Hi,

    Thank you very much, i will try with gpio8 pin.

    Regards,

    Vamshi

  • Hi,

    I am not configuring Gpio1 pin for interrupt to corepac0 but i want to send some signal on Gpio1 pin which should not interefere with interrupt to corepac0.

    Regards,

    Vamshi

  • Hi,

    You able to configure GPIO1 as input/output pin for corepack0.

    In your code you did not set the GPIO1 pin direction that only the GPIO1 trigger is not working. Set GPIO1 pin direction on your test code and the toggle the GPIO1 pin

    // Set GPIO pin number 1 as an output pin
    CSL_GPIO_setPinDirOutput (hGpio, 1);

    // Toggle GPIO_1 pin
    CSL_GPIO_clearOutputData (hGpio, 1); //GPIO_1=0

    Add some delay hare


    CSL_GPIO_setOutputData (hGpio, 1); //GPIO_1=1

    Thanks,

  • Hi,

    I will elaborate what is the real problem for me:

    1) First problem is: The code is executing continuously in loop i.e., it is not exiting after return 0.

    2) second problem is: whenever i add following 3 lines execution is not coming out of while loop(which should exit while loop after servicing ISR), instead the execution is starting again from main().

    // Set GPIO pin number 1 as an output pin
    CSL_GPIO_setPinDirOutput (hGpiog, 1);
    // Toggle GPIO_1 pin to trigger GPIO interrupt
    CSL_GPIO_clearOutputData (hGpiog, 1); //GPIO_1=0
    CSL_GPIO_setOutputData (hGpio, 1); //GPIO_1=1

    whenever i remove these 3 lines, execution is exiting while loop as expected and again program is running from the starting of main(). so i am not understanding what is happening when i want to use gpio pin 1 !!

  • Hi,

    I am able to get interrupt on gpio successfully by following the code given here. But i want to have two isr's(interrupt service routines) for two interrupts coming on both gpio0 and gpio15, i am not understanding how to assign isr's to their respective interrupts on gpio pins in the same code. can you help me.

    regards,

    vamshi

  • hi steven,

    can you supply a whole project for GPIO interrupt?
    i have include some libraries, but it still can not pass compile//
  • Refer below thread for examples,
    e2e.ti.com/.../215247
    e2e.ti.com/.../374048
  • hallo raja, thanks for your reply!
    but i mean the whole project. this are only code of main.c.
    i have the problem with the project configuration..so if anyone can provide a whole correct project ,it is very nice and appreciated !
    and the error shows like :

    warning #10210-D: creating ".stack" section with default size of 0x400; use the -stack option to change the default size
    warning #10210-D: creating ".sysmem" section with default size of 0x400; use the -heap option to change the default size


    undefined first referenced
    symbol in file
    --------- ----------------
    CSL_GPIO_open ./main.obj
    CSL_intcGlobalEnable ./main.obj
    >> Compilation failure
    CSL_intcGlobalNmiEnable ./main.obj
    CSL_intcHwControl ./main.obj
    CSL_intcInit ./main.obj
    CSL_intcOpen ./main.obj
    CSL_intcPlugEventHandler ./main.obj

    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "CSL.out" not built


    regrads
  • Hi,

    There is no issue with your project. I think, you have not specified the linker command(.cmd) file to the project. You can find the same in below path test_lnk.cmd (..\ti\pdk_C6678_1_1_2_6\packages\ti\csl\example\timer).

    -c
    
    -heap  0x2000
    
    -stack 0x2000
    
    /* Memory Map 1 - the default */
    
    MEMORY
    
    {
    
           L1D:     o = 00f00000h   l = 00007FFFh
    
           L1P:     o = 00e00000h   l = 00007FFFh
    
           L2:      o = 00800000h   l = 0007FFFFh
    
    }
    
    SECTIONS
    
    {
    
       .csl_vect   >       L2
    
       .text       >       L2
    
       .stack      >       L2
    
       .bss        >       L2
    
       .cinit      >       L2
    
       .cio        >       L2
    
       .const      >       L2
    
       .data       >       L2
    
       .switch     >       L2
    
       .sysmem     >       L2
    
       .far        >       L2
    
       .testMem    >       L2      
    
       .fardata > L2
    
       .neardata   > L2
    
       .rodata     > L2
    
    }

    Please refer below wiki on how to add .cmd to the project.

  • Also make sure to link the CSL libararies (PDK\packages\ti\csl\lib) for building the .out file,


    Thank you.

  • thanks man!

    it works now, but do you know where i can find a proper CMD file for my project?
    it seems that my cmd files of other project does not works for this one.
  • Glad to hear that the issue is resolved.

    What was causing the issue, Is it CMD file or linking of libraries?

    The CSL example directories has the .cmd files.
    PATH: C:\ti\pdk_C6678_1_1_2_6\packages\ti\csl\example\timer

    Thank you.
  • it is the library !
    now this code works with several warnings, but it doesn't matter
    e.g.

    Description Resource Path Location Type
    #118-D non-void function "main" should return a value main.c /CSL line 48 C/C++ Problem

    Description Resource Path Location Type
    #515-D a value of type "void (*)()" cannot be assigned to an entity of type "CSL_IntcEventHandler" main.c /CSL line 75 C/C++ Problem


    thanks man ! you are so kind !