Re: UART範例程式問題
|
||||
---|---|---|---|---|
版主
|
10 是由兩個 ASCII Code 所組成的,其值為 0x31 及 0x30 ,而 Rec_buffer卻是只有一個byte,所以不可以這樣比的。
你必須先將 Rec_Buffer 先存道一個陣列裏,直到收到結束位元組後在一次做比較的。
發表於: 2008/10/24 15:52
|
|||
|
Re: UART範例程式問題
|
||||
---|---|---|---|---|
版主
|
f (Rec_Count>=3)
{ setcurLCD(0,1) ; // 一定要顯示嗎? Rec_Count=0; //錯在這裡 因為 Rec_Count 大於三時你又把它清為零所遠無法超過 4 當然就不會有超過 100 得計數,建議再加入一組count 來區別一下。
發表於: 2008/10/21 10:38
|
|||
|
Re: UART範例程式問題
|
||||
---|---|---|---|---|
新會員
|
想在請問一下板主,因為我是用APP020學習板,例如我要從LabVIEW傳個100的字串给PIC,然後要讓APP020的LED1亮,再傳個101的字串就讓LED1滅,想請問版主我要如何去抓這些字串,我是想利用你的程式去改,我執行結果就是當我LabVIEW不管傳什麼值都只會讓LED1亮,我抓取字串程式如下,其他程式都參照範例程式
while (1) { while ( !Rec_Flag) ; Rec_Flag=0; putcLCD(Rec_Buffer); Rec_Count++; if (Rec_Count>=3) { setcurLCD(0,1) ; Rec_Count=0; } if(Rec_Buffer==100); { LED1 = 0; } if(Rec_Buffer==101); { LED1 = 1; } } }
發表於: 2008/10/20 20:56
|
|||
|
Re: UART範例程式問題
|
||||
---|---|---|---|---|
版主
|
這就是接收電腦傳來的字,程式採中斷方式接收並將將收到的可顯示的 ASCII Code 送給 LCD 的第二行顯示。
putcLCD(Rec_Buffer); //呼叫 LCD 顯示函數,顯示接收到的字元 Rec_Count++; if (Rec_Count>=16) //LCD 一行顯示16個字 { setcurLCD(0,1) ; //Course 設再第二行, 第一個位置 Rec_Count=0;
發表於: 2008/10/17 8:56
|
|||
|
Re: UART範例程式問題
|
||||
---|---|---|---|---|
新會員
|
感謝版主的熱心回答,想在請教一下板主if (Rec_Count>=16)的Rec_Count是代表什麼意思?還有就是我現在只要接受到電腦傳來的字,那就只要
putcLCD(Rec_Buffer); Rec_Count++; if (Rec_Count>=16) { setcurLCD(0,1) ; Rec_Count=0; } 就可以了嗎?也麻煩可以解釋一下這段程式的動作嗎?謝謝!!!
發表於: 2008/10/16 19:32
|
|||
|
Re: UART範例程式問題
|
||||
---|---|---|---|---|
版主
|
這程式是我寫的,說明如下 :
SRbits.IPL=4; 設定 CPU 的中斷優先權為 4 ,而 UART 的接收中斷優先權設為 6 。在這裡設的ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR6 & UART_TX_INT_DIS & UART_TX_INT_PR2); if (Rec_Buffer==0x0d) 判斷街道的字元為按鍵的 Enter key 其值為 0x0D,如果收到 0x0D 則表示收到結速控制字元。
發表於: 2008/10/16 9:20
|
|||
|
UART範例程式問題
|
||||
---|---|---|---|---|
新會員
|
想請教各位前輩,小弟有在下載中心下載課程裡的一個關於UART的範例程式,範例程式如下,想請教關於下列兩行紅色部份是表示什麼,還有小弟是個新手想請教一下Rec_Buffer是代表讀取由電腦傳來的值嗎?謝謝!!!
/************************************************************/
發表於: 2008/10/15 22:40
Edited by Ryang on 2008年10月16日 09:21:45
Edited by Ryang on 2008年10月16日 09:22:20 |
|||
|