#include<reg52.h>
typedef unsigned char uint8;
sbit wela=P2^7;
uint8 code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71
};
void send_byte(uint8 dat) //发送数据
{
SBUF=dat;
P0=dat;
while(!TI);
TI=0;
}
void uart_init() //初始化
{
SCON=0x50;
TMOD=0X20;
TH1=0xfd;
TL1=0xfd;
REN=1;
TR1=1;
}
void main() //主函数
{
uart_init();
wela=1;
P0=0xfb;
wela=0;
send_byte(table[9]);
while(1);
}
|