用c作程序,如何计算延时?
加入我的晶振是11.0592MHz我要调用延时程序
delay(int n)
{
int i;
for(i=0;i<n;i++)
{}
}
这样的情况延时如何计算呢? #define XTAL_FREQ 4MHZ/* Crystal frequency in MHz */
#define MHZ *1000L /* number of kHz in a MHz */
#define KHZ *1 /* number of kHz in a kHz */
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \
while(--_dcnt != 0) \
continue; }
页:
[1]