#include......
#pragma vector uart_isp @ 0x10; unsigned int data;
void delay(unsigned int time)//延時函數(shù),省略內(nèi)容 {...... }
void uart_init()//初始化函數(shù) { _urc1=0x80; _urc2=0xe4; _brg=51; _euri=1;//開串口中斷 _emi=1;//開總中斷 }
void uart_send(unsigned int data)//發(fā)送函數(shù) { unsigned int i; _txen=1; i=_usr; _txr_rxr=data; while(~_tidle); } void uart_isp()//接收函數(shù) { 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的串口通信,目的是發(fā)送三個自己從鍵盤輸入的字符給單片機,然后單片機發(fā)送一樣的字符到電腦; 為什么實現(xiàn)不了,求正確例程與解釋
[此貼子已經(jīng)被作者于2012-1-6 19:30:56編輯過]
|