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.

[参考译文] CC1310:Task_sleep ()和 usleep ()之间的功耗差异是什么?

Guru**** 2482105 points


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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1272107/cc1310-what-is-the-difference-in-power-consumption-between-task_sleep-and-usleep

器件型号:CC1310

大家好、

Task_sleep ()和 usleep ()之间的功耗有何差异?

 我知道睡眠和 usleep 之间的功耗没有区别,但我不知道  Task_sleep ()和 usleep ()。

此致、

银河

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

    您好、Galaxy、

    Task_sleep()以系统时钟节拍数作为计时参数。 您可以在此处阅读完整文档:  

    https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_7_10_01_24/docs/tirtos7/doxygen/m4/html/Task_8h.html#a1c5f0ae2e0960e2e7bdc4f1a8edb07fa

    usleep()将需要几微秒作为计时参数。 如果你看看 sleep.c 中的执行、你将看到它最终会调用 Task_sleep。

    /*
     *  ======== usleep ========
     */
    int usleep(useconds_t usec)
    {
        UInt32 timeout;
    
        /* usec must be less than 1000000 */
        if (usec >= 1000000) {
            errno = EINVAL;
            return (-1);
        }
    
        /*  Implementations may place limitations on the granularity of timer
         *  values. For each interval timer, if the requested timer value requires
         *  a finer granularity than the implementation supports, the actual timer
         *  value shall be rounded up to the next supported value.
         */
        /* Clock_tickPeriod is the Clock period in microseconds */
        timeout = (UInt32)((usec + Clock_tickPeriod - 1) / Clock_tickPeriod);
    
        /* must add one tick to ensure a full duration of timeout ticks */
        Task_sleep(timeout + 1);
    
        return (0);
    }

    谢谢、

    M·H