Other Parts Discussed in Thread: MSP430WARE,
Tool/software: Code Composer Studio
Hello,
I am very new to the MSP430 mcu family as well as serious embedded programming/design (I come from an arduino/rpi backround).
I have been looking at this code for the second consecutive day and still can't figure out what the problem could possibly be or where to start looking for it.
The concept of the code is to light a different on-board LED depending on which of the on-board buttons is pressed, but no matter what I try the interrupt doesn't seem to fire at all.
Appreciate any help, and be nice I bruise easy!
Here is my code:
#include <msp430.h>
#include <driverlib.h>
#include <gpio.h>
#include <stdio.h>
#include <string.h>
int main(void) {
WDT_A_hold(WDT_A_BASE); // Stop watchdog timer
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); // Set Red LED output
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); // Red LED off
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN1); // Set Green LED output
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN1); // Green LED off
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5, GPIO_PIN6); // S1 P5.6: PxDIR, PxOUT and PxREN registers
GPIO_selectInterruptEdge(GPIO_PORT_P5, GPIO_PIN6,GPIO_LOW_TO_HIGH_TRANSITION); // S1 P5.6: PxIES register
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5, GPIO_PIN5); // S2 P5.5: PxDIR, PxOUT and PxREN registers
GPIO_selectInterruptEdge(GPIO_PORT_P5, GPIO_PIN5,GPIO_LOW_TO_HIGH_TRANSITION); // S2 P5.5: PxIES register
// Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
PMM_unlockLPM5();
// Set all P5IFG to zero
P5IFG = 0x00;
GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN6); // S1 P5.6: PxIE register
GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN5); // S2 P5.5: PxIE register
__bis_SR_register(GIE); // Enable all interrupts
while(1) {;}
}
#pragma vector=PORT5_VECTOR
__interrupt void Port_5(void)
{
switch (P5IFG)
{
case 0b01000000: // S1 P5.6 = 64: toggle red LED
{
P1OUT ^= BIT0; // Toggle P1.0
P5IFG &= ~BIT6; // P5.6 clear interrupt flag
break;
}
case 0b00100000: // S2 P5.5 = 32: toggle green LED
{
P1OUT ^= BIT1; // Toggle P1.1
P5IFG &= ~BIT5; // P5.5 clear interrupt flag
break;
}
default: // should not be here!
{
break;
}
}
}