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

📄 base1.lst

📁 代码保护功能处于持续发展中。Microchip 承诺将不断改进产品的代码保护功能。任何试图破坏Microchip 代码保护功能的行为均可视 为违反了《数字器件千年版权法案(Digital Mille
💻 LST
📖 第 1 页 / 共 5 页
字号:
MPASM 03.70.01 Released                             BASE1.ASM   3-28-2006  19:32:15         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00002 ;
                      00003 ;       Project:                Interfacing PICs 
                      00004 ;       Source File Name:       BASE1.ASM               
                      00005 ;       Devised by:             MPB             
                      00006 ;       Date:                   31-1-06
                      00007 ;       Status:                 RS232 added
                      00008 ;
                      00009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00010 ;
                      00011 ;       Program to exercise the 16F877 BASE module
                      00012 ;       with 8-bit analogue input, LCD, phone keypad 
                      00013 ;       and serial memory
                      00014 ;       
                      00015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00016 
                      00017         PROCESSOR 16F877
                      00018 ;       Clock = XT 4MHz, standard fuse settings
2007   3731           00019         __CONFIG 0x3731
                      00020 
                      00021 ; LABEL EQUATES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00022 
                      00023         INCLUDE "P16F877A.INC"  ; standard register labels      
                      00001         LIST
                      00002 ; P16F877A.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
Message[301]: MESSAGE: (Processor-header file mismatch.  Verify selected processor.)
                      00398         LIST
                      00024 
                      00025 ; User register label allocation ;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00026 
                      00027 ; GPR 20 - 2A   local variables
                      00028 ; GPR 30 - 32   keyin subroutine
                      00029 ; GPR 60 - 65   SERMEM serial memory driver
                      00030 ; GPR 70 - 75   LCDIS display driver
                      00031 ; GPR 77 - 7A   CONDEC BCD conversion routine
                      00032 
  00000008            00033 LCDport EQU     08      ; assign LCD to Port D
  00000088            00034 LCDdirc EQU     88      ; data direction register
                      00035 
  00000020            00036 Temp    EQU     20      ; temp store
  00000021            00037 Tabin   EQU     21      ; Table pointer
                      00038 
                      00039 ; Keypad registers
                      00040 
  00000030            00041 Cont    EQU     30      ; Delay counter
  00000031            00042 Key     EQU     31      ; Input key
  00000032            00043 Test    EQU     32      ; Key check
                      00044 
                      00045 ;----------------------------------------------------------
                      00046 ; MAIN PROGRAM
                      00047 ;----------------------------------------------------------
                      00048 
0000                  00049         ORG     0               ; Default start address 
MPASM 03.70.01 Released                             BASE1.ASM   3-28-2006  19:32:15         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0000   0000           00050         NOP                     ; required for ICD mode
                      00051 
                      00052 ; Port & display setup ------------------------------------
                      00053 
0001   1683 1303      00054         BANKSEL TRISA           ; Select bank 1
0003   30C8           00055         MOVLW   B'11001000'     ; Port B code for
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0004   0086           00056         MOVWF   TRISB           ; keypad row outputs
0005   3097           00057         MOVLW   B'10010111'     ; Port C code for       
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0006   0087           00058         MOVWF   TRISC           ; rows and columns
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0007   0188           00059         CLRF    TRISD           ; Display port is output
                      00060 
0008   1283 1303      00061         BANKSEL PORTA           ; Select bank 0
000A   0188           00062         CLRF    PORTD           ; Clear display outputs
000B   01E1           00063         CLRF    HiReg           ; select memory page 0
000C   01E2           00064         CLRF    LoReg           ; select first location
000D   2119           00065         CALL    inimem          ; initialise serial memory
000E   20C5           00066         CALL    inid            ; Initialise the display
                      00067 
                      00068 ;----------------------------------------------------------
                      00069 ; MAIN LOOP
                      00070 ;----------------------------------------------------------
                      00071 
000F   0103           00072 start   CLRW                    ; Select AN0 input
0010   20F7           00073         CALL    adin            ; read analogue input
0011   20E0           00074         CALL    condec          ; convert to decimal
0012   205C           00075         CALL    putdec          ; display input
0013   2072           00076         CALL    store           ; store input in memory
                      00077 
0014   2079           00078         CALL    putkey          ; Fixed message
0015   2018           00079         CALL    keyin           ; scan phone keypad
0016   20B5           00080         CALL    send            ; display key
0017   280F           00081         GOTO    start           ; and again
                      00082 
                      00083 
                      00084 ;-----------------------------------------------------------
                      00085 ; SUBROUTINES
                      00086 
                      00087 ;----------------------------------------------------------
                      00088 ; Routine to scan 3x4 phone key pad
                      00089 ; Returns ASCII code in W
                      00090 ; Output rows: RB2,RB4,RB5,RC5
                      00091 ; Input cols: RC0,RC1,RC2
                      00092 ;----------------------------------------------------------
                      00093 
0018   0000           00094 keyin   NOP     
0019   1683 1303      00095         BANKSEL TRISC
001B   3097           00096         MOVLW   B'10010111'     ; Port C code for       
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
001C   0087           00097         MOVWF   TRISC           ; rows and columns
001D   1283 1303      00098         BANKSEL PORTC
MPASM 03.70.01 Released                             BASE1.ASM   3-28-2006  19:32:15         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00099 
001F   1506           00100         BSF     PORTB,2         ; Set
0020   1606           00101         BSF     PORTB,4         ; rows 
0021   1686           00102         BSF     PORTB,5         ; high
0022   1687           00103         BSF     PORTC,5         ; initially
                      00104 
0023   1430           00105         BSF     Cont,0          ; Counter not zero
0024   01B2           00106         CLRF    Test            ; No key
                      00107 
                      00108 ; Scan keyboard -------------------------------------------
                      00109 
0025   0103           00110 again   CLRW                    ; No key yet
0026   1106           00111         BCF     PORTB,2         ; Row 1
0027   0000           00112         NOP                     ; wait
0028   0000           00113         NOP     
                      00114 
0029   1C07           00115         BTFSS   PORTC,0         ; key pressed?
002A   3031           00116         MOVLW   '1'             ; yes - load ASCII code
002B   1C87           00117         BTFSS   PORTC,1         ; next
002C   3032           00118         MOVLW   '2'             ; etc
002D   1D07           00119         BTFSS   PORTC,2         ;
002E   3033           00120         MOVLW   '3'             ;
002F   1506           00121         BSF     PORTB,2         ; deselect row
                      00122 ; ---------------------------------------------------------
0030   1206           00123         BCF     PORTB,4         ; second row
0031   1C07           00124         BTFSS   PORTC,0
0032   3034           00125         MOVLW   '4'
0033   1C87           00126         BTFSS   PORTC,1
0034   3035           00127         MOVLW   '5'
0035   1D07           00128         BTFSS   PORTC,2
0036   3036           00129         MOVLW   '6'
0037   1606           00130         BSF     PORTB,4
                      00131 ; ---------------------------------------------------------
0038   1286           00132         BCF     PORTB,5         ; third row
0039   1C07           00133         BTFSS   PORTC,0
003A   3037           00134         MOVLW   '7'
003B   1C87           00135         BTFSS   PORTC,1
003C   3038           00136         MOVLW   '8'
003D   1D07           00137         BTFSS   PORTC,2
003E   3039           00138         MOVLW   '9'
003F   1686           00139         BSF     PORTB,5
                      00140 ; ---------------------------------------------------------
0040   1287           00141         BCF     PORTC,5         ; fourth row
0041   1C07           00142         BTFSS   PORTC,0
0042   302A           00143         MOVLW   '*'
0043   1C87           00144         BTFSS   PORTC,1
0044   3030           00145         MOVLW   '0'
0045   1D07           00146         BTFSS   PORTC,2
0046   3023           00147         MOVLW   '#'
0047   1687           00148         BSF     PORTC,5
                      00149 
                      00150 ;Test key -------------------------------------------------
                      00151 
MPASM 03.70.01 Released                             BASE1.ASM   3-28-2006  19:32:15         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0048   00B2           00152         MOVWF   Test            ; get code
0049   08B2           00153         MOVF    Test,F          ; test it
004A   1D03           00154         BTFSS   STATUS,Z        ; if code found
004B   284E           00155         GOTO    once            ; beep once
                      00156 
004C   0831           00157         MOVF    Key,W           ; load key code and
004D   0008           00158         RETURN                  ; if no key, or released
                      00159 
                      00160 ; Check if beep done --------------------------------------
                      00161 
004E   08B0           00162 once    MOVF    Cont,F          ; beep already done?
004F   1903           00163         BTFSC   STATUS,Z        ; 
0050   2825           00164         GOTO    again           ; yes - scan again
                      00165 
0051   0832           00166         MOVF    Test,W          ; store key
0052   00B1           00167         MOVWF   Key             
                      00168 
                      00169 ; Beep ----------------------------------------------------     
                      00170         
0053   3010           00171 beep    MOVLW   10              ; 10 cycles
0054   00B0           00172         MOVWF   Cont
                      00173 
0055   1406           00174 buzz    BSF     PORTB,0         ; one beep cycle
0056   20A5           00175         CALL    onems           ; 2ms
0057   1006           00176         BCF     PORTB,0
0058   20A5           00177         CALL    onems           
Message[305]: Using default destination of 1 (file).
0059   0BB0           00178         DECFSZ  Cont            ; last cycle?
005A   2855           00179         GOTO    buzz            ; no
                      00180 
005B   2825           00181         GOTO    again           ; yes
                      00182 
                      00183 ; End of keypad routine ------------------------------------
                      00184 
                      00185 ; ----------------------------------------------------------
                      00186 ; Display input test voltage on top line of LCD 
                      00187 ;-----------------------------------------------------------
                      00188 
005C   10F4           00189 putdec  BCF     Select,RS       ; set display command mode
005D   3080           00190         MOVLW   080             ; code to home cursor
005E   20B5           00191         CALL    send            ; output it to display
005F   14F4           00192         BSF     Select,RS       ; and restore data mode
                      00193 
                      00194 ; Convert digits to ASCII ----------------------------------
                      00195 
0060   3030           00196         MOVLW   030             ; load ASCII offset
Message[305]: Using default destination of 1 (file).
0061   07F8           00197         ADDWF   Huns            ; convert hundreds to ASCII

⌨️ 快捷键说明

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