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.

CCS/MSP430FR2311: How to make sure that the TimerB runs only once in MSP430FR2311?

Part Number: MSP430FR2311

Tool/software: Code Composer Studio

I am trying to write a code where TimerB should run only once and then stop until it is started again by software. However, when the code is executed, TIMERB is continuously running inspite of setting the MODE to stop in the TB0CTL register in the ISR. Please refer to below code and advise why my timer is not stopping after executing once ?

#include <msp430.h>

int timerflag = 0;
void start200mstimer()
{

timerflag=1;
TB0CTL |= TBCLR;
TB0CTL |= MC__UP;
TB0CTL |= TBSSEL__ACLK ;
TB0CCR0 = 6553;

TB0CCTL0 |= CCIE; // ENABLE TIMER MASKABLE INTERRUPT
TB0CCTL0 &= ~CCIFG; //clear interrupt bit

}

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 &= ~LOCKLPM5;
initGPIO ();

__enable_interrupt();

while (1)
{
if (timerflag==0)
start200mstimer();

}

return 0;
}

#pragma vector = TIMER0_B0_VECTOR
__interrupt void ISR_200ms ()
{
//WRITE CODE TO UPDATE FLAG
TB0CTL &= ~MC__STOP;
TB0CTL |= TBCLR;
TB0CCTL0 &= ~CCIFG;

}

**Attention** This is a public forum