Delay Function in msec

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Delay Function in msec

1,962 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by superkato on Wed Apr 08 05:25:05 MST 2015
Hi,

does someone has a example for a simple delay function in milliseconds?

like:
Delay(1000); //1sec delay


void Delay(uint32_t msecs)
{
  while (msecs != 0)   
  {
    //do something with the systicktimer;
  }

}



标签 (1)
0 项奖励
回复
2 回复数

1,368 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Apr 08 09:24:24 MST 2015
http://www.lpcware.com/content/forum/what-do-you-use-to-delay
0 项奖励
回复

1,368 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Wed Apr 08 07:28:55 MST 2015
Hi superkato,

Just to get your thought process going, a basic delay function can be implemented by using a timer interrupt (Systick works fine) and sleep mode. The idea is that you start a timer that will count for the desired delay duration. While it is counting, the MCU can be put into Sleep mode ensuring no code is being executed. Once the timer goes off, the interrupt will wake up the MCU and resume code execution. You can then disable the timer and exit the delay function.
0 项奖励
回复