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