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


Browsing this Thread:   1 Anonymous Users






請問一下有關於Software UART
#1
新會員
新會員


查看用戶資訊
請問一下,如果要使用軟體之UART,若一開始腳位就不一樣
(PortG.1,PortG.2),是否要更改到c18的openuart.asm
那中間需要注意什麼事情,再請各位高手教導一下,謝謝


MPLAB
6620

感謝

發表於: 2007/2/13 9:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下有關於Software UART
#2
新會員
新會員


查看用戶資訊
是不是還要加什麼delay的?

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


Re: 請問一下有關於Software UART
#3
版主
版主


查看用戶資訊
只要改一下腳位的定義就可以了,需注意要使用的腳位是否有AD輸入功能或比I/O更高優先的設定。

發表於: 2007/2/14 11:37
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下有關於Software UART
#4
版主
版主


查看用戶資訊
依底下程式 (OpenUART.asm)所顯示,只要變更 PORTB 4 & 5 就可以了。

C:\mcc18\src\traditional\pmc\SW_UART\openuart.asm

INCLUDE "p18cxxx.inc"

SWTXD equ PORTB ; Transmit pin port and pin
SWTXDpin equ 4
TRIS_SWTXD equ TRISB ; Transmit pin tris and pin
SWRXD equ PORTB ; Receive pin port and pin
SWRXDpin equ 5
TRIS_SWRXD equ TRISB ; Receive pin tris and pin

發表於: 2007/2/14 11:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下有關於Software UART
#5
新會員
新會員


查看用戶資訊
如果只改上面腳位的話..compiler會有以下錯誤
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - could not find definition of symbol 'DelayRXHalfBitUART' in file 'OPENUART.O'.
Errors : 1



我後來去別的地方看,他是說還要定義下列function,我把下列function寫在sw_uart.h裡面
DelayTXBitUART Delay for:
((((2*FOSC) / (4*baud)) + 1) / 2) - 12 cycles
DelayRXHalfBitUART Delay for:
((((2*FOSC) / (8*baud)) + 1) / 2) - 9 cycles
DelayRXBitUART Delay for:
((((2*FOSC) / (4*baud)) + 1) / 2) - 14 cycles

定義之後compiler就會過,可是還是沒法輸出資料於終端機,請問一下這是什麼問題,要顯示資料在終端機可以用WriteUART這個指令嗎

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


Re: 請問一下有關於Software UART
#6
版主
版主


查看用戶資訊
WriteUART( ) 是送出 UART 的訊號函數,用中斷點設定找一下問題,看看成是是否有執行到這裡。

發表於: 2007/2/14 13:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下有關於Software UART
#7
中級會員
中級會員


查看用戶資訊
參照:

ilovetoc 寫到:
如果只改上面腳位的話..compiler會有以下錯誤
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - could not find definition of symbol 'DelayRXHalfBitUART' in file 'OPENUART.O'.
Errors : 1



我後來去別的地方看,他是說還要定義下列function,我把下列function寫在sw_uart.h裡面...


Function哪有寫在頭文件里的?

這是我以前做過的,僅供參考。你還需要依照你的FOSC改一改。

;*************************************************************************************
Delay.asm

Delay routines for C18 software UART
;
Fosc 48MHz
Baudrate 115,200 bps
;
;*************************************************************************************
 
udata_acs
DelayCount res 1

 code
DelayTXBitUART
;*************************************************************************************
Delay for (((((2*FOSC) / (4*BAUDRATE)) + 1) / 2) - 12)
; = 
92.66
; = 93 (nearest integer)
;
settle for 91 (after excluding call instruction cycle count)
; = 
DelayRXBitUART
;*************************************************************************************
    global 
DelayTXBitUART    89 91 Tcy
    bra DelayRXBitUART


DelayRXHalfBitUART
;*************************************************************************************
Delay for (((((2*FOSC) / (8*BAUDRATE)) + 1) / 2) - 9)
; = 
43.58
; = 44 (nearest integer)
;
settle for 42 (after excluding call instruction cycle count)
;*************************************************************************************
    global 
DelayRXHalfBitUART
    movlw .12
    movwf DelayCount
    bra loop                
;   (1+1+2)
                            ; + (
1+2)*12
                            
; + (2)
                            ;   --------
                            ;   
42 Tcy
                            
;   ========


DelayRXBitUART
;*************************************************************************************
Delay for (((((2*FOSC) / (4*BAUDRATE)) + 1) / 2) - 14)
; = 
90.66
; = 91 (nearest integer)
;
settle for 89 (after excluding call instruction cycle count)
;*************************************************************************************
    global 
DelayRXBitUART
    movlw .28
    movwf DelayCount
    nop
loop
    decfsz DelayCount
    bra loop
    
    
return        ; (1+1+1) + (1+2)*28 + (2)= 89 Tcy
    
    end

發表於: 2007/2/16 2:20
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... ]

教育訓練中心

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