• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 使用APP023-1 USART接收問題(18F8680)
#8
高級會員
高級會員


查看用戶資訊
多謝各位了~終於找到真正原因了...原來是超級終端機那邊有個流量限制, 因為預設是 "硬體" ,我把它改成無 就能收的到訊號了... 感恩~~

發表於: 2007/12/10 8:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#7
資深會員
資深會員


查看用戶資訊
i found a short example in PICDEM FS USB

//RS-232 Setup for pic18 USB series
        
TRISCbits.TRISC7=1// RX
        
TRISCbits.TRISC6=0// TX
        
SPBRG 0x71;
        
SPBRGH 0x02;      // 0x0271 for 48MHz -> 19200 baud
        
TXSTA 0x24;       // TX enable BRGH=1
        
RCSTA 0x90;       // continuous RX
        
BAUDCON 0x08;     // BRG16 = 1
        
temp RCREG;       // Empty buffer
        
temp RCREG;       // Empty buffer
        
        //RS-232 Tx & Rx Tests
        //while(!Switch3IsPressed());
        
TXbyte('R');
        
TXbyte('S');
        
TXbyte('-');
        
TXbyte('2');
        
TXbyte('3');
        
TXbyte('2');
        
TXbyte(' ');
        
TXbyte('T');
        
TXbyte('X');
        
TXbyte(' ');
        
TXbyte('T');
        
TXbyte('e');
        
TXbyte('s');
        
TXbyte('t');
        
TXbyte(' ');
        
TXbyte('O');
        
TXbyte('K');
        
TXbyte(',');
        
TXbyte(' ');
        
TXbyte('P');
        
TXbyte('r');
        
TXbyte('e');
        
TXbyte('s');
        
TXbyte('s');
        
TXbyte(' ');
        
TXbyte('"');
        
TXbyte('r');
        
TXbyte('"');
        
TXbyte(',');
        while(
PIR1bits.RCIF==0);  //Wait for data from RS232
        
if(RCREG == 'r')
        {
            
TXbyte(' ');
            
TXbyte('R');
            
TXbyte('X');
            
TXbyte(' ');
            
TXbyte('T');
            
TXbyte('e');
            
TXbyte('s');
            
TXbyte('t');
            
TXbyte(' ');
            
TXbyte('O');
            
TXbyte('K');
        }
//end if


文中 TRISCbits.TRISC6=0, 他用的是 pic18 USB 系列 你自己斟酌看看

SPBRG, SPBRGH 要根據 Fosc 調整

參照:

For a device with FOSC of 16 MHz, desired baud rate of 9600, Asynchronous mode, 8-bit BRG:
Desired Baud Rate = FOSC/(64 ([SPBRGH:SPBRG] + 1))
Solving for SPBRGH:SPBRG:
X = ((FOSC/Desired Baud Rate)/64) – 1
= ((16000000/9600)/64) – 1
= [25.042] = 25
Calculated Baud Rate= 16000000/(64 (25 + 1))
= 9615
Error = (Calculated Baud Rate – Desired Baud Rate)/Desired Baud Rate
= (9615 – 9600)/9600 = 0.16%


TXSTA, RCSTA 請對照 data sheet, 跟你 PC terminal 的設定也有關

另一點 硬體插斷先 disable, 用軟體 polling 的方式

while(PIR1bits.RCIF==0); 這一步會等收到 data 才繼續

RCREG == 'r'; 或 temp = RCREG; 會去buffer 讀資料 並 clear PIR1bits.RCIF...

void TXbyte(byte data)
{
    while(
TXSTAbits.TRMT==0);
    
TXREG data;
}
//end TXbyte


發表於: 2007/12/7 14:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#6
資深會員
資深會員


查看用戶資訊
DSW2 pin3,4 要 on
你由電腦送信號時 那 DSW2 旁的 LED16 (RX) 有沒有反應 LED15 是 TX

至於範例 有 Pic16 or dsPic30 右邊範例程式(29)有 pic16 的

pic18 我再找找

發表於: 2007/12/7 13:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#5
新會員
新會員


查看用戶資訊
可以去掉Tx只保留Rx試試看摟(IPR1只留RCIP)
或是貼一下code大家來debug

發表於: 2007/12/7 13:28
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#4
高級會員
高級會員


查看用戶資訊
多謝T大的提醒~但是我已經把 TRISC 全都設定為1了,也是不行.您是否有code 能直接給我test一下呢?

發表於: 2007/12/7 10:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#3
資深會員
資深會員


查看用戶資訊
我看了一下 18F8680 的 DataSheet 越來越發現 Microchip 的奧妙

參照:

In order to configure pins RC6/TX/CK and RC7/RX/DT
as the Universal Synchronous Asynchronous Receiver
Transmitter:
• SPEN (RCSTA<7>) bit must be set (= 1),
• TRISC<6> bit must be set (= 1), and
• TRISC<7> bit must be set (= 1).


表示 bit<7:6> 都必須設成 1

感覺上 在設這些 I/O pin 在 pic16, pic18, dsPic30 都有點不太一樣 尤其在 pic16 若 pin 有 analog 的功能 還要 disable ANSEL 才能讀 digital 的資料 我為了這個花了兩個鐘頭把 datasheet 讀了好幾遍 才找出原因

發表於: 2007/12/6 14:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 使用APP023-1 USART接收問題(18F8680)
#2
高級會員
高級會員


查看用戶資訊
= =" 都沒人回答,我從新補充清楚一點好了.
PIE1 00100000B
// Bit5 :1=RCIE Enable

PIR1 00010000B
// Bit4 :1=TXIE Enable

IPR1 11111111B
//全部中斷設定成高優先權
(包含 RCIP 跟TXIP)

RCON 10011100B
//Bit7:IPEN 1=Enable priority
//Bit4:~RI Reset Instruction Flag
//Bit3:~TO Watch dog Time out Flag
//Bit2:~PD Power-down Detection Flag
(Bit2~Bit4 這些設定有錯嗎?)

INTCON 10000001B
//Bit7 :1=GIE/GIEH Enable

TXSTA 10100110B
//Bit7:CSRC Don't care (Asyn mode)
//Bit5:TXEN 1=Transmit Enable
//Bit2:BRGH 1=High speed
//Bit1:TRMT 1=TSR empty

RCSTA 10010000B
//Bit7:SPEN 1=Serial Port Enable
//Bit4:CREN 1=Enable receiver (Asyn)

TRISC 10111111B
//把RC6 設定為輸出~RC7 設定為輸入

請問大家 我還有哪些東西是沒注意到的呢? 用了好久都用不出來.好困擾....

發表於: 2007/12/6 9:42
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


使用APP023-1 USART接收問題(18F8680)
#1
高級會員
高級會員


查看用戶資訊
小弟我使用這片練習版 想試著使用 RS-232 跟電腦超級終端機發送訊號.目前
我用PIC 發出字元,超級終端機都收的到,
但是我使用超級終端機發送字元PIC 卻收不到 不知到是哪裡有問題,
RCREG 裡面 一直都沒有資料...檢查後的結果
我的一些REG內容是這樣的...
PIE1 00100000B
PIR1 00010000B
IPR1 11111111B
RCON 10011100B
INTCON 10000001B
TXSTA 10100110B
RCSTA 10010000B
TRISC 10111111B

麻煩請大家幫個忙~

發表於: 2007/12/5 10:14
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... ]

教育訓練中心

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