Re: 為何無法持續送出訊號?
|
||||
---|---|---|---|---|
高級會員
|
tonys實在太感謝你的指導...
原來我還有這麼多地方沒有注意到! 因為我是看書自學的... 所以你提醒我的地方都是目前我所沒想到過的... 真是太感謝你了! 尤其是你提的第三點.... 我再好好看一下該如何改...
發表於: 2004/10/29 23:53
|
|||
|
Re: 為何無法持續送出訊號?
|
||||
---|---|---|---|---|
高級會員
|
謝謝版主的回應...
不好意思再請問一下... 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
|
|||
|
Re: 為何無法持續送出訊號?
|
||||
---|---|---|---|---|
版主
|
有一個 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
|
|||
|
Re: 為何無法持續送出訊號?
|
||||
---|---|---|---|---|
高級會員
|
現在我是使用組合語言寫程式...
所以C程式我看不太懂... 不過還是很感謝你的回應! 也許以後我會改成用C來寫... 到時候就能參考了! 不知道有人懂組合語言的寫法嗎? 麻煩幫我檢查一下... 謝謝!
發表於: 2004/10/29 0:06
|
|||
|
Re: 為何無法持續送出訊號?
|
||||
---|---|---|---|---|
資深會員
|
我也不懂,用 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
|
|||
|
為何無法持續送出訊號?
|
||||
---|---|---|---|---|
高級會員
|
麻煩各位幫小弟看一下程式是否有誤..
我使用的是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
|
|||
|