#include <reg52.h>
sbit LED1 = P2^0;
sbit LED2 = P2^3;
unsigned char tempbuf;
/*初始化串口*/
void BlueteethInit()
{
SCON = 0x50;
TMOD = 0x20;
PCON = 0x00;
REN = 1;
TH1 = 0xfd; //设置波特率为9600
TL1 = 0xfd;
RI = 0;
EA = 1;
ES = 1;
TR1 = 1;
}
void main()
{
BlueteethInit();
LED1=1;
LED2=1;
TI = 0;
while(1)
{
if(tempbuf==1)
LED1=0;
if(tempbuf==2)
LED2=0;
}
}
void Serial(void) interrupt 4
{
tempbuf = SBUF;
RI = 0; //读标志清零
SBUF = tempbuf; //将内容返回到手机端,可在手机查看发送的内容
while(!TI);
TI = 0; //写标志清零
}
哪里的问题啊,接收到的都是乱码,hc05默认的波特率9600,
|