//串口收不到数据
# include "recevie.h"
uint8 a = 0xff;
sbit led0 = P0^0;
void uart_init()
{ //SCON:SM0 SM1 SM2 REN TB8 RB8 TI RI
SCON = 0X50;//串口工作在方式1,不允许发送中断和接收中断(赋值50也行,本程序只有一个发送程序,故没让接收允许,REN=0)
TMOD = 0X20;//T1定时器工作在方式2,自动重装模式
TH1 = 0XFD;
TL1 = 0XFD;//T1定时器赋初值
TR1 = 1;
}
int uart_recevie ()
{
if (RI)
{
a = SBUF;
RI = 0;
led0 = 0;
}
return a;
}
void main ()
{
enled = 0;
addr3 = 1;
addr0 = 0;
addr1 = 1;
addr2 = 1;
uart_init();
P0 = uart_recevie ();
}
|