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.

[参考译文] MSP430FR6972:无法从计时器获取精确的时钟。

Guru**** 2383970 points
Other Parts Discussed in Thread: MSP430FR6972
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1011048/msp430fr6972-cannot-get-an-accurate-clock-from-the-timer

器件型号:MSP430FR6972

大家好、

客户无法使用 IC 从计时器获取准确的时钟。 下面是详细信息。

"

我正在使用 MSP430FR6972开发一个项目。 我无法从计时器获取准确的时钟。 我将时间设置为60秒、但它始终比我设置的时间短几毫秒、例如1毫秒、2毫秒甚至10毫秒。 我使用了一个外部32768Hz 晶体振荡器作为时钟源、除以64作为计时脉冲。

void this UCS 初始化(void)

GPIO_setPeripheralModuleFunctionInputPin (
GPIO_PORT_PJ、
GPIO_PIN4 + GPIO_PIN5、
GPIO_PRIMARY_MODULE_FUNCTION
);

//将 DCO 频率设置为1MHz
CS_setDCOFreq (CS_DCORSEL_0、CS_DCOFSEL_0);
//将外部时钟频率设置为32.768KHz
cs_setExternalClockSource (32768、0);
//set ACLK=LFXT
CS_initClockSignal (CS_ACLK、CS_LFXTCLK_select、CS_Clock_divider);
//set SMCLK = DCO、分频器为1
CS_initClockSignal (CS_SMCLK、CS_DCOCLK_select、CS_Clock_divider);
//set MCLK = DCO、分频器为1
CS_initClockSignal (CS_MCLK、CS_DCOCLK_select、CS_Clock_divider);
//Start XT1、无超时
CS_TurnOnLFXT (CS_LFXT_DRIVE_3);

void timer_B0_init ()

Timer_B_initContinuousModeParam initContParam ={0};

//以 ACLK 为源的连续模式中的启动定时器
initContParam.clockSource = Timer_B_CLOCKSOURCE_ACLK;
initContParam.clockSourceDivider = TIMER_B_CLOCKSOURCE_divider;
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_CAPTURECMPARE 寄存器_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);

"

提前感谢您。

此致、
梅纳德

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    1) 1)您正在使用什么晶体? 在60秒以上、20ppm 晶振可关闭60秒*.000020 = 1.2ms。

    2) 2)您如何对此进行测试? 我建议 printf()不是一个非常精确的指标。 考虑摆弄 GPIO 并在示波器上观察它。 更好的做法是:将 P2.5配置为 TB0.0、OUTMOD=4、从而消除所有软件延迟。

    3) 3) timer_B0_Rn_reload ()有什么作用? 如果将 TB0R 清零、这将根据 TIMER0_B0_ISR ()的延迟引入错误。