我通過銀行開關在PIC彙編感到困惑切換...這適用於把一個「Q」的USART:銀行在PIC彙編
bsf PORTB,1 ;Set Transmit DIR (PORTB (0x6) not mirrored in other banks)
movlw 'Q' ;'Q' to work reg
movwf TXREG ;work reg to TXREG (TXREG (0x19) not mirrored in other banks)
clrwdt ;Clear watchdog
btfss TXSTA,TRMT ;Wait until 'Q' is shifted (TXSTA is 0x18, not mirrored)
goto $-2
bcf PORTB,1 ;Set Recive DIR
而且這個工程一樣好:
BCF 0x3, 0x5 ;Switch to bank 0
BCF 0x3, 0x6
bsf PORTB,1 ;Set Transmit DIR
movlw 'Q' ;'Q' to work reg
movwf TXREG ;work reg to TXREG
BSF 0x3, 0x5 ;Switch to bank 1
clrwdt ;Clear watchdog
btfss TXSTA,TRMT ;Wait until 'Q' is shifted
goto $-2
BCF 0x3, 0x5 ;Switch to bank 0
bcf PORTB,1 ;Set Recive DIR
我已經檢查過,編譯器沒有做任何銀行切換,當我沒有看...當有切換銀行?
感謝您對BANKSEL的建議。而且BANK1僅用於我的代碼中的TXSTA。正如你所說,PORTB是BANK0。 – c0m4 2009-05-05 12:28:51
看最後2行。它在清除TRISB而不是PORTB之前切換到BANK1。 – sybreon 2009-05-05 12:31:04
我站好了!我已經修正並稍微修改了這個問題。這個答案雖然有效,但... – c0m4 2009-05-05 13:53:15