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.

C6748 LCDK GPIO Interrupt service routine

Hello.

I possess C6748 LCDK board, CCS5v3 and bios_c6sdk_02_00_00_00.

I don ´t have much experiences with LCDK and c.

I modifyed gpio example to connect LEDs with switches. It works.

Now I wish to connect a led with a pushbutton.

My goal is: when I push button for first time, the led is off.

When I push it for second time, the led is on and so on.

I initialize GPIO and wrote this code for led D4 and pushbutton S3:

while(1){

x=GPIOPinRead(SOC_GPIO_0_REGS,38);
        if (x==GPIO_PIN_LOW){
            y++;
            if(y==1){
            GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);
            }
            if (y==2){
            GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);
            y=0;
            }

}

It works, but sometimes the button doesn´ t react on pushing.

I thought, that, it could be solved by interrupt routine:

  interrupt void Button_S3_interrupt(void){
      if(GPIOPinIntStatus(SOC_GPIO_0_REGS, 6)==GPIO_INT_PEND){
          GPIOPinIntClear(SOC_GPIO_0_REGS, 6);
          y++;
            if(y==1){
                      GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);
                      }
            if(y==2){
                      GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);
                      y=0;
                      }


      }


  }

But D4 is always off.

I don´t exactly know, how should Interrupt service routine for C6748 look like and where to specify the interrupt number. Could you write for me the head of typical interrupt service routine and what should be general done in its body?

Thank you.

Petr Duga

  • Hi Petr Duga,

    Have you initialized the interrupt correctly? Please refer the below code snippets.

    GPIO interrupt init code:

    /* Initialize the DSPINTC */
     
    IntDSPINTCInit();
     
    /* Register the GPIO ISR */
     
    IntRegister(C674X_MASK_INTx, GPIOIsr);
     
    /* Map GPIO interrupts to DSP maskable interrupt */
     
    IntEventMap(C674X_MASK_INTx, SYS_INT_GPIO_BxINT);
     
    /* Enable DSP interrupt in DSPINTC */
     
    IntEnable(C674X_MASK_INTx);
     
    /* Enable DSP interrupts */
     
    IntGlobalEnable();
     
    /* Enable the GPIO BANK interrupt */
     
    GPIOBankIntEnable(SOC_GPIO_0_REGS, GPIO_Bx_NUMBER);
    
    /*Configure the GPIO PIN interrupt*/
    
    GPIOIntTypeSet(SOC_GPIO_0_REGS,  pinNumber, GPIO_INT_TYPE_RISEDGE);

    Constants are defined in interrupt.h

    /*CPU maskable interrupt number*/
    #define C674X_MASK_INT4 4
    #define C674X_MASK_INT5 5
    #define C674X_MASK_INT6 6
    #define C674X_MASK_INT7 7
    #define C674X_MASK_INT8 8
    #define C674X_MASK_INT9 9
    #define C674X_MASK_INT10 10
    #define C674X_MASK_INT11 11
    #define C674X_MASK_INT12 12
    #define C674X_MASK_INT13 13
    #define C674X_MASK_INT14 14
    #define C674X_MASK_INT15 15
    
    /*System event number*/
    /*GPIO Interrupts */
    #define SYS_INT_GPIO_B0INT 			65
    #define SYS_INT_GPIO_B1INT 			41
    #define SYS_INT_GPIO_B2INT 			49
    #define SYS_INT_GPIO_B3INT 			52
    #define SYS_INT_GPIO_B4INT 			54
    #define SYS_INT_GPIO_B5INT 			59
    #define SYS_INT_GPIO_B6INT 			62
    #define SYS_INT_GPIO_B7INT 			72
    #define SYS_INT_GPIO_B8INT 			75

    Set the break point inside the ISR and check whether it is getting executed or not?

    GPIO ISR code:

    static void GPIOIsr(void)
    {
        /* Disable the GPIO interrupt */
        GPIOBankIntDisable(SOC_GPIO_0_REGS, GPIO_Bx_NUMBER);
    
    
        /* Clear interrupt status in DSPINTC */
        IntEventClear(SYS_INT_GPIO_BxINT);
    
        /*Clear the GPIO pin interrupt*/    
        GPIOPinIntClear(SOC_GPIO_0_REGS,  pinNumber)
    
        /*Set flag or do processing, signal application with ucSetFlag*/
        ucSetFlag = 1;
    
      
        /* Enable the GPIO interrupt */
        GPIOBankIntEnable(SOC_GPIO_0_REGS, GPIO_Bx_NUMBER);
    
    }

    Please refer and execute the other interrupt examples available in the Starterware package. (example: timer)

    Thanks.

  • Thank you Rajasekaran K,

    my interrupt routine now works.

    Petr Duga

  • Hi,

    I have saved my workspace with working code using GPIO and interrupts on TM320C6748 lcdk ver 5 and attached it .

    Hopefully it helps someone.

    Petr Duga

    LED_and_switch_interrupt.zip
  • Hi Petr Duga,

    It will help someone. Thank you for your post.

  • Hi Rajasekaran,

    Which document lists down the GPIO interrupt number mapping

    /*System event number*/
    /*GPIO Interrupts */
    #define SYS_INT_GPIO_B0INT 			65
    #define SYS_INT_GPIO_B1INT 			41
    #define SYS_INT_GPIO_B2INT 			49
    #define SYS_INT_GPIO_B3INT 			52
    #define SYS_INT_GPIO_B4INT 			54
    #define SYS_INT_GPIO_B5INT 			59
    #define SYS_INT_GPIO_B6INT 			62
    #define SYS_INT_GPIO_B7INT 			72
    #define SYS_INT_GPIO_B8INT 			75
    

    I tried searching for this in the following documents TMS 320C674x Reference Guide and OMAP L138 Technical Reference Manual but I did not find anything.

  • Hi Prashant,

    Please refer the Seciton 3.2.2.1 Interrupt Controller (INTC) of  OMAP L138 Technical Reference Manual.

    Please look for "DSP Interrupt Map".

    Thanks.

  • Hi Rajasekaran,

    Thank you for the links. This is exactly what I was looking for.

    Regards

    Prashant

  • Thank you Petr Dugga

    It's very appropriate for my first example using GPIO. I have looking this for long time. 

    My application consist in serial transmission using one pin of GPIO (LCDK6748), I am going to review the example you shared to know how GPIO works.

    Once again thanks

    German Chavarro