標(biāo)題:
單片機(jī)串口通信,上位機(jī)一直接受不到數(shù)據(jù) 求幫助
[打印本頁(yè)]
作者:
51_users
時(shí)間:
2020-11-10 22:37
標(biāo)題:
單片機(jī)串口通信,上位機(jī)一直接受不到數(shù)據(jù) 求幫助
#include <reg52.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
void Init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
SCON=0x50;
EA=1;
ES=1;
TR1=1;
}
void delayms(int z)
{
int i,j;
for(i=z;i>0;i--)
for(j=114;j>0;j--);
}
void SendByte(uchar transdata)//發(fā)送字符
{
SBUF=transdata;
while(!TI)
TI=0;
}
void SendStr(uchar *p)//處理字符串
{
int i=0;
while(p[i]!='\0')//運(yùn)用將字符串處理成字符
{
SendByte(p[i]);
i++;
}
}
void SendEnd()
{
SendByte(0xFF);
SendByte(0xFF);
SendByte(0xFF);
}
void main()
{
Init();
while(1)
{
delayms(500);
SendStr("t1.txt=\"Welcome!\"");
SendEnd();
}
}
復(fù)制代碼
這是用于淘晶馳串口屏的接受代碼,上位機(jī)一直接受不到數(shù)據(jù),請(qǐng)教一下大家這個(gè)代碼中存在問(wèn)題嗎???在此謝過(guò)。
作者:
wulin
時(shí)間:
2020-11-11 07:36
while(!TI)后面少分號(hào)
void SendByte(uchar transdata)//發(fā)送字符
{
SBUF=transdata;
while(!TI);
TI=0;
}
作者:
51_users
時(shí)間:
2020-11-11 13:59
wulin 發(fā)表于 2020-11-11 07:36
while(!TI)后面少分號(hào)
void SendByte(uchar transdata)//發(fā)送字符
{
十分感謝!。
作者:
壓著我頭發(fā)啦
時(shí)間:
2020-11-11 14:39
編譯時(shí)候沒(méi)報(bào)錯(cuò)么
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1