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.

MSP430FR2155: msp430 fr2155

Part Number: MSP430FR2155


Hi

I am working on a timer TB0 CCR0 routine

I have an issue here and see if TI expert can give me some pointer.

I simplify app so that timer run 240 clock cycle and restart.

I found that in the beginning, the Timer kick every 210 clock cycle. I am expecting 240 clock cycle.

After 120 kick, program stop and start Timer.

and Timer kick every 420 clock cycle after restart.

Not sure what i miss here.

I attach a simple code here.

Thanks

unsigned int count;
unsigned int delta[120];
unsigned int pre_rtc;

void RTCInit()
{
    HWREG16(RTC_BASE + OFS_RTCCTL) &= ~(RTCSS_3 | RTCPS_7);
    HWREG16(RTC_BASE + OFS_RTCMOD) = 32767;
    RTC_start(RTC_BASE,  RTCSS_1);
}

void InitTimer()
{
    HWREG16(TIMER_B0_BASE + OFS_TBxCTL) = TBSSEL__SMCLK;
    HWREG16(TIMER_B0_BASE + OFS_TBxCCR0) = 239;
    HWREG16(TIMER_B0_BASE + OFS_TBxCCTL0) |= CCIE

    HWREG16(TIMER_B0_BASE + OFS_TBxCTL) |=  MC; 
}


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_B0_VECTOR
__interrupt void TIMER0_B0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_B0_VECTOR))) TIMER0_B0_ISR (void)
#else
#error Compiler not supported!
#endif
{
    
    delta[count] = RTCCNT - pre_rtc;
    pre_rtc = RTCCNT;
    count++;

    if (count>=120)
    {
           HWREG16(TIMER_B0_BASE + OFS_TBxCTL) &=  ~MC; 
           // process data

           
            
           HWREG16(TIMER_B0_BASE + OFS_TBxCTL) |=  MC;    


    } 
}

**Attention** This is a public forum