基于stc15f2k60s2芯片单片机编程(串口)

#include 

void UartInit();

void main()
{
P2=0xa0;P0=0X00;
UartInit();

}
void UartInit(void)		//[email protected]
{
	SCON = 0x50;		//8???,?????
	AUXR |= 0x40;		//???1???Fosc,?1T
	AUXR &= 0xFE;		//??1?????1???????
	TMOD &= 0x0F;		//?????1?16???????
	TL1 = 0xC0;		//??????
	TH1 = 0xFD;		//??????
	ET1 = 0;		//?????1??
	TR1 = 1;		//?????1
	EA=1;
	ES=1;
}

void jieshou()interrupt 4
{
	unsigned char receiveData;

	receiveData=SBUF;  //出去接收到的数据
	RI = 0;  //清除接受中断标志位
	SBUF=receiveData;  //将接受到的数据放入到发送寄存器
	while(!TI);	//等待发送数据完成
	TI=0;//清除发送完成标志位						

}

你可能感兴趣的:(基于stc15f2k60s2芯片单片机编程(串口))