#ifdef FOSC_160000 // if Fsys = 16MHz
#define TIMER_DIV12_VALUE_100us 65536-130 //130*12/16000000 = 10 uS, // Timer divider = 12 16M时钟,12分频后定时器的周期为16/12 us,所以1ms=1000*16/12 约为1334
void Timer0_Delay1ms(UINT32 u32CNT) clr_T0M; //T0M=0, Timer0 Clock = Fsys/12 定时器0 12分频 set_TR0; //Start Timer0 开启 { TH0 = HIBYTE(TIMER_DIV12_VALUE_1ms); //高8位和低8位设置相应值 clr_TF0; //清除溢邮 } }
|