|
/*
* 延時(shí)
*/
void delay(uint16 n)
{
while (n--);
}
/*
* UART初始化
* 波特率:9600
*/
void UART_init(void)
{
SCON = 0x50; // 10位uart,允許串行接受
TMOD = 0x20; // 定時(shí)器1工作在方式2(自動(dòng)重裝)
TH1 = 0xFD;
TL1 = 0xFD;
TR1 = 1;
}
/*
* UART 發(fā)送一字節(jié)
*/
void UART_send_byte(uint8 dat)
{
SBUF = dat;
while (TI == 0);
TI = 0;
}
/*
* UART 發(fā)送字符串
*/
void UART_send_string(uint8 *buf)
{
while (*buf != '\0')
{
UART_send_byte(*buf++);
}
}
void main()
{
UART_init();
while (1)
{
UART_send_string(Buf);
delay(20000);
}
}
|
|