单片机串口通信中的字符串输出问题

为什么串口通信中不用while(TI)输出的字符串就会出现输出字符串乱码

# include "reg52.h"
# include "intrins.h"

sfr AUXR = 0x8e;

void UartInit()
{
    SCON |= 0x50;
    PCON &= 0x00;
    AUXR |= 0x01;
    
    TMOD |= 0x20;
    
    TL1 = 0xFD;
    TH1 = 0xFD;
    
    TCON = 0x40;    
}

void Delay1000ms()        //@11.0592MHz
{
    unsigned char i, j, k;

    _nop_();
    _nop_();
    i = 43;
    j = 6;
    k = 203;
    do
    {
        do
        {
            while (--k);
        } while (--j);
    } while (--i);
}




void startputzifuchuan(char *str)
{
    while(*str != '\0')
    {
        SBUF = *str;
        while(!TI);
        TI = 0;
        ++str;
}
}
void main()
{
    UartInit();
    while(1)
    {
        Delay1000ms();
        startputzifuchuan("hello word\r\n");
}
}

img

# include "reg52.h"
# include "intrins.h"

sfr AUXR = 0x8e;

void UartInit()
{
    SCON |= 0x50;
    PCON &= 0x00;
    AUXR |= 0x01;
    
    TMOD |= 0x20;
    
    TL1 = 0xFD;
    TH1 = 0xFD;
    
    TCON = 0x40;    
}

void Delay1000ms()        //@11.0592MHz
{
    unsigned char i, j, k;

    _nop_();
    _nop_();
    i = 43;
    j = 6;
    k = 203;
    do
    {
        do
        {
            while (--k);
        } while (--j);
    } while (--i);
}




void startputzifuchuan(char *str)
{
    while(*str != '\0')
    {
        SBUF = *str;
        ++str;
}
}
void main()
{
    UartInit();
    while(1)
    {
        Delay1000ms();
        startputzifuchuan("hello word\r\n");
}
}

img

TI是发送完成标志,你不等待前面发完就往串口里塞新的数据,当然就乱了。