#include <reg52.h>
#include <function.h>//详见第六章第8讲
#include <timer.h> //详见第八章第11讲
u8 RXDBUF;
void
ConfigUART(u16 baud)
{
SCON = 0x50;
TMOD &= 0x0F;
TMOD |= 0x20;
TH1 = 256 - (11059200/12/32)/baud;
TL1 = TH1;
ET1 = 0;
ES = 1;
TR1 = 1;
}
void
main()
{
LED_Init();
EA = 1;
ConfigUART(9600);
TIM0_Init(1000,0);
while
(1)
{
ShowNumber(RXDBUF);
}
}
void
TIM0_IRQHandler() interrupt 1
{
TH0 = T0RH;
TL0 = T0RL;
SEG_Scan();
}
void
InterruptUART() interrupt 4
{
if
(RI)
{
RI = 0;
RXDBUF = SBUF;
SBUF = RXDBUF;
}
if
(TI)
{
TI = 0;
}
}