51定时器延时函数(精确延时)
1 bit f,m; 2 3 void T0_service(void) interrupt 1 4 { 5 TH0=(65536-5000)>>8; 6 TL0=(unsigned char)(65536-5000); 7 Count5ms=Count5ms+1; 8 m=~m; 9 if (Count5ms==100) 10 { 11 Count5ms=0; 12 f=~f; 13 } 14 } 15 16 void delay1s(void) 17 { 18 while(f); 19 while(!f); 20 } 21 22 void delay10ms(void) 23 { 24 while(m); 25 while(!m); 26 }