#include <reg52.h>
#include "./delay/delay.h"
#include<stdio.h>
unsigned char i = 0;
unsigned char src[10];
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 uart_init()
{
SCON = 0x50;
TMOD = 0x20;
TH1 = 0xfd;
TR1 = 1;
EA = 1;
ES = 1;
}
void uart_isr() interrupt 4
{
if(RI)
{
if(SBUF != 0x20)
{
src[i] = SBUF;
i++;
}
else
{
src[i] = '\0';
i = 0;
uart_send_str(src);
uart_send_byte('\n');
}
RI = 0;
}
}
void main()
{
uart_init();
uart_send_str("Pleas input a string:\n");
while(1);
}
#include "./delay/delay.h"
#include<stdio.h>
unsigned char i = 0;
unsigned char src[10];
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 uart_init()
{
SCON = 0x50;
TMOD = 0x20;
TH1 = 0xfd;
TR1 = 1;
EA = 1;
ES = 1;
}
void uart_isr() interrupt 4
{
if(RI)
{
if(SBUF != 0x20)
{
src[i] = SBUF;
i++;
}
else
{
src[i] = '\0';
i = 0;
uart_send_str(src);
uart_send_byte('\n');
}
RI = 0;
}
}
void main()
{
uart_init();
uart_send_str("Pleas input a string:\n");
while(1);
}