#include<reg52.h> //52单片机头文件
#include <intrins.h> //包含有左右循环移位子函数的库
#define uint unsignedint //宏定义
#define uchar unsignedchar //宏定义
sbit P1_0=P1^0;
uchar tt,a;
void main() //主函数
{
TMOD=0x01;//设置定时器0为工作方式1
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;//开总中断
ET0=1;//开定时器0中断
TR0=1;//启动定时器0
a=0xfe;
while(1);//等待中断产生
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++;
if(tt==2)
{
tt=0;
P1=a;
a=_crol_(a,1);
}
}
|