星期一, 8月 24, 2009

Keil C51 延時函數 delay_1ms

利用 printf 計時,好像不太準耶,不知為啥。

12.0 MHz 延時 1ms 函數

void delay_1ms(unsigned int ms) { unsigned char i; while(ms--) { for(i = 0; i < 123; i++); } }

22.1184 MHz 延時 1ms 函數

void delay_1ms(unsigned int ms) { unsigned char i; while(ms--) { _nop_(); _nop_(); for(i=0; i<228; i++); } }

原文出處:http://www.dztang.com/article/dpj/jcycx/117.html
经过电子堂网站的实测,精确到us啊,足够了吧。

沒有留言:

張貼留言