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.

[参考译文] LAUNCHXL-CC1310:如何使用板载 TI-RTOS 测量按钮按下的时间?

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1575135/launchxl-cc1310-how-to-measure-time-of-pressing-of-button-with-ti-rtos-on-board

器件型号:LAUNCHXL-CC1310


工具/软件:

您好、

我需要测量按下按钮的时间。 我感兴趣的时间值如下:

200ms、1 秒、3.5 秒和 10 秒。 因此范围是 200ms 到 10 秒。

为了检测按键的开始、我将使用回调函数 gpioButtonFxn0()。 但如何测量压力的时间?

此致、

Wojtek

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

    大家好、

    我使用了如下源代码

    #include <ti/sysbios/knl/Clock.h>
    
                uint32_t prevTicks = Clock_getTicks();
    
                // some task to time meausere...
    
                uint32_t currentTicks = Clock_getTicks();
                uint32_t elapsedTime = (currentTicks - prevTicks);
    
                // press_time = time in miliseconds
                uint32_t press_time = elapsedTime * Clock_tickPeriod / 1000.0;

    所以让我关闭这个票:-)