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.

CCS/LAUNCHXL-F28379D: External interrupt for a switch with pull up enabled.

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello ,

I am writing a program to toggle a switch with  external interrupt ( XINT1 ) and i have enabled the PULL_UP on GPIO_INPUT(pin 18) , but what i am observing is that on choosing RISING_EDGE_INTERRUPT when I toggle switch from open state (HIGH STATE) to close state (GROUND STATE) it cause interrupt (BUT IT IS A TRANSITION FROM LOW TO HIGH STATE and RISING EDGE MEAN A TRANSITION FROM LOW TO HIGH)

and reverse is happening on choosing the FALLING_EDGE_INTERRUPT (transition from LOW TO HIGH STATE CAUSING INTERRUPT.)

I WANT TO KNOW WHY THESE IS DOING INVERTED FUNCTION?

DOES TI HAVE PURPOSELY MADE IT LIKE THIS?

/****************************************************************************************************************************/

IN MY FILE THIS IS DEFINED :

typedef enum
{
GPIO_INT_TYPE_FALLING_EDGE = 0x00, //!< Interrupt on falling edge
GPIO_INT_TYPE_RISING_EDGE = 0x04, //!< Interrupt on rising edge
GPIO_INT_TYPE_BOTH_EDGES = 0x0C //!< Interrupt on both edges
} GPIO_IntType;

  • Hi Ashish,

    Can you please share your software configuration for the GPIO interrupt?

    Have you verified that the state transitions meet your expectations by probing your GPIO input (pin 18)?

    Best,
    Kevin
  • /*This function enables the external interrupt on pin 18(IGNITION_SWITCH)*/

    void ext_int(void)
    {
    Interrupt_initModule();

    Interrupt_initVectorTable();

    Interrupt_register(INT_XINT1, &xint1_isr);

    Interrupt_enable(INT_XINT1);

    EINT; // Enable Global Interrupts

    PinStateChange(IGNITION_SWITCH,GPIO_INPUT);

    GPIO_setInterruptPin(IGNITION_SWITCH,GPIO_INT_XINT1);

    GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_RISING_EDGE);

    GPIO_enableInterrupt(GPIO_INT_XINT1); // Enable XINT1


    }

    /***********************************************************
    * This ISR Function reads the value on Ignition Switch
    * and assign its value to the ignition_Switch_val variable.
    ***********************************************************/
    interrupt void xint1_isr(void)
    {

    ignition_Switch_Val=MOTOR_Ignition_ON_OFF_GET();

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
    }

    AND AS I TOLD EARLIER STATE TRANSITION IN RISING EDGE IS FROM HIGH TO LOW  IS CAUSING EXTERNAL INTERRUPT (BUT IT SHOULD BE FROM LOW TO HIGH CAUSING INTERRUPT) AND REVERSE IS HAPPENING IN FALLING EDGE INTERRUPT.

  • Hi Ashish,

    Can you share your PinStateChange(); function?

    Have you already reviewed the external interrupt example within c2000ware? Located at the directory below:

    C:\ti\c2000\C2000Ware_1_00_06_00\driverlib\f2837xd\examples\cpu1\interrupt

    Can you try running that example and seeing if it works as intended for you? Then you can pull what you need from it into your own application as needed.

    Best,
    Kevin
  • I have pulled my code from that file only and it is working and all but why falling edge is working like rising edge interrupt and vice versa.
    Thats all i want to i know,I have enabled pull up for this pin.

    i can change the hex values and it will work fine.

    typedef enum
    {
    GPIO_INT_TYPE_FALLING_EDGE = 0x00, //!< Interrupt on falling edge
    GPIO_INT_TYPE_RISING_EDGE = 0x04, //!< Interrupt on rising edge
    GPIO_INT_TYPE_BOTH_EDGES = 0x0C //!< Interrupt on both edges
    } GPIO_IntType;
  • Hi Ashish,

    I just tried the example I referenced and it works as intended, GPIO_INT_TYPE_FALLING_EDGE causes an interrupt on high to low and GPIO_INT_TYPE_RISING_EDGE causes an interrupt on low to high. Have you tried running the example as is to confirm you see the same thing?

    Best,
    Kevin
  • Ashish,

    Do you happen to have the GPAINV (GPIO A Input Polarity Invert) Register set? Setting this register will invert the specified GPIO inputs.

    See section 7.9.2.8 "GPAINV Register (Offset = 10h) [reset = 0h]" of the TRM for more information.

    http://www.ti.com/lit/spruhm8

    Best,
    Kevin