这是一段定时器+软件技术的延时程序,为什么 #include <reg52.h> #include <intrins.h> #define uint unsigned int #define uchar unsigned char uchar a,num; //这里num=0的时候延时就不起作用了??? void main() { a=0xfe; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; while(1) { P0=a; } } void T0_time() interrupt 0 { TH1=(65536-50000)/256; TL1=(65536-50000)%256; num++; if(num==200) { num=0 a=_crol_(a,1); } }
|