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.

[stellaris launchpad] button interrupt problem..

i wrote a code for RGB LED blink using the switch interrupt...but the interrupt gets triggered at the wrong button.....i have selected the button of port f pin 4 but interrupt get triggered when i press the button at pin 0......i have checked the datasheet and schametics too......

heres the code for it...

#define SWITCH  GPIO_PIN_4

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_IntMasterEnable(); // enable processor interrupts

GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,SWITCH);
GPIOIntTypeSet(GPIO_PORTF_BASE,SWITCH, GPIO_RISING_EDGE);
GPIOPortIntRegister(GPIO_PORTF_BASE,SwitchIntHandler);
IntPrioritySet(INT_GPIOF, 0x00);

GPIOPinIntEnable(GPIO_PORTF_BASE,SWITCH);

help me...

  • Are you aware that PF0 defaults into NMI behavior unless you take specific actions to repurpose?  There should be a specific handler for such NMI management.

    Via your, "GPIOPortIntRegister()" you create a, "dynamic" interrupt mechanism.  Far more usual is "static" - which requires your declaration & properly located entry of the interrupt handler w/in your "start-up" file.

    You'll heighten your understanding if you can switch away from PF0 (at least temporarily) - and determine if "other" activity on Port F causes entry to your interrupt handler.

    Note further that your code listing does not show, "ROM_GPIOPadConfigSet()" - which likely must configure your Pin_4 as, "GPIO_PIN_TYPE_STD_WPD" - as you chose to interrupt on a rising edge.  Indeed your call to, "GPIOPinTypeGPIOInput()" calls to, "GPIOPadConfigSet()" - but I suspect without the "WPD" parameter.  

  • how to set a static interrupt???

    when i use the pad config function no interrupt gets fired...

    i have created a handler and registered in the startup file......

  • "How to set a static interrupt?"

    Below - key items to achieve static interrupt (Port B - illustrated) - (this w/in our, start-up file:)  You should eliminate your, "interrupt register" call. (as it creates the more complex dynamic interrupt)

    //  External declarations for the interrupt handlers used by the application.
    //
    //*****************************************************************************
    extern void IntDefaultHandler(void);
    extern void ADC0IntHandler(void);       
    // extern void ADC0SS0Handler(void);   
    extern void GPIOBIntHandler(void);      
    extern void CANIntHandler(void);
    extern void FaultISR(void);
    extern void NmiSR(void);
    extern void PWM0IntHandler(void);       

    // The vector table.  Note that the proper constructs must be placed on this to
    // ensure that it ends up at physical address 0x0000.0000.

    .
    .
        SysTickIntHandler,                      // The SysTick handler
        IntDefaultHandler,                       // GPIO Port A
        GPIOBIntHandler,                      // GPIO Port B
        IntDefaultHandler,                      // GPIO Port C

    Your, "static interrupt" registration code should appear similar to the "highlighted" items, above.

    To interrupt upon a rising signal edge - as you desire - all potential interrupt trigger pins must be held at/near logic low - so that the rising signal may be properly recognized.  Thus you need to review just how GPIOPinType's() call to the GPIOPadConfig() operates.  (that is revealed w/in driverlib\gpio.c - under GPIOPinType code block)  This explains my choice of "WPD" to insure those "interrupting pins" sit @/near logic low - when inactive.

    Note you've ticked your "questioning" post as, Verified.  Better to tick the responder's post - which correctly answered...