• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: rs232傳送問題一問
#9
高級會員
高級會員


查看用戶資訊
所以是要將原本high的改到low然後將timer4改到high就可以了嗎?

發表於: 2007/10/25 13:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#8
版主
版主


查看用戶資訊
如果 Timer4 設在 Hi-Priority Interrupt,其餘的 UART 硬體中斷設為 Low-Priority 的話那Timer4的 Baud Rate 的產生就不會受其他的中斷影響。

你現在將 Timer4 的中斷改到 Low-Priority 的話應該是會被影響到的,就看你在 Hi-Priority 中斷底花了多少時間才出來。

發表於: 2007/10/25 11:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#7
高級會員
高級會員


查看用戶資訊
你的意思是先測可以用之後在來測試用倍頻的方式、
還有一個問題就是因為我原本就有兩個uart port在會接收資料中斷、i/o port做的uart在傳送資料的鮑率是用timer4做我的每資接收uart的資料或是傳送uart資料時會另外用i/o port傳一筆資料出來、可是因為中斷的關係會不會影響我用timer做的鮑率呢?
我原本timer4中斷是用在high 後來改到low但這到底會有影響嗎?
因為我想接收資料的時候要等那鮑率應該會產生問題吧?

發表於: 2007/10/25 9:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#6
資深會員
資深會員


查看用戶資訊
你先把時脈設定調成HS,不要用PLL倍頻試試看。
我用CCS時,若是用倍頻UART會變亂碼。

或是更改下面這行的設定
#use delay(clock=4000000)

假設你用4MHz的XTAL,那PLL倍頻後應該要把上面的數值改成
16000000才對。CCS裡面,UART和DELAY_MS這類函數都會用到上面的設定。


發表於: 2007/10/25 8:34
不要問我哪裡來,我只是個流浪天涯的工程師
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#5
高級會員
高級會員


查看用戶資訊
因為原本的兩組都已經在用了、所以要另外接一組做debug用
我之前有看到用軟體的i/o模擬rs232接收與傳送、的方法你可以幫我看一下嗎?
我會先用示波器量一下我的 Baud Rate
http://www.microchip.com.tw/modules/n ... 813&forum=1#forumpost3340

發表於: 2007/10/24 15:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#4
版主
版主


查看用戶資訊
你要不要先用 MPLAB SIM 測量一下中斷時間已確定你的 Baud Rate。可以在 SIM 的 Setting 目錄下設OSC = 16MHz。

疑問 : PIC18F8622 有兩組 EUSART 為何不用,而要使用軟體模擬的功能呢?

發表於: 2007/10/24 14:59
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#3
高級會員
高級會員


查看用戶資訊
sorry!
我說明的不清楚、我是用i/o port來模擬rs232的輸出傳送資料、不是用內部的uart、在timer4是時間的設定、請問有i/o port的設定程式可以供參考嗎?

發表於: 2007/10/24 14:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: rs232傳送問題一問
#2
版主
版主


查看用戶資訊
之前已經問過了,Baud Rate 確定對嗎? 還有 Protocal 呢?
傳送出去的資料要是不確定話可以用示波器良一下時間及解析一下資料格式,單用 Terminal 是部會告訴你哪裡錯了。底下是一段 18F4520 的 UART 的設定程式,供參考:
void Set_USART(void)
{

        
TXSTA 0// CLEAR THE LOAD REGS
        
RCSTA 0;

      
TRISC =0x80;
    
RCSTAbits.SPEN 1;  // ENABLING THE USART Tx AND Rx 
    
RCSTAbits.CREN 1// ENABLING THE CONTINOUS  RECEIVE 
    
RCSTAbits.RX9 0;;// DISABLE 9TH BIT RECEIVE
    
        
PIR1bits.TXIF 0;  
    
TXSTAbits.SYNC 0;   // ASYNCH MODE
    
TXSTAbits.BRGH =1;   // HIGH BAUD RATE
    
TXSTAbits.TXEN =1;  // ENABLE TRANSMISSION
    
TXSTAbits.TX9 =0;     // DISABLE 9TH BIT TRANSMISSION
    
     
SPBRG =51;   // BAUD OF 19200 with 16MHz

   
}

     
void ClsUSART(void)
   {
      
RCSTA 0b01001111;  // Disable the receiver
      
TXSTAbits.TXEN 0;   // and transmitter

      
PIE1 0b11001111;   // Disable both interrupts
    
}

發表於: 2007/10/24 14:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


rs232傳送問題一問
#1
高級會員
高級會員


查看用戶資訊
我是原本是用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
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... ]

教育訓練中心

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