Re: 16F690 UART Rx 問題
|
||||
---|---|---|---|---|
新會員
|
感謝各位,我知道問題了。確實如 leowang 所說的,我沒注意到 Rx 與 AN11 是同一個腳位!
發表於: 2008/10/20 12:34
|
|||
|
Re: 16F690 UART Rx 問題
|
||||
---|---|---|---|---|
新會員
|
我發現在 16F887 上利用接收中斷來控制 LED (PORTD) 亮或不亮很正常,一樣的程式放在 16F690 在接收中斷控制 RA5 為 1 或 0 卻沒動作。我試過 16F690 若是只在 main() 做 PORTA ^= 0x20 則 RA5 用電表量是會 High Low 持續切換,16F690 Rx 的腳位我用示波器量測在 PC 輸入資料時是有訊號的。我的程式如下 (baud rate: 2400),不知道我有哪裡弄錯了嗎?
#include <pic.h> //#include "pic16f685.h" #include "pic16f887.h" void Init(void); void RcInit(void); void Delay_x_mS(int); void interrupt ISR(void); void Init() { INTCON = 0x00; PIE1 = 0x00; PIE2 = 0x00; } void RcInit() { TRISD = 0x00; PORTD = 0x00; //TRISA5 = 0; //PORTA &= 0xDF; TXSTA = 0x20; RCSTA = 0x80; SPBRG = 25; //********** PIR1 = 0x00; RCIE = 1; //^^^^^^^^^^ CREN = 1; } void Delay_x_mS(int N_mS) { int Loop_mS, Del_1mS; for (Loop_mS = 0; Loop_mS < N_mS; Loop_mS++){ for (Del_1mS = 0; Del_1mS < 199; Del_1mS ++){ asm("nop"); asm("nop"); } } } void interrupt ISR(void) { unsigned char i; //PORTA ^= 0x20; PORTD ^= 0xFF; i = RCREG; } void main() { Init(); RcInit(); GIE = 1; PEIE = 1; while(1) { //PORTA ^= 0x20; //Delay_x_mS(400); } }
發表於: 2008/10/17 13:36
|
|||
|
Re: 16F690 UART Rx 問題
|
||||
---|---|---|---|---|
版主
|
感覺是接收有問題。試試看在接收中斷裡去 Toggle ㄧ個 I/O 輸出看看,是不是有收到 UART 的訊號且 I/O 腳會轉態輸出。
發表於: 2008/10/17 11:45
|
|||
|
Re: 16F690 UART Rx 問題
|
||||
---|---|---|---|---|
新會員
|
Thanks,那我了解為什麼 16F690 無法進 debug mode 了。至於 16F690 UART Rx 的問題,我有先在 16F887 APP001 開發板上測試,在 Rx 中斷函式裡面寫 TXREG = RCREG,可以看到從 PC 輸入一個字,16F887 就會回傳同一個字給 PC。但是同樣的 code 放到 16F690 卻沒有反應,如果改為單純在 main() 裡面讓 TXREG = 0x38,PC 就會一直收到 8 這個字,所以確定 Tx 沒問題。不知道我有什麼地方漏掉了嗎?
發表於: 2008/10/17 11:32
|
|||
|
Re: 16F690 UART Rx 問題
|
||||
---|---|---|---|---|
版主
|
PIC16F690 是屬於低單價的元件,所以沒有內建 Debug Module,利用 ICD2 除錯時要有專用的除錯轉換腳座。
http://www.microchipdirect.com/produc ... ch.aspx?Keywords=ac162061 PIC16F887 與 PIC16F690 都是 EUSART 的架構,如果在 887 可以執行在 690 應一樣可以執行,因為你沒有除錯器可以使用,所以建議你再程式裡用 I/O 送出點 LED 的狀態這樣就比較容易瞭解程式執行的動作是否正常。
發表於: 2008/10/17 8:12
|
|||
|
16F690 UART Rx 問題
|
||||
---|---|---|---|---|
新會員
|
請教各位幾個問題。我最近用 C programming 16F887 APP001 開發板來做一些測試,透過 UART 從 PC 輸入一些值,確定 RCREG 有收到資料。但是同樣的程式我換到 16F690 去測試發現 RCREG 好像沒有值,可是 16F690 無法進入 debug mode 所以沒辦法看 RCREG 的內容。16F690 是否需要額外的東西才可以進入 debug mode?有沒有人可以教一下單純透過 UART 寫值給 16F690 Rx 的觀念呢?
發表於: 2008/10/16 15:57
|
|||
|