#include <msp430.h>
volatile unsigned int button_count;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
P1DIR |= BIT0; // Set P1.0 to output direction -- LED
P1DIR &= ~BIT1; // Set P1.1 to button input
P1REN |= BIT1; // Enable Pull Up Resistor for pin1.1
P1OUT |= BIT1; //SPECIFIED AS A PULLUP FOR P1.1
P1DIR &= ~BIT2; // Set P1.2 to button input
P1REN |= BIT2; // Enable Pull Up Resistor for pin1.2
P1OUT |= BIT2; //SPECIFIED AS A PULLUP FOR P1.2
TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 3277; //Set value of TA0CCR0 for comparison
TA0CTL |= TASSEL_1 + MC_1; //Pick ACLK & Set Counter to Up Mode
TA0CTL |= TACLR;
TA1CCR1 = 512; //Set value of TA1CCR0 for comparison
P1IES |= BIT1; //Have flag set on High to Low
P1IE |= BIT1; //enable interrupts for Pin 1.1
P1IFG &= ~BIT1; //Clear Pin 1.1 flag so no immediate interrupt
P1IES |= BIT2; //Have flag set on High to Low
P1IE |= BIT2; //enable interrupts for Pin 1.1
P1IFG &= ~BIT2; //Clear Pin 1.1 flag so no immediate interrupt
_enable_interrupt();
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TimerA0_ISR (void)
{
P1OUT ^= BIT0;
}
#pragma vector = PORT1_VECTOR
__interrupt void P1dot1_ISR(void)
{
if(P1IFG & BIT1)
{
if(TA1R > 0)
{
TA0CCR0 = 3277*button_count; //slow down blink speed
P1IES ^= BIT1; //Flip Edge Select
P1IFG &= ~BIT1; //Clear Pin 1.1 flag
}
else
{
TA1CTL |= TASSEL_1 + MC_1 + ID_3; //Pick ACLK & Set Counter to Up Mode & Divide ACLK by 8, so 4096
TA1EX0 |= TAIDEX_7; //Divide ACLK further by 8 to 512 hz
TA1CTL |= TACLR;
P1IES ^= BIT1; //Flip Edge Select
P1IFG &= ~BIT1; //Clear Pin 1.1 flag
}
}
if(P1IFG & BIT2)
{
TA0CCR0 = 3277; //reset blink speed
P1IFG &= ~BIT2; //Clear Pin 1.2 flag
}
}
So, when I enter P1dot1_ISR, I want to start a clock and flip the edge select of port 1.1
None of these are changing. I am setting a break point and viewing the registers. P1ES1 is still set to 1, despite me XOR'ing P1IES with BIT1. Timer A1 is not starting either.
What I am trying to do is, upon pressing (and holding) of p1.1 (button s1), I enter p1.1_ISR, start timer A1. I then flip the edge select of P1.1. When I release the button, because I switched the edge select, I should re-enter the ISR and change the value of CCR0 to some multiple of its old self (basically for every second I hold down the button, the integer I multiply CCR0 by is increased by 1)