This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am developing in MSP430F6438 + CC2564 with Bluetopia SPPLEDemo.
In the SPPLEDemo project , it has Timer like the following code:
#define ACLK_FREQUENCY_HZ ((unsigned int)32768);
#define MSP430_TICK_RATE_HZ ((unsigned int)1000);
static void ConfigureTimer(void)
{
/* Ensure the timer is stopped. */
TA1CTL = 0;
/* Run the timer off of the ACLK. */
TA1CTL = TASSEL_1 | ID_0;
/* Clear everything to start with. */
TA1CTL |= TACLR;
/* Set the compare match value according to the tick rate we want. */
TA1CCR0 = ( ACLK_FREQUENCY_HZ / MSP430_TICK_RATE_HZ ) + 1;
/* Enable the interrupts. */
TA1CCTL0 = CCIE;
/* Start up clean. */
TA1CTL |= TACLR;
/* Up mode. */
TA1CTL |= TASSEL_1 | MC_1 | ID_0;
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER_INTERRUPT(void)
{
++MSP430Ticks;
/* Exit from LPM if necessary (this statement will have no effect if */
/* we are not currently in low power mode). */
LPM3_EXIT;
}
When the interrupt trigger , the MSP430Ticks will plus 1. It seems the MSP430Ticks can be use for time calculate.
But in this case , how to convert the MSP430Ticks to the Time ?
What is the time unit ? millisecond ? or microsecond ?
Thank in advance.
MSP430Ticks
Hi Wun!
You can use this formula:
input_divider * timer_ticks / f_timer [Hz] = time [s]
So for example when having the timer sourced with 1MHz, the timer's input divider is 2 and you have 1000 timer ticks in your CCR register you would have:
2 * 1,000 / 1,000,000Hz = 0.002s = 2ms
Or in your case:
1 * 33 / 32768Hz = 0.001s = 1ms
So your interrupt would fire every 1ms.
Dennis
**Attention** This is a public forum