Part Number: MSP430FR2676
I am trying to set up multiple timers on the MSP430FR2676. I know that it has two timers: A and B. I have been able to run the example code successfully (see below). However, I would like to be able to run 4 separate timers to toggle 4 separate LEDs. I am trying to set that up using Timer B with the separate TB0CCTLn registers. I understand that each separate TB0CCTLn register has a separate count in order to cause an interrupt. I am a little confused on how to recognize when the separate interrupts occur in the interrupt function. Is there a register to read that states which interrupt triggered the event? Also, I know that sending a TB0CTL &= ~MC stops the entire Timer B. However, is there a way to stop an individual TB0CCTLn count so as to stop each individual LED timer via software?
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1DIR |= BIT0; // P1.0 output
P1OUT |= BIT0; // P1.0 high
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 50000;
TA0CTL |= TASSEL__SMCLK | MC__CONTINUOUS; // SMCLK, continuous mode
__bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupts
__no_operation(); // For debug
}
// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
P1OUT ^= BIT0;
TA0CCR0 = 50000; // Add Offset to TACCR0
}