CC2541怎样做到微秒延时?

[复制链接]
3269|16
 楼主| 右岸 发表于 2015-10-26 17:19 | 显示全部楼层 |阅读模式
本帖最后由 右岸 于 2015-10-27 14:58 编辑

本人新手,刚玩CC2541,想实现一个1500微秒的延时,发现OSAL下有下面的定时函数,但是毫秒级的:
  1. /*********************************************************************
  2. * @fn      osal_start_timerEx
  3. *
  4. * @brief
  5. *
  6. *   This function is called to start a timer to expire in n mSecs.
  7. *   When the timer expires, the calling task will get the specified event.
  8. *
  9. * @param   uint8 taskID - task id to set timer for
  10. * @param   uint16 event_id - event to be notified with
  11. * @param   uint32 timeout_value - in milliseconds.
  12. *
  13. * [url=home.php?mod=space&uid=266161]@return[/url]  SUCCESS, or NO_TIMER_AVAIL.
  14. */
  15. uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value )
  16. {
  17.   halIntState_t intState;
  18.   osalTimerRec_t *newTimer;

  19.   HAL_ENTER_CRITICAL_SECTION( intState );  // Hold off interrupts.

  20.   // Add timer
  21.   newTimer = osalAddTimer( taskID, event_id, timeout_value );

  22.   HAL_EXIT_CRITICAL_SECTION( intState );   // Re-enable interrupts.

  23.   return ( (newTimer != NULL) ? SUCCESS : NO_TIMER_AVAIL );
  24. }

  25. /*********************************************************************
希望前辈们指点一二,是不是我没有找到微秒的延时函数??该怎样使用OSAL库函数写出微秒的延时函数??

angerbird 发表于 2015-10-26 22:50 | 显示全部楼层
这个跟主频相关系的,主频越高,延时的越可以细化的
cehuafan 发表于 2015-10-27 22:10 | 显示全部楼层
计时。
sunmeat 发表于 2015-10-28 17:10 | 显示全部楼层
微妙的话,用NOP延时吧。
旧影子 发表于 2015-10-29 16:34 | 显示全部楼层
一个函数执行就有这么长时间了,微秒延时没有意义。
米尔豪斯 发表于 2015-10-29 19:29 | 显示全部楼层
用_NOP()延时,应该可以达到uS
尤彼卡 发表于 2015-10-29 19:40 | 显示全部楼层
想实现一个1500微秒的延时

这也就达到ms了呀
Thor9 发表于 2015-10-29 20:04 | 显示全部楼层
用的什么晶振,多高频率的
可可球 发表于 2015-10-29 20:30 | 显示全部楼层
自己写一个,关键是得看系统的时钟
309030106 发表于 2015-10-29 20:49 | 显示全部楼层
void delay_1us(void)       //1us延时函数  
  {     
asm("nop");   
}
冰河w 发表于 2015-10-29 21:19 | 显示全部楼层
延时是和系统时钟有关的
STM32初学者 发表于 2015-10-30 22:33 | 显示全部楼层
309030106 发表于 2015-10-29 20:49
void delay_1us(void)       //1us延时函数  
  {     
asm("nop");   

这个nop和系统的主频率有关的,不一定是1us
mmbs 发表于 2015-10-31 15:02 | 显示全部楼层
没用过微妙级的
xiaoyaozt 发表于 2015-10-31 18:49 | 显示全部楼层
一般不是ms吗
xiaoyaozt 发表于 2015-10-31 18:50 | 显示全部楼层
微妙的话 建议定时器中断
598330983 发表于 2015-10-31 19:45 | 显示全部楼层
真心不喜欢定时器延时,太麻烦,可是这种跑空周期也是费周期。
598330983 发表于 2015-10-31 19:46 | 显示全部楼层
_NOP()延时,应该可以达到uS
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

114

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部