Other Parts Discussed in Thread: TEST2
Hi team,
Customer cannot get an accurate clock from the timer using the IC. Below is the details.
"
I am developing a project using MSP430FR6972. I cannot get an accurate clock from the timer. I set a time of 60 seconds, but it is always a few milliseconds less than the time I set, such as 1 millisecond, 2 milliseconds, or even 10 milliseconds. I used an external 32768Hz crystal oscillator as the clock source, divided by 64 as the timing pulse.
void THIS_UCS_init(void)
{
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_PJ,
GPIO_PIN4 + GPIO_PIN5,
GPIO_PRIMARY_MODULE_FUNCTION
);
//Set DCO frequency to 1 MHz
CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0);
//Set external clock frequency to 32.768 KHz
CS_setExternalClockSource(32768,0);
//Set ACLK=LFXT
CS_initClockSignal(CS_ACLK,CS_LFXTCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Set SMCLK = DCO with frequency divider of 1
CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Set MCLK = DCO with frequency divider of 1
CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Start XT1 with no time out
CS_turnOnLFXT(CS_LFXT_DRIVE_3);
}
void TIMER_B0_init()
{
Timer_B_initContinuousModeParam initContParam = {0};
//Start timer in continuous mode sourced by ACLK
initContParam.clockSource = TIMER_B_CLOCKSOURCE_ACLK;
initContParam.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_64;
initContParam.timerInterruptEnable_TBIE = TIMER_B_TBIE_INTERRUPT_DISABLE;
initContParam.timerClear = TIMER_B_DO_CLEAR;
initContParam.startTimer = true;
Timer_B_initContinuousMode(TIMER_B0_BASE, &initContParam);
/*TIMER_B0_RN_start(TIMER_B_CAPTURECOMPARE_REGISTER_0, 10000);
Timer_B_startCounter( TIMER_B0_BASE, TIMER_B_CONTINUOUS_MODE);*/
}
#pragma vector=TIMER0_B0_VECTOR
__interrupt void TIMER0_B0_ISR (void)
{
printf("test2");
TIMER_B0_RN_reload(MAIN_TIMER_REGISTER, systemstate.upperiod*90000);
}
#pragma vector=TIMER0_B0_VECTOR
__interrupt void TIMER0_B0_ISR (void)
{
printf("test2");
TIMER_B0_RN_reload(MAIN_TIMER_REGISTER, systemstate.upperiod*60000);
}
"
Thank you in advance.
Regards,
Maynard