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.

MSP430FR5994: Strange interrupt behavior on port P8 adjacent pins

Part Number: MSP430FR5994
Other Parts Discussed in Thread: SYSBIOS

Hello,

I am facing a strange behavior on Port P8 of msp430fr5994.

I have configured GPIO P8.2 and GPIO P8.1 as interrupt source. I attached two buttons with external pullups resistors to the pins.

When I press button attached to P8.2 everything works well.

When I press button attached to P8.1 the interrupt associated with P8.1 is triggered first, then the the interrupt associated with P8.2 is also triggered (i debugged the exact occourring of the two events).

I use a green led led that should toggle when i press P.8.2 and yellow led  that should toggle when i press P8.1

What I see is that each time i press the button connected to P8.2 only the green led changes state but when i press the button connected to P8.1 the yellow led changes state followed by the green led.

I am using TI-RTOS 2.2.0, I just created the tow HWI connected with the two callbacks which post an event to a task.

in main.c

    GPIO_setCallback(BUTTON_POWER, gpioButtonPowerInt); // P8.2
    GPIO_setCallback(BUTTON_SAMPLE, gpioButtonSampleInt); // P8.1

    /* enable Button interrupt */
    GPIO_enableInt(BUTTON_POWER);
    GPIO_enableInt(BUTTON_SAMPLE);

    /* Start BIOS */
    BIOS_start();

In buttons.c (interrupt callbacks)

void gpioButtonPowerInt(unsigned int index)
{
    if (index==BUTTON_POWER) {
        GPIO_clearInt(BUTTON_POWER);
        Event_post(btnEvent, Event_ButtonPower);
    }
}


void gpioButtonSampleInt(unsigned int index)
{
    if (index==BUTTON_SAMPLE) {
        GPIO_clearInt(BUTTON_SAMPLE);
        Event_post(btnEvent, Event_ButtonSample);
    }
}

in leds.c (Task)

void Leds(void){
    UInt evt;
    int key;
    while(1) {
        evt = Event_pend(btnEvent, 0, Event_ButtonPower |
                Event_ButtonSample | Event_Button0 | Event_Button1, BIOS_WAIT_FOREVER);
        switch(evt) {
        case Event_ButtonPower:
            GPIO_disableInt(BUTTON_POWER);
            GPIO_toggle(LED_GREEN);
            Task_sleep(600); // debounce
            GPIO_enableInt(BUTTON_POWER);
        break;
        case Event_ButtonSample:
            GPIO_disableInt(BUTTON_SAMPLE);
            GPIO_toggle(LED_YELLOW);
            Task_sleep(600); // debounce
            GPIO_enableInt(BUTTON_SAMPLE);
        break;
        }
    }
}

in my .cfg

var hwi0Params = new halHwi.Params();
hwi0Params.arg = 8;
hwi0Params.instance.name = "hwi0H";
hwi0Params.maskSetting = xdc.module("ti.sysbios.interfaces.IHwi").MaskingOption_ALL;
Program.global.hwi0H = halHwi.create(19, "&GPIO_hwiIntFxn", hwi0Params);

var hw1Params = new halHwi.Params();
hw1Params.arg = 5;
hw1Params.instance.name = "hw1H";
hw1Params.maskSetting = xdc.module("ti.sysbios.interfaces.IHwi").MaskingOption_ALL;
Program.global.hw1H = halHwi.create(27, "&GPIO_hwiIntFxn", hw1Params);


var event0Params = new Event.Params();
event0Params.instance.name = "btnEvent";
Program.global.btnEvent = Event.create(event0Params);

var task1Params = new Task.Params();
task1Params.instance.name = "ledTask";
Program.global.ledTask = Task.create("&Leds", task1Params);

halHwi.dispatcherAutoNestingSupport = false;

in Board.h

#define LED_GREEN                      MSP_EXP430FR5994_LED_G
#define LED_YELLOW                  MSP_EXP430FR5994_LED_Y

#define BUTTON_POWER                   MSP_EXP430FR5994_BUTTON_P
#define BUTTON_SAMPLE               MSP_EXP430FR5994_BUTTON_S

These have been added to the enumeration in MSP_EXP430FR5994.h

typedef enum MSP_EXP430FR5994_GPIOName {
    MSP_EXP430FR5994_S1 = 0,
    MSP_EXP430FR5994_S2,

    MSP_EXP430FR5994_BUTTON_P,
    MSP_EXP430FR5994_BUTTON_S,

    MSP_EXP430FR5994_LED1,
    MSP_EXP430FR5994_LED2,

    MSP_EXP430FR5994_LED_G,
    MSP_EXP430FR5994_LED_Y,

    MSP_EXP430FR5994_GPIOCOUNT
} MSP_EXP430FR5994_GPIOName;

And have been confired in MSP_EXP430FR5994.c

GPIO_PinConfig gpioPinConfigs[] = {
    /* Input pins */
    /* MSP_EXP430FR5994_S1 */
    GPIOMSP430_P5_6 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING,
    /* MSP_EXP430FR5994_S2 */
    GPIOMSP430_P5_5 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING,
    
    /* Added buttons */
    GPIOMSP430_P8_2 | GPIO_CFG_IN_NOPULL | GPIO_CFG_IN_INT_FALLING,
    GPIOMSP430_P8_1 | GPIO_CFG_IN_NOPULL | GPIO_CFG_IN_INT_FALLING,
    //
    /* Output pins */
    /* MSP_EXP430FR5994_LED1 */
    GPIOMSP430_P1_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP430FR5994_LED2 */
    GPIOMSP430_P1_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    
    /* Added Leds */
    GPIOMSP430_P4_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    GPIOMSP430_P4_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
}

ADDENDUM

I discovered that by pressing button connected to P8.1 twice raidly (double clicking) prevent the green led to commute.

Maybe a stupid mistake somewhere in my code? Someone can help?

Cheers

Damiano

  • I don't know much about TI-RTOS, but as a general practice I suggest you insert a

    GPIO_clearInt(BUTTON_mumble);

    before each call to 

    GPIO_enableInt(BUTTON_mumble);

    This may or may not fix your problem, but it might avoid some illusions.

    1) Different buttons bounce differently.

    2) Buttons bounce on release as well as press.

  • Hi Bruce,

    Thank you for the anwer.

    Tried to move GPIO_clearInt from ISR to te Task, just before GPIO_enableInt, but unfortunately this did not solve the problem.

    Forget to mention that this behavior is not random, it always happens. The second interrupt, in the example i posted seems to occour exactly after the Task_sleep period ends ad the task resumes.

    I am using CCS v6.2 with TI v15.12.7LTS compiler. I know it's a bit old but I read somewhere that news release have problems compiling TI-RTOS for MSP430.

  • Are you fairly certain this isn't electrical? If you have a scope, try watching the button wires. (This will also give you some idea of how much bounce to expect.) If not: is the "other" callback actually called?

    How strong are the external pullups? You might try using the internal pullups as well (GPIO_CFG_IN_PU).

    The canonical (interrupt-based) debounce looks like:

    1) Disable interrupt. 

    2) Wait for an appropriate time period.

    3) Check pin signal level (presumed settled by now) and take action.

    4) Clear interrupt indicator.

    5) Enable interrupt.

    Item (1) should be done in the ISR/callback. The rest can be done at leisure.

**Attention** This is a public forum