#include......
#pragma vector uart_isp @ 0x10;
unsigned int data;
void delay(unsigned int time)//延時(shí)函數(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(..)//延時(shí)
}
盛群單片機(jī)HT46的串口通信,目的是發(fā)送三個(gè)自己從鍵盤輸入的字符給單片機(jī),然后單片機(jī)發(fā)送一樣的字符到電腦;
為什么實(shí)現(xiàn)不了,求正確例程與解釋
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |