程序如下:
LIST P=18F248 INCLUDE "P18F248.INC" CAN_FLAG EQU 0x20 ORG 0x0000 GOTO MAIN ORG 0x0008 GOTO CAN_INTSERVE ORG 0x30 INITIAL MOVLW 0x08 MOVWF TRISB MOVLW 0x80 MOVWF CANCON WAIT BTFSS CANSTAT,OPMODE2 GOTO WAIT MOVLW 0x01 MOVWF BRGCON1 MOVLW 0x90 MOVWF BRGCON2 MOVLW 0x42 MOVWF BRGCON3 MOVLW 0x03 MOVWF TXB0CON ;???????为什么写不进去??? MOVLW 0xFF MOVWF TXB0SIDH ;????? MOVLW 0xE0 MOVWF TXB0SIDL ;?????
MOVLW 0x08 MOVWF TXB0DLC ;??? MOVLW 0x0F MOVWF BSR
MOVLW 0x00 MOVWF TXB0D0 MOVLW 0x01 MOVWF TXB0D1 MOVLW 0x02 MOVWF TXB0D2 MOVLW 0x03 MOVWF TXB0D3 MOVLW 0x04 MOVWF TXB0D4 MOVLW 0x05 MOVWF TXB0D5 MOVLW 0x06 MOVWF TXB0D6 MOVLW 0x07 MOVWF TXB0D7 MOVLW 0xFF MOVWF RXB0SIDH MOVLW 0xE0 MOVWF RXB0SIDL MOVLW 0x20 MOVWF RXB0CON MOVLW 0x08 MOVWF RXB0DLC MOVLW 0x00 MOVWF RXB0D0 MOVLW 0x00 MOVWF RXB0D1 MOVLW 0x00 MOVWF RXB0D2 MOVLW 0x00 MOVWF RXB0D3 MOVLW 0x00 MOVWF RXB0D4 MOVLW 0x00 MOVWF RXB0D5 MOVLW 0x00 MOVWF RXB0D6 MOVLW 0x00 MOVWF RXB0D7
MOVLW 0xFF MOVWF RXF0SIDH MOVLW 0xE0 MOVWF RXF0SIDL MOVLW 0x00 MOVWF RXM0SIDH MOVLW 0x00 MOVWF RXM0SIDL
MOVLW 0x00 MOVWF CIOCON MOVLW 0x40 MOVWF CANCON
WAIT2 MOVF CANSTAT ANDLW 0xE0 SUBLW 0x40 BTFSS STATUS,Z GOTO WAIT2
MOVLW 0x00 MOVWF PIR3 MOVLW 0x01 MOVWF PIE3 MOVLW 0x01 MOVWF IPR3 RETURN
CAN_INTSERVE WAIT3 BTFSS PIR3,RXB0IF GOTO ERR_EXIT BSF CAN_FLAG,0 BCF PIR3,RXB0IF BCF RXB0CON,RXFUL ERR_EXIT RETFIE
MAIN NOP CLRF INTCON CALL INITIAL MOVLW 0xC0 MOVWF INTCON LOOP BSF TXB0CON,TXREQ
WAITE4 BTFSS PIR3,TXB0IF GOTO WAITE4 WAITE5 BTFSS CAN_FLAG,0 GOTO WAITE5 BCF CAN_FLAG,0 BCF TXB0CON,TXREQ INCF RXB0D0,0 MOVWF TXB0D0 INCF RXB0D1,0 MOVWF TXB0D1 INCF RXB0D2,0 MOVWF TXB0D2 INCF RXB0D3,0 MOVWF TXB0D3 INCF RXB0D4,0 MOVWF TXB0D4 INCF RXB0D5,0 MOVWF TXB0D5 INCF RXB0D6,0 MOVWF TXB0D6 INCF RXB0D7,0 MOVWF TXB0D7 GOTO LOOP RETURN END
出现的问题如下: TXB0CON TXB0SIDH TXB0SIDL TXB0DLC 这四个寄存器一直是初始值,写不进新值,很困惑,不知各位遇到过这样的问题没有.. |