Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
高級會員
|
所以是要將原本high的改到low然後將timer4改到high就可以了嗎?
發表於: 2007/10/25 13:34
|
|||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
高級會員
|
你的意思是先測可以用之後在來測試用倍頻的方式、
還有一個問題就是因為我原本就有兩個uart port在會接收資料中斷、i/o port做的uart在傳送資料的鮑率是用timer4做我的每資接收uart的資料或是傳送uart資料時會另外用i/o port傳一筆資料出來、可是因為中斷的關係會不會影響我用timer做的鮑率呢? 我原本timer4中斷是用在high 後來改到low但這到底會有影響嗎? 因為我想接收資料的時候要等那鮑率應該會產生問題吧?
發表於: 2007/10/25 9:44
|
|||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
資深會員
|
你先把時脈設定調成HS,不要用PLL倍頻試試看。
我用CCS時,若是用倍頻UART會變亂碼。 或是更改下面這行的設定 #use delay(clock=4000000) 假設你用4MHz的XTAL,那PLL倍頻後應該要把上面的數值改成 16000000才對。CCS裡面,UART和DELAY_MS這類函數都會用到上面的設定。
發表於: 2007/10/25 8:34
|
|||
不要問我哪裡來,我只是個流浪天涯的工程師
|
||||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
高級會員
|
因為原本的兩組都已經在用了、所以要另外接一組做debug用
我之前有看到用軟體的i/o模擬rs232接收與傳送、的方法你可以幫我看一下嗎? 我會先用示波器量一下我的 Baud Rate http://www.microchip.com.tw/modules/n ... 813&forum=1#forumpost3340
發表於: 2007/10/24 15:14
|
|||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
版主
|
你要不要先用 MPLAB SIM 測量一下中斷時間已確定你的 Baud Rate。可以在 SIM 的 Setting 目錄下設OSC = 16MHz。
疑問 : PIC18F8622 有兩組 EUSART 為何不用,而要使用軟體模擬的功能呢?
發表於: 2007/10/24 14:59
|
|||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
高級會員
|
sorry!
我說明的不清楚、我是用i/o port來模擬rs232的輸出傳送資料、不是用內部的uart、在timer4是時間的設定、請問有i/o port的設定程式可以供參考嗎?
發表於: 2007/10/24 14:45
|
|||
|
Re: rs232傳送問題一問
|
||||
---|---|---|---|---|
版主
|
之前已經問過了,Baud Rate 確定對嗎? 還有 Protocal 呢?
傳送出去的資料要是不確定話可以用示波器良一下時間及解析一下資料格式,單用 Terminal 是部會告訴你哪裡錯了。底下是一段 18F4520 的 UART 的設定程式,供參考:
void Set_USART(void)
發表於: 2007/10/24 14:15
|
|||
|
rs232傳送問題一問
|
||||
---|---|---|---|---|
高級會員
|
我是原本是用18F6680後來改成18f8622
原本是使用timer2我後來改到timer4因為型態才相同。 osc 4Mhz 使用4倍頻所以是16MHz 以下是一些相關的設定、有大大能幫我看一下嗎 為什麼換成18f8622之後傳出的資料用電腦讀就變成亂碼了 18f6680換18f8622 void Dputc(uw8 cc) { uw16 i; Dbit = 0x0001; Ddata = 0xF007 | ((uw16)cc<<4);//61447 T4CONbits.TMR4ON = 1; i = 0; while(T4CONbits.TMR4ON) { if (i>RSWAIT_T2MS) break; _nop(); i++; } } if (PIR3bits.TMR4IF) { // Timer4 Interrupt for DBG (9600 bps). PIR3bits.TMR4IF = 0; TMR4 = 0; if (Ddata & Dbit) PORTEbits.RE7 = 1; else PORTEbits.RE7 = 0; Dbit <<= 1; if (Dbit==0x8000) T4CONbits.TMR4ON = 0; } TRISE = 0x10; INTCON = 0xE0; INTCON2 = 0x8E; INTCON3 = 0xB0; PIR1 = 0x0; PIR2 = 0x0; PIR3 = 0x0; PIE1 = 0x21; PIE2 = 0x0; PIE3 = 0xEA; IPR1 = 0x21; IPR2 = 0x0; IPR3 = 0xE2; RCON = 0x80;
發表於: 2007/10/24 10:00
|
|||
|