#include......
#pragma vector uart_isp @ 0x10;
unsigned int data;
void delay(unsigned int time)//延時函數,省略內容
{......
}
void uart_init()//初始化函數
{
_urc1=0x80;
_urc2=0xe4;
_brg=51;
_euri=1;//開串口中斷
_emi=1;//開總中斷
}
void uart_send(unsigned int data)//發送函數
{
unsigned int i;
_txen=1;
i=_usr;
_txr_rxr=data;
while(~_tidle);
}
void uart_isp()//接收函數
{
a[0]=a1];
a[1]=a[2];
data=_txr_rxr;
while(~_ridle);
}
void main()
{
uart_init();
while(1)
{
uart_send(w[0]);
uart_send(w[1]);
uart_send(w[2]);
delay(..)//延時
}
盛群單片機HT46的串口通信,目的是發送三個自己從鍵盤輸入的字符給單片機,然后單片機發送一樣的字符到電腦;
為什么實現不了,求正確例程與解釋
歡迎光臨 (http://m.zg4o1577.cn/bbs/) | Powered by Discuz! X3.1 |