📄 main.lst
字号:
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00072
0000 00073 GLOBAL DALI_H, DALI_L, BRIDGE_STATUS
0000 00074 GLOBAL DALI_H_BAK1, DALI_L_BAK1
0000 00075 GLOBAL DALI_H_BAK2, DALI_L_BAK2
0000 00076 GLOBAL DALI_H_BAK3, DALI_L_BAK3
00077
003B 00078 MILLISECONDS res 1 ; This is an 8-bit 1ms timer
003C 00079 OVER_LOAD_CNT res 1
003D 00080 COUNTER_L res 1
0000 00081 GLOBAL MILLISECONDS, OVER_LOAD_CNT, COUNTER_L
00082
00083
003E 00084 SEARCH_H res 1
003F 00085 SEARCH_M res 1
0040 00086 SEARCH_L res 1
0000 00087 GLOBAL SEARCH_H, SEARCH_M, SEARCH_L
00088 ; *****************************************************************************
00089
00090
00091 ; *** Variables ***************************************************************
00092 ACCESS1 udata_shr 0x70
00093 ; *****************************************************************************
0070 00094 W_COPY res 1
0071 00095 STATUS_COPY res 1
0072 00096 PORTB_COPY res 1
0073 00097 WREG1 res 1
0074 00098 WREG2 res 1
0075 00099 WREG3 res 1
0076 00100 WREG4 res 1
0077 00101 WREG5 res 1
0078 00102 WREG6 res 1
0000 00103 GLOBAL W_COPY, STATUS_COPY, WREG1
0000 00104 GLOBAL WREG2, WREG3, WREG4, WREG5, WREG6
0000 00105 GLOBAL PORTB_COPY
00106 ; *****************************************************************************
00017 ; *****************************************************************************
00018
00019
00020 ; *** Vectors *****************************************************************
00021 STARTUP CODE
0000 2??? 00022 goto Setup
00023
00024 INTVCT CODE ; Handle interrupts
0000 00?? 00025 movwf W_COPY ; Save data
0001 0E03 00026 swapf STATUS, W
0002 00?? 00027 movwf STATUS_COPY
00028
00029 brset INTCON, T0IF, TimeCounter
0003 190B M btfsc INTCON, T0IF
0004 2??? M goto TimeCounter
00030
0005 2??? 00031 goto Setup
00032 ; *****************************************************************************
MPASM 5.20 MAIN.ASM 11-3-2008 15:53:48 PAGE 10
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00033
00034
00035 ; **** Setup Everything *******************************************************
00036 MAIN_SETUP CODE ; Init all necessary
00037 ; *****************************************************************************
0000 00038 Setup
0000 1283 1303 00039 banksel PORTA ; ** Select bank 0 **
00040
0002 0181 00041 clrf TMR0 ; Reset TIMER0
00042
0003 3090 00043 movlw 0x90 ; Setup serial port receive
0004 0098 00044 movwf RCSTA
00045
00046 movlf 0x36, CMCON ; Setup comparators
0005 3036 M movlw 0x36
0006 009F M movwf CMCON
00047
00048 movlf 0x00, PIR1 ; Clear int flags
0007 3000 M movlw 0x00
0008 008C M movwf PIR1
00049 movlf 0x00, INTCON ; Setup interrupts
0009 3000 M movlw 0x00
000A 008B M movwf INTCON
00050
000B 0185 00051 clrf PORTA ; Clear the ports
000C 0186 00052 clrf PORTB
00053
00054 movlf 0x02, OVER_LOAD_CNT ; Init overload counter
000D 3002 M movlw 0x02
000E 00?? M movwf OVER_LOAD_CNT
00055
00056
000F 1683 1303 00057 banksel TXSTA ; ** Select bank 1 **
00058
0011 3020 00059 movlw 0x20 ; Setup serial port send
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0012 0098 00060 movwf TXSTA
0013 3018 00061 movlw 0x18 ; Setup baud rate, 2400 bps
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0014 0099 00062 movwf SPBRG
00063
00064 movlf 0x02, TRISB ; Setup PORT directions
0015 3002 M movlw 0x02
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0016 0086 M movwf TRISB
00065 movlf 0x27, TRISA
0017 3027 M movlw 0x27
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0018 0085 M movwf TRISA
00066
00067 ; movlf 0x80, OPTION_REG ; WDT and INT related bits
00068 movlf 0x8F, OPTION_REG ; WDT and INT related bits
0019 308F M movlw 0x8F
MPASM 5.20 MAIN.ASM 11-3-2008 15:53:48 PAGE 11
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
001A 0081 M movwf OPTION_REG
00069
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
001B 158E 00070 bsf PCON, OSCF ; Set 4MHz
00071
001C 1283 1303 00072 banksel PORTA ; ** Select bank 0 **
00073
001E 2??? 00074 call LoadReset ; Load the reset values
00075
001F 08?? 00076 movf BAUD_RATE, W ; Load the baud rate
0020 1683 1303 00077 banksel SPBRG
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0022 0099 00078 movwf SPBRG
0023 1283 1303 00079 banksel PORTA
00080
00081
0025 168B 00082 bsf INTCON, T0IE ; Enable TIMER0 interrupt
00083
0026 178B 00084 bsf INTCON, GIE ; Enable interrupts
00085
0027 01?? 00086 clrf BRIDGE_STATUS ; Init the status register
00087
0028 01?? 00088 clrf MILLISECONDS
00089
00090 Lp1 cflbig MILLISECONDS, 0xFA, Main
0029 08?? M movf MILLISECONDS, W
002A 3CFA M sublw 0xFA
002B 1C03 M btfss STATUS, C
002C 2??? M goto Main
00091
00092 brclr CMCON, C1OUT, Lp1 ; Wait 250ms for circuit stabilization
002D 1F1F M btfss CMCON, C1OUT
002E 2??? M goto Lp1
00093
002F 2??? 00094 goto Main
00095 ; *****************************************************************************
00096
00097
00098 ; *** Main Decision Branch ****************************************************
00099 MAIN_PROG CODE
00100 ; *****************************************************************************
0000 00101 Main
0000 1283 1303 00102 banksel PORTA
0002 1218 00103 bcf RCSTA, CREN ; Reset Communications
00104 movlf 0x90, RCSTA
0003 3090 M movlw 0x90
0004 0098 M movwf RCSTA
00105
0005 08?? 00106 movf BAUD_RATE, W ; Load the baud rate
0006 1683 1303 00107 banksel TXSTA ; ** Select bank 1 **
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0008 0099 00108 movwf SPBRG
MPASM 5.20 MAIN.ASM 11-3-2008 15:53:48 PAGE 12
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00109 movlf 0x20, TXSTA ; Setup serial port send
0009 3020 M movlw 0x20
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
000A 0098 M movwf TXSTA
000B 1283 1303 00110 banksel PORTA ; ** Select bank 0 **
00111
000D 1218 00112 bcf RCSTA, CREN ; Reset Communications
000E 1618 00113 bsf RCSTA, CREN
00114
000F 081A 00115 movf RCREG, W ; Clear FIFO
0010 081A 00116 movf RCREG, W
00117
0011 00118 MainLoop
0011 0064 00119 clrwdt
00120
00121 brclr PIR1, RCIF, MainLoop ; Receive command byte
0012 1E8C M btfss PIR1, RCIF
0013 2??? M goto MainLoop
00122 brset RCSTA, FERR, Main ; Check for communication error
0014 1918 M btfsc RCSTA, FERR
0015 2??? M goto Main
00123 brset RCSTA, OERR, Main
0016 1898 M btfsc RCSTA, OERR
0017 2??? M goto Main
00124 movff RCREG, COMMAND
0018 081A M movf RCREG, W
0019 00?? M movwf COMMAND
00125
001A 01?? 00126 clrf MILLISECONDS ; Wait 100ms before giving up
00127 Lp2 cflbig MILLISECONDS, 0x64, Main
001B 08?? M movf MILLISECONDS, W
001C 3C64 M sublw 0x64
001D 1C03 M btfss STATUS, C
001E 2??? M goto Main
00128 brclr PIR1, RCIF, Lp2 ; Receive high byte for DALI
001F 1E8C M btfss PIR1, RCIF
0020 2??? M goto Lp2
00129 brset RCSTA, FERR, Main ; Check for communication error
0021 1918 M btfsc RCSTA, FERR
0022 2??? M goto Main
00130 brset RCSTA, OERR, Main
0023 1898 M btfsc RCSTA, OERR
0024 2??? M goto Main
00131 movff RCREG, DALI_H
0025 081A M movf RCREG, W
0026 00?? M movwf DALI_H
00132
0027 01?? 00133 clrf MILLISECONDS ; Wait 100ms before giving up
00134 Lp3 cflbig MILLISECONDS, 0x64, Main
0028 08?? M movf MILLISECONDS, W
0029 3C64 M sublw 0x64
002A 1C03 M btfss STATUS, C
002B 2??? M goto Main
MPASM 5.20 MAIN.ASM 11-3-2008 15:53:48 PAGE 13
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -