#include"STC15F2K60S2.h"
#define Segs P0
#define Out P1
#define Anm_speed 4
unsigned char code table[]={
//第0帧
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
//第1帧
0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03,
0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03,
//第2帧
0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,
0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,
//第3帧
0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,
//第4
//第827帧
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00,
};
unsigned char code Segs_tab[]={
0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
};
unsigned char idata Rec_buf[64]={
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
***it Rest=P3^0;
void IO_Interrupt_UART_Init();
unsigned char T1_count=0,Anm1=0,Mode=0,Rec_count=0;
unsigned int End,Anm=0;
void main()
{
End=sizeof(table);
IO_Interrupt_UART_Init();
while(1)
{
if(Anm>End)Anm=0;
Segs=Segs_tab[Anm1];
switch (Mode)
{
case 0:Out=table[Anm1+Anm];break;
case 1:Out=Rec_buf[Anm1];break;
default:break;
}
}
}
void IO_Interrupt_UART_Init()
{
P0M1=0x00;
P0M0=0x00;
P1M1=0x00;
P1M0=0xff;
EA=1;
EX0=1;
IT0=1;
ET0=1;
ET1=1;
ES=1;
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x5C; //设置定时初值
TH0 = 0xF7; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
AUXR &= 0xBF; //定时器时钟12T模式
TMOD &= 0x0F; //设置定时器模式
TL1 = 0x00; //设置定时初值
TH1 = 0x70; //设置定时初值
TF1 = 0; //清除TF1标志
TR1 = 1; //定时器1开始计时
SCON = 0x50; //8位数据,可变波特率
AUXR |= 0x04; //定时器2时钟为Fosc,即1T
T2L = 0xD0; //设定定时初值
T2H = 0xFF; //设定定时初值
AUXR |= 0x01; //串口1选择定时器2为波特率发生器
}
void Button() interrupt 0
{
Mode=Mode+1;
if(Mode==1)
{
AUXR |= 0x10;
ET1=0;
TR1=0;
Anm=0;
Anm1=0;
}
if(Mode>1)IAP_CONTR=0x60;
}
void Display_delay() interrupt 1
{
TR0=0;
Anm1=Anm1+1;
if(Anm1>63)Anm1=0;
Out=0x00;
Segs=0xff;
TR0=1;
}
void LED_Display() interrupt 3
{
TR1=0;
T1_count++;
if(T1_count==Anm_speed)
{
T1_count=0;
Anm=Anm+64;
}
TR1=1;
}
void uart_receive() interrupt 4
{
unsigned char ch;
ES=0;
if(RI)
{
ch=SBUF;
Rec_buf[Rec_count]=ch;
Rec_count++;
if(Rec_count>63)Rec_count=0;
}
RI=0;
ES=1;
}
已退回10积分