Hello all,
I am trying to use TimerA0 and TimerA1 to achieve a synchronised blinking on 2 seperate leds. Both Timers are set up to have ACLK as reference and are counting up to CCR0. Interrupts are set to flip the led states. When i dont use a divider and put 32768 on TA0CCR0 and 32768/2 on TA1CCR0 i get a perfectly synchronised blinking every second and half second even when left running for a long time. But when i try to use a divider in order to get the CCR0 values closer to approximate ms for future use (32768/32 =1024Hz) I found that the led blinks get out of sync very quickly. I've tried using both a combination of TAxCTL set to divide by 8 plus TAxEX0 set to divide by 4, and leaving the timer specific dividers to 1 and using only the UCSCTL5 ACLK divider set to /32, both gave the same results.
Putting the same value in both CCR0 registers also gives me a perfectly synchronised blinking no matter with what division.
Is there something i am missing?
I am using a MSP430F5529 launchpad.
Here is my code:
void SetupTimers(){
// Setup ACLK
UCSCTL4 |= SELA__XT1CLK; // Set XT1 as source(32768Hz)
// Timer0 Setup
TA0CCTL0 = CCIE; // CCR0 interrupt enabled
TA0CTL = TASSEL__ACLK + MC__UP + TACLR + ID__8; // ACLK, upmode, clear TAR, divider 32768/8
TA0EX0 = TAIDEX_3 ; // divider /4
TA0CCR0 = 1024; // 1= 1.024ms
// Timer1 Setup
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CTL = TASSEL__ACLK + MC__UP + TACLR + ID__8; // ACLK, upmode, clear TAR, divider /8
TA1EX0 = TAIDEX_3 ; // divider /4
TA1CCR0 = 1024/2; // 1= 1.024ms;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void){
P1OUT ^= BIT0;
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void){
P4OUT ^= BIT7;
}
Thanks for the help!