|
#include "STC12C5A60S2.H"
#include "intrins.H"
#define uchar unsigned char
#define uint unsigned int
uchar Send_Busy = 0;
uchar Receive_Busy= 0;
uchar i=0;
void UART_init(void)
{
SM0=0;
SM1=1;
REN=1;
BRT=0xFD;
AUXR=0x15;
ES=1;
IPH=0x10;
IP=0x10;
EA=1;
}
void send_byte(uchar byte)
{
SBUF=byte;
while(!TI);
TI=0;
}
void printf(uchar*p)
{
while(*p!='\0')
{
send_byte(*p);
p++;
}
}
void UART_ISR(void) interrupt 4
{
if(RI)
{
RI=0;
i=SBUF;
Receive_Busy= 0;
if(TI)
{
TI=0;
Send_Busy = 0;
}
}
}
void main()
{
UART_init();
while(1)
{
//printf("0x5A 0xA5 0x05 0x82 0x00 0x00 0x00 0x64");
// send_byte(0x5A);
//send_byte(0xA5); //Ö¡í·
//send_byte(0x05); //êy¾Y3¤¶è
//send_byte(0x82); //Ö¸¶¨êy¾YμØÖ·D′èë×Ö·û
//send_byte(0x00);
//send_byte(0x00);//0x0000 ¼Ä′æÆ÷μØÖ·
//send_byte(0x00);
send_byte(0x64);
//printf("hellow");
}
// if(TI)
// {
// TI=0;
// Send_Busy = 0;
// }
// }
}
这是我的串口程序 波特率112500 让他发0x64时 但是用串口调试显示时显示16 91 64 不知道怎么回事 发送字符串串时 有时能正常发送 有时显示乱码
|
|