#include "reg52.h"
#include<intrins.h> //因为要用到左右移函数,所以加入这个头文件
#define uchar unsigned char
typedef unsigned int u16; //对数据类型进行声明定义
typedef unsigned char u8;
u8 duan[8]={0x40};
u8 wei[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}
u8 dispbitcnt;
u8 i;
void Timer()
{
TMOD=0x01;//采用定时器0,16位
TH0=0x3c; //初始值 10ms
TL0=0xb0;
EA=1; //总中断打开
ET0=1; //定时器中断打开
TR0=1; //定时器开关打开
}
void main()
{
Timer();
while (1);
{
if(i==100)
{
i=0;
P0=0x40;
P2=wei[dispbitcnt];
P2=P2>>1;
dispbitcnt++;
if(P2==0x7f)
dispbitcnt=0;
}
}
}
void Timer0(void) interrupt 1
{
static u16 i;
TH0=0xd8;
TL0=0xf0;
i++;
}
|