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


Browsing this Thread:   1 Anonymous Users






Re: 為何無法持續送出訊號?
#7
高級會員
高級會員


查看用戶資訊
tonys實在太感謝你的指導...
原來我還有這麼多地方沒有注意到!
因為我是看書自學的...
所以你提醒我的地方都是目前我所沒想到過的...
真是太感謝你了!
尤其是你提的第三點....
我再好好看一下該如何改...

發表於: 2004/10/29 23:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法持續送出訊號?
#6
資深會員
資深會員


查看用戶資訊
(1) number equ .625 ?
 這一行 MPLAB 會出現 Warning,你沒有看?
 625 > 255 , 結果只用到 625 mod 256 = 113 (就是 lower 8 bit)
(2) mechwu 已提醒你檢測 TXIF
(3) 最重要的一點: count equ 0x80 !!!
 你程式前半段的指令都有指定 a=0, 後半段對 count 所下的指令都沒有指定 a 值,程式也沒有指定 BSR (它沒有 power on default!)
 萬一它指到的 0x80 是 0xF80(PORTA) , 你永遠讀回 0 ← 你的情況很像這樣。
(4) 你有沒有設 CONFIG bit ?
 你這個實驗若目前沒有需要防當機功能,請把看門狗(Watch Dog)關。若未掉關看門狗,則應適時經常餵狗(CLRWDT)。

相關部份不明白的話請先看一下 datasheet

發表於: 2004/10/29 22:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法持續送出訊號?
#5
高級會員
高級會員


查看用戶資訊
謝謝版主的回應...
不好意思再請問一下...

Q1:

" bsf RCSTA,CREN "
在非同步模式下為接收致能的意思...
我是用PIC傳訊號出來..
並不是用PIC接收...
醬子也要"bsf RCSTA,CREN"嗎?

Q2:

bcf PIR1,TXIF ; Clear TxD interrupt flag
bcf PIE1,TXIE ; Disable TxD interrupt
bcf IPR1,RCIP ; Set the RxD for Low priority interrupt
bcf PIR1,RCIF ; Clear RxD interrupt flag
bsf PIE1,RCIE ; Enable RxD interrupt
我並沒有使用到中斷指令...
這幾行也要加嗎?

謝謝....

發表於: 2004/10/29 21:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法持續送出訊號?
#4
版主
版主


查看用戶資訊
有一個 bit 沒設到(CREN)

參考底下的設定
;***********************************************************************
;**** Initial USART as 9600,N,8,1 @16MHz
;***********************************************************************
Init_USART:
movlw b'00100000' ; 8-bit data mode , ASYNC
movwf TXSTA ; Low Speed mode, Enable TxD
;
movlw b'10010000' ; Enable Serial Port, 8-bit receive
movwf RCSTA ; Continuous Receive, Disable Address Detection
;
movlw .25 ; Set baud rate at 9600 with Low Speed mode
movwf SPBRG
;
bcf PIR1,TXIF ; Clear TxD interrupt flag
bcf PIE1,TXIE ; Disable TxD interrupt
;
bcf IPR1,RCIP ; Set the RxD for Low priority interrupt
bcf PIR1,RCIF ; Clear RxD interrupt flag
bsf PIE1,RCIE ; Enable RxD interrupt
;
return

發表於: 2004/10/29 14:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法持續送出訊號?
#3
高級會員
高級會員


查看用戶資訊
現在我是使用組合語言寫程式...
所以C程式我看不太懂...
不過還是很感謝你的回應!
也許以後我會改成用C來寫...
到時候就能參考了!
不知道有人懂組合語言的寫法嗎?
麻煩幫我檢查一下...
謝謝!

發表於: 2004/10/29 0:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法持續送出訊號?
#2
資深會員
資深會員


查看用戶資訊
我也不懂,用 C compiler 插花一下,參考一下 CCS 編出來的 code 吧

#use delay(clock=10000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main(void)
{
... 略
0040: MOVLW 40
0042: MOVWF SPBRG
0044: MOVLW 26 <-- 設定不太一樣
0046: MOVWF TXSTA
0048: MOVLW 90 <-- 設定不太一樣
004A: MOVWF RCSTA
... 略
while(1)
{
putc(0b10110011);

.................... putc(0b10110011);

004C: MOVLW B3
004E: BTFSS PIR1.4 <-- 檢查 TXIF,等到 ok 才發!
0050: BRA 004E
0052: MOVWF TXREG

delay_ms(1);
}
}

發表於: 2004/10/28 21:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


為何無法持續送出訊號?
#1
高級會員
高級會員


查看用戶資訊
麻煩各位幫小弟看一下程式是否有誤..
我使用的是10MHz的震盪器...

list p=18F252
#include <p18F252.INC>
number equ .625
count equ 0x80
;**********************
org 0x00
nop
initial:
banksel SPBRG
movlw .129
movwf SPBRG,0
bcf TXSTA,SYNC,0
bsf RCSTA,SPEN,0
bsf TXSTA,TXEN,0
bcf TRISC,6,0
bsf TRISC,7,0
start:
movlw B'10110011'
movwf TXREG
call delay_1ms
goto start
delay_1ms:
movlw number
movwf count
dec_loop nop
decfsz count,f
goto dec_loop
return
end

Q: 為何用示波器觀看RC6/TX/CK腳位只有一瞬間有波形
產生,之後就跳到3V的準位,並沒如預期的間隔1ms就送出一
次訊號,不解?

發表於: 2004/10/28 20:05
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... ]

教育訓練中心

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