- #include<reg52.h>
- #include<intrins.h>
- unsigned char count;
- void main()
- {
- count=0;
- TMOD=0x01;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- EA=1;
- ET0=1;
- TR0=1;
- P2=0xfe;
- while(1);
- }
- void timer0() interrupt 1
- {
- TH0=(65536-50000)/256;
- TL0=(65535-50000)%256;
- count++;
- if(count==20)
- {
- count=0;
- P2=_crol_(P2,1);
- }
- }
复制代码
|