普中51单片机学习(串口通信)-实验代码

时间:2024-02-26 09:01:44
#include "reg52.h"
typedef unsigned char u8;
typedef unsigned int u16;


void UsartInit()
{
	TMOD|=0X20;
	TH1=0XF3;
	TL1=0XF3;
	PCON=0X80;
	TR1=1;
	SCON=0X50;
	ES=1;
	EA=1;
}

void main(){
	UsartInit();
	while(1);
}

void Usart() interrupt 4
{
	u8 receiveData;
	receiveData=SBUF;
	RI=0;
	SBUF=receiveData;
	while(!TI);
	TI=0;
}