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.

[参考译文] CC1312R:计时器启动与停止

Guru**** 2587175 points
Other Parts Discussed in Thread: LAUNCHXL-CC1312R1

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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/694191/cc1312r-timer-start-stop

器件型号:CC1312R

您好!  

我正在研究 LAUNCHXL-CC1312R1板和 rfEasyLinkRx 示例。

定时器和中断的设置为;

GPTimerCC26XX_Params 参数;

Params.width = GPT_CONFIG_32位;
params.mode = GPT_MODE_OneShot_Up;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
HTimer = GPTimerCC26XX_OPEN (Board_GPTIMER0A、params);
if (hTimer==空)
{
while (1);
}

/*将超时值设置为300ms */
rxTimeoutVal =(SysCtrlClockGet()*3UL)/10UL -1UL;
GPTimerCC26XX_setLoadValue (hTimer、rxTimeoutVal);


/*注册 GPTimer 中断*/
GPTimerCC26XX_registerInterrupt (hTimer、rxTimeoutCb、GPT_INT_TIMEOUT); 

这是代码;

PIN_setOutputValue (pinHandle、Board_PIN_LED2、1);
PIN_setOutputValue (pinHandle、Board_PIN_LED2、0);

GPTimerCC26XX_setLoadValue (hTimer、rxTimeoutVal);
GPTimerCC26XX_START (hTimer);

延迟(250000);//延迟250ms

GPTimerCC26XX_STOP (hTimer);
PIN_setOutputValue (pinHandle、Board_PIN_LED1、1);
PIN_setOutputValue (pinHandle、Board_PIN_LED1、0);

GPTimerCC26XX_setLoadValue (hTimer、rxTimeoutVal);
GPTimerCC26XX_START (hTimer);


while (1); 

这里是中断函数;

void rxTimeoutCb (GPTimerCC26XX_Handle handle、
GPTimerCC26XX_IntMask interruptMask)
{
/*设置超时标志*/
rxTimeoutFlag =真;

PIN_setOutputValue (pinHandle、Board_PIN_LED2、1);
PIN_setOutputValue (pinHandle、Board_PIN_LED2、0);

} 

存在 LED 引脚行为。 尽管停止计时器并重新加载该值、但计时器会再运行50ms、并产生中断。 停止并重新加载值后、我应该怎么做才能使它运行300ms 并产生中断? 谢谢。。。




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

    您好、Onur、

    在我看来、当您调用停止/启动或设置加载值时、当前时间值不会重置。 最终结果是、您只需暂停计时器一小段时间、并将超时值设置为与之前相同。

    它会设置加载值、如果正在递减计数、则从该值开始计数。

    我现在唯一的建议是两者之一

    a)将计时器模式设置为递减计数而不是递增计数。

    #include 
    #include DeviceFamily_constructPath (inc/hw_memmap.h)
    #include DeviceFamily_constructPath (inc/hw_gptt.h)
    
    HWREGBITW (GPT0_BASE + GPT_O_Tamr、GPT_TADR_BITN)=(GPT_TAMR_TADIR_DOWN)=(GPT_TADDIR_S);GPT_TADR_DOWN) 

    b)手动重置计时器值、无需调用新的 setLoadValue。

    HWREG (GPT0_BASE + GPT_O_TAV)= 0;// GPTimer 0A。 

    如果有更好的方法,我会将此主题告知同事:)

    此致、
    Aslak

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

    您好、Onur、

    另一种方法是通过将中的当前计时器值考虑在内来更新加载值:

    uint32_t CurrentValue = GPTimerCC26XX_getValue (handle);
    GPTimerCC26XX_setLoadValue (handle、CurrentValue + newValue); 

    我建议在将定时器设置为递减计数模式之前尝试这种方法、因为从现在起 GPTimer 就不支持这种方法。 虽然可能会起作用、但没有对此进行测试、并且可能存在一些未定义的行为。