📄 yaonew02.c
字号:
#include <reg52.h>
#define SEG1 8
#define SEG2 16
#define uchar unsigned char
#define uint unsigned int
uchar th1,tl1,index,phase;
bit left_flag;
code char chara[17][3]={
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xf9,0xff},
{0xff,0xf6,0x9f},
{0xff,0xee,0xa6},
{0xfe,0xdd,0x78},
{0x7e,0xbb,0x7f},
{0x00,0x77,0x7f},
{0x7e,0xbb,0x7f},
{0xfe,0xdd,0x78},
{0xff,0xee,0xa6},
{0xff,0xf6,0x9f},
{0xff,0xf9,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff},
{0xff,0xff,0xff},
};
main()
{
EA=0;
EX0=1;
EX1=1;
ET0=1;
ET1=1;
IT0=1;
IT1=1;
TMOD=0x11;
index=0;
EA=1;
while(1)
{
}
}
void int0_ser() interrupt 0 using 1
{
uint t0_counter;
left_flag=1;
TR0=0;
TR1=0;
t0_counter=TH0<<8|TL0;
TH0=0;
TL0=0;
TR0=1;
t0_counter=65535-t0_counter/SEG1;
tl1=t0_counter%256;
th1=t0_counter/256;
TH1=th1;
TL1=tl1;
index=1;
if (th1!=0xff || tl1!=0xff)
{
phase=0;
TR1=1;
}
else
{
TR1=0;
}
}
void int1_ser() interrupt 2 using 2
{
uint t0_counter;
left_flag=0;
TR0=0;
TR1=0;
t0_counter=TH0<<8|TL0;
TH0=0;
TL0=0;
TR0=1;
t0_counter=65535-t0_counter/SEG1;
tl1=t0_counter%256;
th1=t0_counter/256;
TH1=th1;
TL1=tl1;
index=1;
if (th1!=0xff || tl1!=0xff)
{
phase=17;
TR1=1;
}
else
{
TR1=0;
}
}
void timer1() interrupt 3 using 3
{
P0=chara[phase][index];
if(left_flag)
{
if(phase<9)
phase++;
}
else
{
if(phase>8)
phase--;
}
TH1=th1;
TL1=tl1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -