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.

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后,定时器总会溢出导致中断。

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

谢谢!