#include
#include "delay.h"
#include
void uart_init()
{
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xfd;
TR1 = 1;
}
void uart_send_byte(unsigned char byte)
{
SBUF = byte;
while(!TI);
TI = 0;
}
void uart_send_str(unsigned char *s)
{
while((*s) != '\0')
{
uart_send_byte(*s);
s++;
}
}
void main()
{
unsigned char temp [10];
unsigned char i = 0;
uart_init();
uart_send_str("PLEASE input a string\n");
while(1)
{
if(RI)
{
temp[i] = SBUF;
if(temp[i] == ' ')
{
temp[i] = '\n';
i = 0;
uart_send_str("your input string is:");
uart_send_str(temp);
}
else
{
i++;
}
RI = 0;
}
}
}
串口显示字符
最新推荐文章于 2024-07-01 18:36:19 发布