Hi Team,
Does it have some functions to calculate the working time from the starting point on msp430r5994?
Best,
Gaosheng
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.
Hi Team,
Does it have some functions to calculate the working time from the starting point on msp430r5994?
Best,
Gaosheng
Hi Gaosheng,
Unfortunately, there is no "built-in" feature or function in the MSP430FR5994 MCU. However, this could be done easily in SW using any of it's multiple timers.
Here [link] is a very simple example showing how you might use a timer. I modified it a little here to show you how to use the interrupt to update a counter once every second. It will even toggle an IO pin, if you want, so you can monitor with an oscilloscope or logic probe.
If you want a different update rate, change the period of the timer TA0CCR0 register value. For example if you want to count the number of 0.1 seconds, then change TA0CCR0 value to (32768/10).
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT // Configure GPIO P1DIR |= BIT0; P1OUT |= BIT0; // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; long seconds_counter = 0; TA0CCTL0 = CCIE; // TACCR0 interrupt enabled TA0CCR0 = 32768; // Using ACLK @ 32768KHz, generate interrupt every 1 second TA0CTL = TASSEL__ACLK | MC__UP; // ACLK, UP mode __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt __no_operation(); // For debugger } // Timer0_A0 interrupt service routine #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer0_A0_ISR (void) #elif defined(__GNUC__) void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void) #else #error Compiler not supported! #endif { P1OUT ^= BIT0; seconds_counter++; }
Does this help answer your question?
**Attention** This is a public forum