[問題] 判斷SBUF接收內容

作者: rey619 (Jeffrey)   2014-04-24 11:05:54
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
keil_c
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
如何正確判斷SBUF裡的內容 然後做相對應的程式碼
餵入的資料(Input):
預期的正確結果(Expected Output):
搭配超級終端機 按下電腦鍵盤W 做程式一
若不是W鍵 則進入程式二
錯誤結果(Wrong Output):
無論按下哪顆按鍵 都只會執行同個程式
判斷式 if(SBUF = 'W')功能一 else 功能二 .. => 永遠執行程式一
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <at89x51.h>
#include <stdio.h>
void delay_ms(unsigned int ms);
define uchar unsigned char
void UART_init (unsigned int bps) ;
void delay (int);
void delay(int msec) {
int i = 1000;
while(msec
作者: peng978   2014-04-24 21:49:00
'w'我搞錯了別理會...
作者: peoplewc (dong')   2014-05-30 11:57:00
當你接受到w時你要吧 SBUF清掉不然都會一直執行 程式

Links booklink

Contact Us: admin [ a t ] ucptt.com