发表于:2008-03-07 18:59:00
楼主
/*************************************************************************************/
#include
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar a,b,flag;
void main()
{
TMOD=0x20; //方式控制字
SCON=0x50; //
TH1=0xfd; //设置波特率为9600
TL1=0xfd;
TR1=1; //开定时器1
// REN=1; //
EA=1; //总中断允许
ES=1; //串口中断允许
while(1)
{ P0=table[a-0x30];
if(flag==1)
{
ES=0;
flag=0;
SBUF=a;
while(!TI);
TI=0;
ES=1;
}
}
}
void serial() interrupt 4
{
a=SBUF;
P1=0xf7;
flag=1;
RI=0;
}
单片机菜鸟群:17373243
单片机学习群:57464005
QQ:370302924