大家好!
翻了翻论坛帖子就一篇问定时器清零的,答案还是clock,不是timer,所以想重开一个帖子问一下GPTimerCC26XX_getValue()函数是获取当前定时器的值,应该对应的有setValue()设置当前定时器值得函数吧,项目需要获取完定时器值后立刻清零等待下次开启定时器再计时,应该调用什么函数清零呢?谢谢各位~
Felix ZF:
clock是TI-RTOS自带的定时器模块,使用起来灵活方便。
可以参考SDK中的clock例程了解clock module的使用方法。
hui chu:
回复 Felix ZF:
谢谢回复,我参考了您说的例程,知道如何设置和获取当前计数值,但是例程里没有清零相关的代码,能问一下clock清零的方式吗?
Felix ZF:
回复 hui chu:
为什么要清零呢?
是为了重新开始计数吗?如果是想在前一次计数还没有结束时重新开始计数,可以先Clock_stop,使用Clock_setTimeout设置新的计数值,再Clock_start。
关于clock的所有API的详细描述,可以参考
hui chu:
回复 Felix ZF:
您好,清零是为了重新计数,Clock_stop是让时钟暂停,不会清零当前计数值的,而Clock_setTimeout是设置时钟终值,再次start应该不是从0开始计数而是从之前暂停的位置吧,不知道我理解的是不是有误,实际做实验感觉是这样的,向您请教
Felix ZF:
回复 hui chu:
clock module是从设置的计数值递减至0。
Clock_setPeriod() // instance
index URL
Set periodic interval
C synopsis
target-domainVoid Clock_setPeriod(Clock_Handle handle, UInt32 period);
ARGUMENTS
handle — handle of a previously-created Clock instance object
period — periodic interval in Clock ticks
CONSTRAINTS
Cannot change period of instance that has been started.
Clock_setTimeout() // instance
index URL
Set the initial timeout
C synopsis
target-domainVoid Clock_setTimeout(Clock_Handle handle, UInt32 timeout);
ARGUMENTS
handle — handle of a previously-created Clock instance object
timeout — initial timeout in Clock ticks
CONSTRAINTS
Cannot change the initial timeout of instance that has been started.
Clock_start() // instance
index URL
Start instance
C synopsis
target-domainVoid Clock_start(Clock_Handle handle);
ARGUMENTS
handle — handle of a previously-created Clock instance object
DETAILS
The timeout and period values set during create() or by calling Clock_setTimeout() and Clock_setPeriod() are used and the expiry is recomputed. Note that for periodic instances, the first expiry is computed using the timeout specified. All subsequent expiries use the period value.
CONSTRAINTS
Timeout of instance cannot be zero
Clock_stop() // instance
index URL
Stop instance
C synopsis
target-domainVoid Clock_stop(Clock_Handle handle);
ARGUMENTS
handle — handle of a previously-created Clock instance object
hui chu:
回复 Felix ZF:
您好,从打印结果看是递增至timeout啊,不是像您说的递减到0
System time in clk0Fxn = 15509
System time in clk0Fxn = 16006
System time in clk0Fxn = 16507
System time in clk0Fxn = 17007
System time in clk0Fxn = 17508
System time in clk0Fxn = 18005
System time in clk0Fxn = 18509
System time in clk0Fxn = 19006
System time in clk0Fxn = 19507
System time in clk0Fxn = 20007
System time in clk0Fxn = 20508
System time in clk0Fxn = 21005
System time in clk0Fxn = 21509
System time in clk0Fxn = 22006
System time in clk1Fxn = 22021
Calling BIOS_exit() from clk1Fxn
Felix ZF:
回复 hui chu:
你打出来的是system tick计数,不是你的clock instance的计数值,你可以通过ROV查看你的clock instance的计数值。
从你打印的值来看,你使用的clock是5ms的周期性定时器。
hui chu:
回复 Felix ZF:
非常感谢您的回复,很有帮助!请教一下怎么获取tRemaining的数值呢?谢谢
TI中文支持网


