这个程序的串口发送怎么停不下来
时间:10-02
整理:3721RD
点击:
如题,最近在学51串口,本程序就是想通过串口发送一个字符串“hello world!”。预期目标单片机上电后,通过串口调试助手应该只能收到一个“hello world!”,但实际是一直不停的发,请问是什么原因呢?
#include<reg52.h>
void Delay(unsigned char t)
{
while(t--);
}
void sendchar(unsigned char c)
{
SBUF=c;
while(!TI);
TI=0;
}
void sendchars(unsigned char *s)
{
while(*s!='\0')
{
sendchar(*s);
s++;
Delay(20);
}
}
void main()
{
SCON = 0X50;
TMOD = 0X20;
TH1 = TL1 = 0XFD;
TR1 = 1;
//ES = 1;
//EA = 1;
sendchars("hello world!");
}
#include<reg52.h>
void Delay(unsigned char t)
{
while(t--);
}
void sendchar(unsigned char c)
{
SBUF=c;
while(!TI);
TI=0;
}
void sendchars(unsigned char *s)
{
while(*s!='\0')
{
sendchar(*s);
s++;
Delay(20);
}
}
void main()
{
SCON = 0X50;
TMOD = 0X20;
TH1 = TL1 = 0XFD;
TR1 = 1;
//ES = 1;
//EA = 1;
sendchars("hello world!");
}