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

CC2640R2F: 请问该器件是否具有直接重置定时器计数值的函数?

Part Number:CC2640R2F

while (1) {UART_read(uart, &input, 1);//UART_write(uart, &input, 1);test_value1[uart_num++] = input;GPTimerCC26XX_start(hTimer1A);if(uart_num == SIMPLEPROFILE_CHAR4_LEN){SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, sizeof(uint8_t), &open_flag);uart_num = 0;GPTimerCC26XX_stop(hTimer1A);}}
void timerCallback1A(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
{// SimplePeripheral_performPeriodicTask();int i =0;if(uart_num < SIMPLEPROFILE_CHAR4_LEN){GPTimerCC26XX_stop(hTimer1A);for(i = uart_num;i<SIMPLEPROFILE_CHAR4_LEN;i++){test_value1[i] = 0;}uart_num = 0;SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, sizeof(uint8_t), &open_flag);}
}

(以上while1是串口接受处理函数,随后一个是200us中断函数)

本人设置了一个200us的定时器,用于检测一个接收串口数据的数组是否接受满(接收满则关闭定时器,防止定时器溢出),当200us计时溢出且数组没填满时就对剩余数组位置全部填0。

现在使用的是每10ms发送长度为5的数组,接受同样也是长度为5,按道理这200us的定时中断永远也不会触发(前提是每次接收完对定时器计数值进行重置)。使用中发现每接受五次数组就会触发一次中断,导致得到的两个数组后无端多了几个0(因为1个长度5的数组会被拆成2个)。最后发现是由于对定时器开关的操作我只用了GPTimerCC26XX_start(hTimer1A);以及GPTimerCC26XX_stop(hTimer1A);两个函数。但是GPTimerCC26XX_stop(hTimer1A);函数在停止定时器计数时并不会对其进行清零,导致多次进行stop后,定时器总会溢出导致中断。

所以问题在于是否具有直接重置定时器计数值的函数?有的话请告知!

谢谢!

zhi qiang liu:

我查看了GPTimerCC26XX.h并未发现写计数值的函数,只有两个读取的函数GPTimerCC26XX_getFreeRunValue,GPTimerCC26XX_getValue。所以只有来提问了!麻烦了!

,

Kevin Qiu1:

驱动没有清零的API,会在到达load值时,自动清零

Oneshot mode counting upwards. When timer reaches load value, the timer is stopped automatically. Supported in both 16 and 32-bit configuration.
Periodic mode counting upwards. When timer reaches load value it wraps and starts counting from 0 again. Supported in both 16 and 32-bit configuration

,

zhi qiang liu:

好的,感谢你的回答。

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F: 请问该器件是否具有直接重置定时器计数值的函数?
分享到: 更多 (0)