这个程序
#include <reg51.h>
#include <stdio.h>
void delay1ms()
{
unsigned int i;
for(i=500000;i>0;i--);
}
void InitUART(void) //串口波特率
{
TMOD = 0x20;
SCON = 0x50;
TH1 = 0xFD;
TL1 = TH1;
PCON = 0x00;
EA = 1;
ES = 1;
TR1 = 1;
}
void InitTimer0(void) //初始化定时器0
{
TMOD=0x01;
TH0=0x0DC;
TL0=0x00;
EA=1;
ET0=1;
TR0=1;
}
void main()
{
InitTimer0();
}
void Timer0()interrupt 1
{ unsigned int a=0;
unsigned char bur[4]={'A','1','2','0'};
InitUART();
while(a<4)
{
SBUF=bur[a++];
delay1ms();
}
TH0=0x0DC;
TL0=0x00;
} |