Re: 請問各位大大有關uart接收資料的問題
|
||||
---|---|---|---|---|
新會員
|
樓上的大大感謝您熱心的回覆,我已經把INTCON=0B11000000
但是在超級終端機傳字元時還是沒有反應(同時我也用示波器量RX那支角,也沒有電位的改變)。到底是那裡出問題呢? 以下是我的程式,請各位大大幫我看一下,謝謝! ---------------------------------------------------------------------- #include <pic.h> __CONFIG (UNPROTECT & DEBUGEN & MCLRDIS & BOREN & PWRTEN & INTIO & WDTDIS & IESODIS & FCMDIS);// #define ClearScreen PutStr("\x1B[2J"); void InitPIC16F913(void); void PutStr(const char *data); void Show(void); void interrupt isr_rx(void); /*******************************************/ main() { InitPIC16F913(); ClearScreen while(1) { Show(); while(1) { if(!RB0)//按RB0傳"TXOK" { PutStr("TXOK"); while(!RB0); }; }; } } /*******************************************/ void InitPIC16F913(void) { OPTION = 0x07; OSCCON=0b01100101; OSCTUNE=0b00000000; TRISA = 0b00000000; TRISC = 0b10000000; TXSTA = 0b00100100; RCSTA = 0b10010000; SPBRG = 25; //9600,4Mhz,high speed baud rate PIE1=0b00100000; INTCON=0b11000000; }; /*******************************************/ void Show(void) { PutStr("\x1B[1;1H"); //goto col:1,row:1 PutStr("hello!!"); PutStr("\x1B[2;1H"); }; /*******************************************/ void PutStr(const char *data) { do { while(!(TXSTA & 0x02)); TXREG = *data; } while( *data++ ); }; /*******************************************/ void interrupt isr_rx(void)//若有收到字元將收到的字元傳出 { unsigned char tempres0; tempres0=RCREG; if(OERR || FERR) CREN=0; RCIF=0; while(!(TXSTA & 0x02)); TXREG = tempres0; }; ----------------------------------------------------------------
發表於: 2006/9/14 14:21
|
|||
|
Re: 請問各位大大有關uart接收資料的問題
|
||||
---|---|---|---|---|
中級會員
|
參照:
你只是啓動GLOBAL中斷,外設中斷還沒有被啓動!
發表於: 2006/9/13 17:02
|
|||
|
請問各位大大有關uart接收資料的問題
|
||||
---|---|---|---|---|
新會員
|
使用PIC 16F913 UART的功能連接PICDEM 2 PLUS DEMO BOARD與PC的超級終端機,可以很順利的從PIC 傳資料給PC並在超級終端機秀出來,但是始終無法從PC端傳送資料給PIC。超級終端機是否可在連線時直接由按KEYBOARD的方式傳送字元給COM PORT呢?
設定如下 PIC16F913 __CONFIG (UNPROTECT & DEBUGEN & MCLRDIS & BOREN & PWRTEN & INTIO & WDTDIS & IESODIS & FCMDIS); OPTION = 0x07; OSCCON=0b01100101; OSCTUNE=0b00000000; TRISA = 0b11111111; TRISC = 0b10000000; ADCON1 = 0x00; TXSTA = 0x24; RCSTA = 0x90; SPBRG = 25; BAUD RATE 9600 PIE1=0b00100000; INTCON=0b10000000; 但始終我的RCIF都不會等於1,到底是那裡出問題呢?請各位大大幫幫忙,感激不盡!
發表於: 2006/9/13 11:47
|
|||
|