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

📄 upd6121.lst

📁 use pic16f677 to receive irda ic(up6121) signal.
💻 LST
📖 第 1 页 / 共 3 页
字号:
MPASM  5.06                       UPD6121.ASM   6-2-2008  15:34:04         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;=======================================================
                      00002 ;
                      00003 ;       FILENAME        : NEC_uPD6121.asm
                      00004 ;       AUTHOR          : Ben Hsu
                      00005 ;       M.P.            : +886-952-778-122
                      00006 ;       DATE            : 2008/05/30
                      00007 ;       DESCRIPTION     :
                      00008 ;                       Read the NEC uPD6121 by TMR0 interrput
                      00009 ;                       and INTE interrupt 
                      00010 ;                       The signal is input by INTE pin
                      00011 ;
                      00012 ;=======================================================
                      00013 
                      00014                 list            p=pic16f677, r=dec
                      00015                 #include        <p16f677.inc>
                      00001         LIST
                      00002 ; P16F677.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                      00476         LIST
                      00016 
                      00017                 cblock  0x20
  00000020            00018                 w_temp
  00000021            00019                 status_temp
  00000022            00020                 pclath_temp
  00000023            00021                 fsr_temp
                      00022 
  00000024            00023                 SystemFg
  00000025            00024                 RxBuf                   : 4
  00000029            00025                 TmrBase
  0000002A            00026                 TmrCycle
  0000002B            00027                 GetIndex
                      00028         
  0000002C            00029                 KeyRepeat
                      00030                 endc
                      00031 
                      00032 BANK0   MACRO
                      00033                 bcf             STATUS, RP0
                      00034                 bcf             STATUS, RP1
                      00035                 ENDM
                      00036                 
                      00037 BANK1   MACRO
                      00038                 bsf             STATUS, RP0
                      00039                 bcf             STATUS, RP1
                      00040                 ENDM
                      00041 
                      00042 BANK2   MACRO
                      00043         bcf     STATUS, RP0
                      00044         bsf     STATUS, RP1
                      00045         ENDM
                      00046         
                      00047 BANK3   MACRO
                      00048         bsf     STATUS, RP0
                      00049         bsf     STATUS, RP1
                      00050         ENDM
MPASM  5.06                       UPD6121.ASM   6-2-2008  15:34:04         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00051 
                      00052 #define FgGetDataOK                     SystemFg, 0
                      00053 
                      00054 #define CF                                      STATUS, C
                      00055 #define ZF                                      STATUS, Z
                      00056 
                      00057 ;=======================================================
                      00058 ;       Starting point of the procedure
                      00059 ;
0000                  00060                 org             0x0000
0000   0000           00061                 nop
0001   2848           00062                 goto    Initialize
                      00063 
                      00064 ;=======================================================
                      00065 ;       Interrupt vector address
                      00066 ;
0004                  00067                 org             0x0004
0004                  00068 Interrupt
0004   00A0           00069                 movwf   w_temp
0005   0E03           00070                 swapf   STATUS, w
0006   0183           00071                 clrf    STATUS
0007   00A1           00072                 movwf   status_temp
0008   0804           00073                 movf    FSR, w
0009   00A3           00074                 movwf   fsr_temp
000A   080A           00075                 movf    PCLATH, w
000B   00A2           00076                 movwf   pclath_temp
000C   018A           00077                 clrf    PCLATH
                      00078 
                      00079 ;       Into the TMR0 interrupt vector
                      00080 ;       Interrput cycle is 128us
000D                  00081 T0Vect
000D   1D0B           00082         btfss   INTCON, T0IF
000E   2813           00083         goto    T0VectEnd
                      00084         
000F   3080           00085         movlw   0x80
0010   0081           00086         movwf   TMR0
0011   110B           00087         bcf     INTCON, T0IF
                      00088 
0012   0AA9           00089                 incf    TmrBase, f
0013                  00090 T0VectEnd
                      00091 
                      00092 ;       Into the pin intrrupt vector
0013                  00093 InteVect
0013   1C8B           00094         btfss   INTCON, INTF
0014   283F           00095         goto    InteVectEnd
0015   108B           00096         bcf     INTCON, INTF
                      00097 
0016   0829           00098                 movf    TmrBase, w
0017   00AA           00099                 movwf   TmrCycle
0018   01A9           00100                 clrf    TmrBase
                      00101 
0019                  00102 GetStart
0019   08AB           00103                 movf    GetIndex, f
MPASM  5.06                       UPD6121.ASM   6-2-2008  15:34:04         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

001A   1D03           00104                 btfss   ZF
001B   281E           00105                 goto    GetLeader
                      00106 
001C   0AAB           00107                 incf    GetIndex, f
001D   283F           00108                 goto    InteVectEnd
                      00109 
                      00110 ;       Get leader code
001E                  00111 GetLeader
001E   032B           00112                 decf    GetIndex, w
001F   1D03           00113                 btfss   ZF
0020   282C           00114                 goto    GetData
                      00115 
0021   301E           00116                 movlw   .30
0022   022A           00117                 subwf   TmrCycle, w
0023   1C03           00118                 btfss   CF
0024   283E           00119                 goto    GoElse
                      00120 
                      00121 ;       If pluse width to be equal or smaller than  11.5ms, 
                      00122 ;       The signal is repeat key
0025   305C           00123                 movlw   .92
0026   022A           00124                 subwf   TmrCycle, w
0027   1C03           00125                 btfss   CF
0028   283D           00126                 goto    IsRepeat                
                      00127 
0029   01AC           00128                 clrf    KeyRepeat
002A   0AAB           00129                 incf    GetIndex, f
002B   283F           00130                 goto    InteVectEnd
                      00131 
                      00132 ;       Get data code
002C                  00133 GetData
002C   3023           00134                 movlw   .35
002D   022B           00135                 subwf   GetIndex, w
002E   1803           00136                 btfsc   CF
002F   283E           00137                 goto    GoElse
                      00138 
0030   300D           00139                 movlw   .13
0031   022A           00140                 subwf   TmrCycle, w
                      00141 
0032   0CA8           00142                 rrf             RxBuf+3, f
0033   0CA7           00143                 rrf             RxBuf+2, f
0034   0CA6           00144                 rrf             RxBuf+1, f
0035   0CA5           00145                 rrf             RxBuf, f
                      00146 
0036   0AAB           00147                 incf    GetIndex, f
0037   3022           00148                 movlw   .34
0038   062B           00149                 xorwf   GetIndex, w
0039   1D03           00150                 btfss   ZF
003A   283F           00151                 goto    InteVectEnd
                      00152 
003B   1424           00153                 bsf             FgGetDataOK
003C   283E           00154                 goto    GoElse
                      00155 
003D                  00156 IsRepeat
MPASM  5.06                       UPD6121.ASM   6-2-2008  15:34:04         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

003D   0AAC           00157                 incf    KeyRepeat, f
003E                  00158 GoElse
003E   01AB           00159                 clrf    GetIndex
003F                  00160 InteVectEnd
                      00161 
003F                  00162 InterruptVectEnd
003F   0822           00163                 movf    pclath_temp, w
0040   008A           00164                 movwf   PCLATH
0041   0823           00165                 movf    fsr_temp, w
0042   0084           00166                 movwf   FSR
0043   0E21           00167                 swapf   status_temp, w
0044   0083           00168                 movwf   STATUS
0045   0EA0           00169                 swapf   w_temp, f
0046   0E20           00170                 swapf   w_temp, w
0047   0009           00171                 retfie
                      00172 
                      00173 ;=======================================================
                      00174 ;       FUNCTION NAME : Initialize
                      00175 ;       DESCRIPTION :
                      00176 ;               1.  Set up the initialize register of system 
                      00177 ;                       and     the initialize value of parameters
                      00178 ;
                      00179 ;
0048                  00180 Initialize
                      00181 
                      00182                 BANK1
0048   1683               M                 bsf             STATUS, RP0
0049   1303               M                 bcf             STATUS, RP1
                      00183 ;       TMR0 Prescale Rate 1:1
                      00184 ;       Interrupt on falling edge of INTE pin
                      00185 ;       *** Signal normal in high level , set falling edge
                      00186 ;       *** Signal normal in low level , set rising edge
004A   3088           00187                 movlw   0x88                    
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
004B   0081           00188                 movwf   OPTION_REG
                      00189 
                      00190 ;       The RA2 is INTE pin
                      00191 ;       To set the RB7 pin is output mode for LED use
004C   30FF           00192                 movlw   0xff
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
004D   0085           00193                 movwf   TRISA
004E   307F           00194                 movlw   0x7f

⌨️ 快捷键说明

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