• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: 16F690 UART Rx 問題
#9
新會員
新會員


查看用戶資訊
感謝各位,我知道問題了。確實如 leowang 所說的,我沒注意到 Rx 與 AN11 是同一個腳位!

發表於: 2008/10/20 12:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 16F690 UART Rx 問題
#8
新會員
新會員


查看用戶資訊
Please add the code as below in Init()

ANSELH=0x00;
ANSEL=0x00;

For 16F690
The value of ANSELH & ANSEL are 0xFF after power on reset, so if you don’t clean to “0” ,then PIN5 (RB5/AN11/RX/DT) will be analog input.

發表於: 2008/10/17 15:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 16F690 UART Rx 問題
#7
新會員
新會員


查看用戶資訊
我發現在 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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 16F690 UART Rx 問題
#6
版主
版主


查看用戶資訊
感覺是接收有問題。試試看在接收中斷裡去 Toggle ㄧ個 I/O 輸出看看,是不是有收到 UART 的訊號且 I/O 腳會轉態輸出。

發表於: 2008/10/17 11:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 16F690 UART Rx 問題
#5
新會員
新會員


查看用戶資訊
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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 16F690 UART Rx 問題
#4
版主
版主


查看用戶資訊
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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


16F690 UART Rx 問題
#3
新會員
新會員


查看用戶資訊
請教各位幾個問題。我最近用 C programming 16F887 APP001 開發板來做一些測試,透過 UART 從 PC 輸入一些值,確定 RCREG 有收到資料。但是同樣的程式我換到 16F690 去測試發現 RCREG 好像沒有值,可是 16F690 無法進入 debug mode 所以沒辦法看 RCREG 的內容。16F690 是否需要額外的東西才可以進入 debug mode?有沒有人可以教一下單純透過 UART 寫值給 16F690 Rx 的觀念呢?

發表於: 2008/10/16 15:57
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------