CC2640R2F学习笔记(24)——系统延时使用

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_36347513/article/details/100160552

一、头文件

需要包含头文件
<ti/devices/cc26x0r2/driverlib/cpu.h>

二、原函数

//! \note If using an RTOS, consider using RTOS provided delay functions because
//! these will not block task scheduling and will potentially save power.
//!
//! Calculate delay count based on the wanted delay in microseconds (us):
//! - ui32Count = [delay in us] * [CPU clock in MHz] / [cycles per loop]
//!
//! Example: 250 us delay with code in flash and with cache and prefetch enabled:
//! - ui32Count = 250 * 48 / 4 = 3000
//!
//! \param ui32Count is the number of delay loop iterations to perform. Number must be greater than zero.
//!
//! \return None
//
//*****************************************************************************
extern void CPUdelay(uint32_t ui32Count);

传入参数值 3000为 250us

三、封装函数

/**
 @brief 毫秒级延时函数
 @param time -[in] 延时时间(毫秒)
 @return 无
*/
void delayMs(uint8_t time)
{
    CPUdelay(12000 * time);
}

四、调用函数

delayMs(5);    // 延时5ms

• 由 Leung 写于 2019 年 8 月 30 日

猜你喜欢

转载自blog.csdn.net/qq_36347513/article/details/100160552