This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about send data by serial port

I try to write program about Serial interface but it invalid.
Can you recommend I abiut this?.
Are my source code correct?.
this program I try to send "0"


#include <reg51.h>

sbit PLLCON = 0xD7;

int N,i,x0;
float dat = 0;
void main(void)
{
/**********Define UART variable***************/
 SCON = 0x40;  //Serial mode1-->8-bits UART
PCON = 0x80;	//SMOD = 1
PLLCON = 0x50;
TMOD = 0x20; //Timer Mode2 8-bit auto-reload
TR1  = 1;  //set bit TR1 --> Timer1 Run
TH1  = -9;	//Baud rate = 9600
TL1  = -9;
TI   = 0;
/*********************************************/
	dat = 0x30;
	while(1)
	{

	TI = 0;
	SBUF = dat;
		while (~TI)
			TI  = 0;
	}
}


0