Part Number: MSP430FR4133
Tool/software: Code Composer Studio
Hi all,
I'm trying to implement a simple routine to toggle one Led every 10s.
For that, i would like to set the source ACLK which in this lunchpad is 32.768 kHz, in continuous mode and Input divider 1.
Timer(s) = 65535/ 32768 =~ 2s
Each overflow would occur within 2s. The problem is that, what i'm seeing is the the toggle frequency much lower than this. Can someone help me?
This is the code:
#include <msp430.h>
#include <hlcd.h>
unsigned Global_Timer0_Count = 0;
unsigned Global_Count = 0;
int main( void )
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
TA0CTL |= TACLR;
TA0CTL |= MC_2 | TASSEL_1 | ID_0;
TA0CTL |= TAIE;
P1DIR |= BIT0; // P1.0 is Led output
P1OUT = 0x01; // Set led on
PM5CTL0 &= ~LOCKLPM5;
__enable_interrupt();
__bis_SR_register(GIE); // LPM0 with interrupts enabled
while (1)
{
}
}
// Timer A0 interrupt service routine
#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMERA0_ISR0(void)
{
Global_Timer0_Count ++;
if(Global_Timer0_Count == 5){
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
Global_Timer0_Count = 0;
TA0CTL &= ~BIT0;
}