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

📄 rf.lst

📁 汽车无钥进入系统设计,基于PIC单片机16F639,包括电路图和源码
💻 LST
📖 第 1 页 / 共 3 页
字号:
MPASM  5.14                            RF.ASM   9-26-2008  8:07:49         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;/*
                      00002 ;       RF.asm
                      00003 ;
                      00004 ;       Jan Ornter
                      00005 ;
                      00006 ;       DATE:   11-9-2005
                      00007 ;       VER.:   1.0
                      00008 ;
                      00009 ;       This class provides access to the optionally RF-Interface.
                      00010 ;       It will transmit a header (see below) and pulse with modulated data (see below).
                      00011 ;       
                      00012 ;       @timingdiagram Transmission frame
                      00013 ;          |<                 Header                   >|<        Data            >|
                      00014 ;          |<  Init >|< Gap >|<   High    >|<   Low    >|
                      00015 ;           _________         _____________              _
                      00016 ;       ___|         |_______|             |____________| XXXXXXXXXXXXXXXXXXXXXXXXX____
                      00017 ;
                      00018 ;       @timingdiagram A pwm coded '1'
                      00019 ;        |<   T_STEP  >|<        2*T_STEP         >|
                      00020 ;         _____________
                      00021 ;       _|             |___________________________|
                      00022 ;
                      00023 ;
                      00024 ;       @timingdiagram A pwm coded '0'
                      00025 ;        |<        2*T_STEP         >|<   T_STEP  >|
                      00026 ;         ___________________________
                      00027 ;       _|                           |_____________|
                      00028 ;
                      00029 ;*/
                      00030 
                      00031 
                      00032 
                      00033 #include "Project.inc"
                      00001 
                      00002 
                      00003         list p=16F636                           ; list directive to define processor
                      00004         #include <p16f636.inc>      ; processor specific variable definitions
                      00001         LIST
                      00002 ; P16F636.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                      00317         LIST
                      00005 
                      00006         ERRORLEVEL 0,-302,-312  ; Messages, Warnings and Errors Printed
                      00007                                         ; Ignore [301] => Processor Mismatch. 
                      00008                                         ; Ignore [302] => Register in operand not in bank 0. 
                      00009                                                                 ; Ignore [312] => Pagesel not needed for
                             Device
                      00034 #include "Delay.inc"
                      00001 #ifndef DELAY_INC
                      00002 #define DELAY_INC
                      00003 
                      00004 
                      00005 #define Delay.Returned  Delay.flag,3
                      00006 
MPASM  5.14                            RF.ASM   9-26-2008  8:07:49         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

  0000                00007         extern Delay.wait_w_x_50us, Delay.flag, Delay.Counter
  0000                00008         extern Delay.start, Delay.Wait
                      00009 ;
                      00010 ;
                      00011 ;       This macro initialises the delay module
                      00012 ;
                      00013 ;
                      00014 ;Delay.Init macro
                      00015 ;       banksel OPTION_REG
                      00016 ;       MOVLW   b'00000000'             ; SET UP FOR TMR0'S PRESCALER VALUE TO 1
                      00017 ;                                                       ; (RAPU, bit7) = 0 to enable weak pull-up for Po
                            rtA also 
                      00018 ;       MOVWF   OPTION_REG              ; this is used for Delay loop only
                      00019 ;       endm
                      00020 
                      00021 ;/*
                      00022 ;
                      00023 ;       This macro waits for up to 12 ms.
                      00024 ;       The time has to be a multible of 50us.
                      00025 ;       It is just added to enhance readability of the source code.
                      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
MPASM  5.14                            RF.ASM   9-26-2008  8:07:49         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      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
                      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
MPASM  5.14                            RF.ASM   9-26-2008  8:07:49         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      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,
                      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 
MPASM  5.14                            RF.ASM   9-26-2008  8:07:49         PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00163 
                      00164 
                      00165 #endif
                      00035 #ifndef RF.PIN
                      00036         #define RF.PIN          5               ; RF Modulation Output
                      00037         #define RF.PORT         PORTC
                      00038 #endif
                      00039 
                      00040 RF_ovr  udata_ovr
0000                  00041 Parity                  res 1
0001                  00042 RF.COUNTER              res 1
0002                  00043 RF.Byte_Counter res 1

⌨️ 快捷键说明

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