I'm trying to use an MSP430 timer with a 32.768Khz crystal to generate an interrupt every second increments the number on a 7-segment display.
And I'm using the following code to set up the clocks etc.
When the interrupt is run, I execute
And I'm using the following code to set up the clocks etc.
WDTCTL = WDTPW | WDTHOLD;
BCSCTL1 = CALBC1_1MHZ ;
DCOCTL = CALDCO_1MHZ;
P1DIR = 0xFF;
P2DIR = 0xFF;
P1OUT = 0x00;
CCTL0 = CCIE;
CCR0 = 32768;
TACTL = TASSEL_1 + MC_2;
__bis_SR_register(GIE);
When the interrupt is run, I execute
CCR0 += 32768;
But instead of a 1s interval, I'm getting somewhere around 5-6s. I'm pretty sure it's running from the crystal as when I remove it the timer stops counting.
Does anyone know what might be wrong? And also could someone explain to me the process of setting up and resetting the timer? I'm not sure I understand the code properly.