⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message_handler.lst

📁 PKE(被动无钥门禁系统
💻 LST
📖 第 1 页 / 共 5 页
字号:
                      00026 ;       It calls Delay.wait_w_x_50us with appropriate parameters.
                      00027 ;       This function is intended to run at 8 MHz.
                      00028 ;       If running other speeds, change the Delay.wait_w_x_50us method.
                      00029 ;
                      00030 ;       @param time The value of time
                      00031 ;       @param unit The character corresponding to the unit of time (i.e. 'u', 'm')
                      00032 ;
                      00033 ;       @example
                      00034 ;       banksel PORTB
                      00035 ;       bsf             PORTB,0
                      00036 ;       Delay.waitFor .500, 'u'
                      00037 ;       banksel PORTB
                      00038 ;       bcf             PORTB,0
                      00039 ;       @end-ex
                      00040 ;       @ex-desc This sets Pin RB0 high for approx. 500 us
                      00041 ;
                      00042 ;       @status Tested
                      00043 ;
                      00044 ;       @stacklevel +1
                      00045 ;
                      00046 ;       @registers Delay.Returned
                      00047 ;
                      00048 ;*/
                      00049 
                      00050 
                      00051 Delay.WaitFor macro time, unit
                      00052 
                      00053         if(unit == 'u')
                      00054         movlw (time/.50)
                      00055         else
                      00056                 if (unit == 'm')
                      00057         movlw ((time*.1000)/.50)
                      00058                 endif
                      00059         endif
                      00060         call Delay.wait_w_x_50us
                      00061 
                      00062         endm
                      00063 
                      00064 
                      00065 ;Delay.start    macro us                        ;build as function?     Yes, absolutely
                      00066 ;       banksel OPTION_REG                      ;2Cycles        1       ;setting prescaler to 1:2
                      00067 ;       clrf    OPTION_REG                      ;1Cycles        1
                      00068 ;       banksel TMR0                            ;2Cycles        1
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  6


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00069 ;       movlw   0xEA                            ;1Cycles        1       ;0x100 - 0x32 (50u) + 0x06 (stat
                            ic offset) + 0x07(Interrupt) + 0x0F (n first cycle)= 0xEA to compenste static Offsets
                      00070 ;       movwf   TMR0                            ;1Cycles        1
                      00071 ;       bsf             INTCON,T0IE
                      00072 ;       banksel Delay.Counter           ;don't care timer already started
                      00073 ;       movlw   (us/.50)
                      00074 ;       movwf   Delay.Counter
                      00075 ;       banksel Delay.flag
                      00076 ;       bcf             Delay.Returned
                      00077 ;       nop
                      00078 ;       endm
                      00079 
                      00080 ;Delay.Wait macro
                      00081 ;       banksel Delay.flag
                      00082 ;       btfss   Delay.Returned
                      00083 ;       goto    $-1                             ;at least 1 Cycle
                      00084 ;       bcf             INTCON,T0IE
                      00085 ;       endm
                      00086 
                      00087 ;/*
                      00088 ;
                      00089 ;       This macro must be called within the Interrupt routine, to enable the counter.
                      00090 ;       The Counter function is optimized for the following Interrupt routine.
                      00091 ;       If you do changes to that routine you will have to modify counter.start function,
                      00092 ;       to compensate these instructions (or you will loose precision).
                      00093 ;
                      00094 ;       @param w The multiplicator
                      00095 ;
                      00096 ;       @example
                      00097 ;       INT     code    0x04
                      00098 ;               movwf   W_TEMP          ; Save off current W register contents
                      00099 ;               movf    STATUS,w
                      00100 ;               clrf    STATUS                  ; Force to page0
                      00101 ;               movwf   STATUS_TEMP                                                                     
                             
                      00102 ;               movf    PCLATH,w
                      00103 ;               movwf   PCLATH_TEMP             ; Save PCLATH
                      00104 ;               movf    FSR,w
                      00105 ;               movwf   FSR_TEMP                ; Save FSR
                      00106 ;               GOTO    INT_SERV
                      00107 ;               
                      00108 ;               
                      00109 ;       INT_SERV
                      00110 ;       TIMER0_INT
                      00111 ;               btfss   INTCON,T0IE             ; Check if PORTA Interrupt Enabled
                      00112 ;               goto    NEXT_INT                ; ... No, then continue search
                      00113 ;       
                      00114 ;               btfss   INTCON,T0IF             ; Check if TMR0 Interrupt Flag Set
                      00115 ;               goto    NEXT_INT
                      00116 ;       
                      00117 ;               Delay.Isr                               ; Handles the delay routines
                      00118 ;               
                      00119 ;               ; *** If you want to use Timer0 for other Interrupts modify the Delay.start function,
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  7


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00120 ;               ; *** to compensate all instructions, you place here.
                      00121 ;               
                      00122 ;               bcf             INTCON,T0IF
                      00123 ;               goto    EndIsr
                      00124 ;       
                      00125 ;               
                      00126 ;               ; ***You may place other Interrupt Handlers here***
                      00127 ;               
                      00128 ;               
                      00129 ;       
                      00130 ;       EndIsr
                      00131 ;               clrf    STATUS                  ;Select Bank0
                      00132 ;               movf    FSR_TEMP,w
                      00133 ;               movwf   FSR                             ;Restore FSR
                      00134 ;               movf    PCLATH_TEMP,w
                      00135 ;               movwf   PCLATH                  ;Restore PCLATH
                      00136 ;               movf    STATUS_TEMP,w
                      00137 ;               movwf   STATUS                  ;Restore STATUS
                      00138 ;               swapf   W_TEMP,f                          
                      00139 ;               swapf   W_TEMP,w                ;Restore W without corrupting STATUS bits
                      00140 ;               RETFIE
                      00141 ;       @end-ex
                      00142 ;       @ex-desc 
                      00143 ;
                      00144 ;       @status Tested
                      00145 ;
                      00146 ;       @stacklevel 0
                      00147 ;
                      00148 ;       @registers TMR0
                      00149 ;
                      00150 ;*/
                      00151 Delay.Isr macro
                      00152         banksel TMR0                    ;2Cycles        n
                      00153         movlw   0xD8                    ;1Cycle         n       ;so set 0x100-0x32+0x02+0x0E=0xDC
                      00154         movwf   TMR0                    ;1Cycle         n
                      00155         banksel Delay.Counter   ;2Cycles        1
                      00156         decfsz  Delay.Counter   ;1Cycle         1
                      00157         goto    Delay.Isr.End   ;2Cycle         0
                      00158         banksel Delay.flag              ;2Cycles        1
                      00159         bsf             Delay.Returned  ;1Cycle         1
                      00160 Delay.Isr.End
                      00161         endm
                      00162 
                      00163 
                      00164 
                      00165 #endif
                      00056 #include        AFE_639.inc
                      00001 #ifndef AFE_639_INC
                      00002 #define AFE_639_INC
                      00003 
                      00004 
                      00005 
                      00006 #include SPI.inc
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  8


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001         ifndef SPI_INC
                      00002 #define SPI_INC
                      00003 
                      00004 ;/*
                      00005 ;       Stores the most significant Byte
                      00006 ;*/
  0000                00007         extern SPI.BufferH
                      00008 ;/*
                      00009 ;       Stores the least significant Byte
                      00010 ;*/
  0000                00011         extern SPI.BufferL
  0000                00012         extern SPI.Read, SPI.Write
                      00013         ;extern SPI.ShiftOutBuffer, SPI.ShiftInBuffer
                      00014 
                      00015 
                      00016 ;/*
                      00017 ;
                      00018 ;       This macro initialises the SPI module
                      00019 ;
                      00020 ;*/
                      00021 SPI.Init macro
                      00022         banksel TRISC
                      00023         movlw   b'11001110'             ; Set LFDATA,ALERT, and CS as inputs 
                      00024         movwf   TRISC                   ; 
                      00025         banksel PORTC
                      00026         bsf             AFECS                   ; Take AFE CS Line high
                      00027         endm
                      00028 
                      00029 
                      00030 
                      00031 
                      00032 ;
                      00033 ;       This macro shifts data out of the MCU through the SPI-Interface.
                      00034 ;
                      00035 ;
                      00036 ;       @param SPI.BufferH The most significant Byte of the Data
                      00037 ;       @param SPI.BufferL The least significant Byte of the Data
                      00038 ;
                      00039 ;       @example
                      00040 ;       pagesel SPI.BufferH
                      00041 ;       movlw   0xf0
                      00042 ;       movwf   SPI.BufferH
                      00043 ;       movlw   0x0f
                      00044 ;       movwf   SPI.BufferL
                      00045 ;       call    SPI.Write
                      00046 ;       @end-ex
                      00047 ;       @ex-desc This sends 0xf00f over the SPI-Bus
                      00048 ;
                      00049 ;       @status Written
                      00050 ;
                      00051 ;       @stacklevel +1
                      00052 ;
                      00053 ;
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  9


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00054 ;
                      00055 ;SPI.Write macro
                      00056 ;       call    SPI.ShiftOutBuffer
                      00057 ;       endm
                      00058 
                      00059 
                      00060 
                      00061 ;
                      00062 ;       This macro reads two Bytes from the SPI-Bus.
                      00063 ;       Put the Read command and the address in the SPI.BufferH and SPI.BufferL Registers.
                      00064 ;       Then call SPI.Read.
                      00065 ;       Then read the returned values in SPI.BufferH and SPI.BufferL.
                      00066 ;
                      00067 ;
                      00068 ;       @param SPI.BufferH The most significant Byte of the Data
                      00069 ;       @param SPI.BufferL The least significant Byte of the Data
                      00070 ;
                      00071 ;
                      00072 ;       @return SPI.BufferH The most significant Byte of the Data
                      00073 ;       @return SPI.BufferL The least significant Byte of the Data
                      00074 ;
                      00075 ;       @example
                      00076 ;       pagesel SPI.BufferH
                      00077 ;       movlw   0xf0
                      00078 ;       movwf   SPI.BufferH
                      00079 ;       movlw   0x0f

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -