TI中文支持网
TI专业的中文技术问题搜集分享网站

CC3220 定时器如何清空计数

  我在控制程序中用了一个32位的定时器,SDK中只有Timer_getCount函数获取当前定时器的计数值,请问如何设置定时器的计数值呢?

Viki Shi:

参考下这边的代码实现: e2e.ti.com/…/402787

,

冯羽凡:

我试了一下,不行

这是我串口输出的信息

1_timercount is 0

2_timercount is 211

3_timercount is 162612

reload

4_timercount is 412853

reload

5_timercount is 663308

程序是这个样子的

uint32_t timercount = Timer_getCount(timer0);Display_printf(display,0,0,"1_timercount is %d",timercount);Timer_start(timer0);timercount = Timer_getCount(timer0);Display_printf(display,0,0,"2_timercount is %d",timercount);GPIO_setConfig(KEY, GPIO_CFG_IN_PD);timercount = Timer_getCount(timer0);Display_printf(display,0,0,"3_timercount is %d",timercount);Display_printf(display,0,0,"reload");reLoad();timercount = Timer_getCount(timer0);Display_printf(display,0,0,"4_timercount is %d",timercount);Display_printf(display,0,0,"reload");reLoad();timercount = Timer_getCount(timer0);Display_printf(display,0,0,"5_timercount is %d",timercount);

其中reLoad()是用来清空计数的,内容如下:

void reLoad()
{TimerCC32XX_HWAttrs const *hwAttrs = timer0->hwAttrs;unsigned long ulInts;ulInts= MAP_TimerIntStatus(hwAttrs->baseAddress,true);MAP_TimerIntClear(hwAttrs->baseAddress, ulInts);
}

,

冯羽凡:

不好意思,我重新看了一下,刚才用错了

,

Viki Shi:

没事,解决就好

赞(0)
未经允许不得转载:TI中文支持网 » CC3220 定时器如何清空计数
分享到: 更多 (0)