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.

GPIO interrupt on C6657

Hi all,

I wanted to configure GPIO02 for interrupt event. But I encountered some problems as below.

1. When GPIO02 falling edge triggered at one time, it would entry ISR twice(double entry the ISR).

2. Please check "SetGPIO02ISR" function. When while(1) was halted, GPIO02 falling edge would trigger the ISR(still double entry).

Once the while(1) removed, and jumped out "SetGPIO02ISR" then back to sys-BIOS to do multi-thread task. At this time GPIO02 falling edge would not work, it could not jump into ISR.

I got the setup GPIO ISR function as " SetGPIO02ISR " and ISR as " GPIO02InterruptHandler ".

Would someone help to check the function code? I thought maybe I missed something else. Thanks in advance.

===================================================

void SetGPIO02ISR(void)

{

       uint32_t uint32_value;

        CSL_IntcContext              context;

        CSL_IntcEventHandlerRecord  EventRecord;

        CSL_IntcEventHandlerRecord   EventHandler[1];

        CSL_IntcParam               vectId;

        CSL_IntcHandle  gpioIntcHandle;

        CSL_IntcObj       gpioIntcObj;

 

       CSL_IntcGlobalEnableState   state;

 

       // unlock KICK

        KICK0 = KICK0_UNLOCK;

        KICK1 = KICK1_UNLOCK;

       

        // Config GPIO02 as input

            GhGpio = CSL_GPIO_open (0); // Opens GPIO Instance 0

            CSL_GPIO_setPinDirInput (GhGpio, 2); //set GPIO_2 to be input

 

        //. Enable GPIO global interrupt   ( BINTEN)   

        //GPIO user guide needs to be updated for BINTEN register that bit 0 is for Bank 0 (GPIO pins 15:0)

        //and bit 1 is for Bank 1 (GPIO pins 31-16).

           GhGpio->BINTEN = 0x01;

       

        // Enable GPIO02 rising edge interrupt

               CSL_GPIO_setFallingEdgeDetect(GhGpio, 2);

                              

            /* INTC module initialization */

            context.eventhandlerRecord = EventHandler;

            context.numEvtEntries      = 1;

            if (CSL_intcInit(&context) != CSL_SOK)

                printf ("CSL_intcInit fail\n");         

 

            /* Enable NMIs */

             if (CSL_intcGlobalNmiEnable() != CSL_SOK)

                printf ("CSL_intcGlobalNmiEnable fail\n");         

       

            /* Enable global interrupts */

            if (CSL_intcGlobalEnable(&state) != CSL_SOK)

                printf ("CSL_intcGlobalEnable fail\n");

       

        /* Open INTC */

            vectId = CSL_INTC_VECTID_4;

            gpioIntcHandle = CSL_intcOpen(&gpioIntcObj, CSL_GEM_GPINT2, &vectId, NULL);  //CSL_GEM_GPINTN

            if (gpioIntcHandle == NULL)

                printf ("gpioIntcHandle fail\n");

          

            /* Bind ISR to Interrupt */

            EventRecord.handler = (CSL_IntcEventHandler)&GPIO02InterruptHandler;

            EventRecord.arg     =  gpioIntcHandle;   // (void *)CSL_GEM_GPINT2;

            CSL_intcPlugEventHandler(gpioIntcHandle, &EventRecord);

 

          /* Clear the event in case it is pending */

            CSL_intcHwControl(hyplnkExampleIntcHnd, CSL_INTC_CMD_EVTCLEAR, NULL);

         

            /* Event Enable */

            CSL_intcHwControl(gpioIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);



            printf ("GPIO02 Interrupt Test Start\n");

          //CSL_IntcClose(gpioIntcHandle);

           GPIO02_flag = 0x0;

 

          while(1);      

}

 ===================================================

void GPIO02InterruptHandler (void *arg)

{   

      /* Clear the event ID. */

        CSL_intcEventClear((CSL_IntcEventId)arg);

}

 ===================================================

B.R.

OC