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

📄 amps.lst

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


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00002 ;
                      00003 ;       Project:                Interfacing PICs 
                      00004 ;       Source File Name:       AMPS.ASM                
                      00005 ;       Devised by:             MPB             
                      00006 ;       Date:                   20-12-05
                      00007 ;       Status:                 Final
                      00008 ;
                      00009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00010 ;
                      00011 ;       Displays input from different amplifier types
                      00012 ;       
                      00013 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00014 
                      00015         PROCESSOR 16F877A
                      00016 ;       Clock = XT 4MHz, standard fuse settings
2007   3731           00017         __CONFIG 0x3731
                      00018 
                      00019 ;       LABEL EQUATES   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00020 
                      00021         INCLUDE "P16F877A.INC"  
                      00001         LIST
                      00002 ; P16F877A.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                      00398         LIST
                      00022         ; standard register labels      
                      00023 
                      00024 ;----------------------------------------------------------
                      00025 ; User register labels
                      00026 ;----------------------------------------------------------
                      00027 ; GPR 20 - 2F allocated to included LCD display routine
                      00028 
  00000030            00029 count   EQU     30      ; Counter for ADC setup delay
  00000031            00030 ADbin   EQU     31      ; Binary input value
  00000032            00031 huns    EQU     32      ; Hundreds digit in decimal value
  00000033            00032 tens    EQU     33      ; Tens digit in decimal value
  00000034            00033 ones    EQU     34      ; Ones digit in decimal value
                      00034 
                      00035 ;----------------------------------------------------------
                      00036 ; PROGRAM BEGINS
                      00037 ;----------------------------------------------------------
                      00038 
0000                  00039         ORG     0               ; Default start address 
0000   0000           00040         NOP                     ; required for ICD mode
                      00041 
                      00042 ;----------------------------------------------------------     
                      00043 ; Port & display setup
                      00044 
0001   1683 1303      00045         BANKSEL TRISC           ; Select bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0003   0188           00046         CLRF    TRISD           ; Display port is output
0004   3003           00047         MOVLW   B'00000011'     ; Analogue input setup code
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0005   009F           00048         MOVWF   ADCON1          ; Left justify result, 
MPASM 03.70.01 Released                              AMPS.ASM   3-28-2006  22:26:09         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00049                                 ; Port A = analogue inputs
                      00050 
0006   1283 1303      00051         BANKSEL PORTC           ; Select bank 0
0008   0188           00052         CLRF    PORTD           ; Clear display outputs
0009   3041           00053         MOVLW   B'01000001'     ; Analogue input setup code
000A   009F           00054         MOVWF   ADCON0          ; f/8, RA0, done, enable  
                      00055 
000B   2069           00056         CALL    inid            ; Initialise the display
                      00057 
                      00058 ;----------------------------------------------------------
                      00059 ; MAIN LOOP
                      00060 ;----------------------------------------------------------
                      00061 
000C   2010           00062 start   CALL    getADC          ; read input
000D   2015           00063         CALL    condec          ; convert to decimal
000E   202C           00064         CALL    putLCD          ; display input
000F   280C           00065         GOTO    start           ; jump to main loop
                      00066 
                      00067 ;-----------------------------------------------------------
                      00068 ; SUBROUTINES
                      00069 ;-----------------------------------------------------------
                      00070 ; Read ADC input and store .................................
                      00071 
0010   151F           00072 getADC  BSF     ADCON0,GO       ; start ADC..
0011   191F           00073 wait    BTFSC   ADCON0,GO       ; ..and wait for finish
0012   2811           00074         GOTO    wait
0013   081E           00075         MOVF    ADRESH,W        ; store result, high 8 bits
0014   0008           00076         RETURN                          
                      00077         
                      00078 ;-----------------------------------------------------------
                      00079 ; Convert input to decimal 
                      00080 
0015   00B1           00081 condec  MOVWF   ADbin           ; get ADC result
0016   01B2           00082         CLRF    huns            ; zero hundreds digit
0017   01B3           00083         CLRF    tens            ; zero tens digit
0018   01B4           00084         CLRF    ones            ; zero ones digit
                      00085 
                      00086 ; Calclulate hundreds.......................................
                      00087 
0019   1403           00088         BSF     STATUS,C        ; set carry for subtract
001A   3064           00089         MOVLW   D'100'          ; load 100
Message[305]: Using default destination of 1 (file).
001B   02B1           00090 sub1    SUBWF   ADbin           ; and subtract from result
Message[305]: Using default destination of 1 (file).
001C   0AB2           00091         INCF    huns            ; count number of loops
001D   1803           00092         BTFSC   STATUS,C        ; and check if done
001E   281B           00093         GOTO    sub1            ; no, carry on
                      00094 
Message[305]: Using default destination of 1 (file).
001F   07B1           00095         ADDWF   ADbin           ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
0020   03B2           00096         DECF    huns            ; and correct loop count
                      00097 
MPASM 03.70.01 Released                              AMPS.ASM   3-28-2006  22:26:09         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00098 ; Calculate tens digit......................................
                      00099 
0021   1403           00100         BSF     STATUS,C        ; repeat process for tens
0022   300A           00101         MOVLW   D'10'           ; load 10
Message[305]: Using default destination of 1 (file).
0023   02B1           00102 sub2    SUBWF   ADbin           ; and subtract from result
Message[305]: Using default destination of 1 (file).
0024   0AB3           00103         INCF    tens            ; count number of loops
0025   1803           00104         BTFSC   STATUS,C        ; and check if done
0026   2823           00105         GOTO    sub2            ; no, carry on
                      00106 
Message[305]: Using default destination of 1 (file).
0027   07B1           00107         ADDWF   ADbin           ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
0028   03B3           00108         DECF    tens            ; and correct loop count
0029   0831           00109         MOVF    ADbin,W         ; load remainder
002A   00B4           00110         MOVWF   ones            ; and store as ones digit
                      00111 
002B   0008           00112         RETURN                  ; done
                      00113 
                      00114 ;-----------------------------------------------------------
                      00115 ; Output to display
                      00116 
002C   10F4           00117 putLCD  BCF     Select,RS       ; set display command mode
002D   3080           00118         MOVLW   080             ; code to home cursor
002E   2059           00119         CALL    send            ; output it to display
002F   14F4           00120         BSF     Select,RS       ; and restore data mode
                      00121 
                      00122 ; Convert digits to ASCII and display..........................
                      00123 
0030   3030           00124         MOVLW   030             ; load ASCII offset
Message[305]: Using default destination of 1 (file).
0031   07B2           00125         ADDWF   huns            ; convert hundreds to ASCII
Message[305]: Using default destination of 1 (file).
0032   07B3           00126         ADDWF   tens            ; convert tens to ASCII
Message[305]: Using default destination of 1 (file).
0033   07B4           00127         ADDWF   ones            ; convert ones to ASCII
                      00128 
0034   0832           00129         MOVF    huns,W          ; load hundreds code
0035   2059           00130         CALL    send            ; and send to display
0036   302E           00131         MOVLW   '.'             ; load point code
0037   2059           00132         CALL    send            ; and output
0038   0833           00133         MOVF    tens,W          ; load tens code
0039   2059           00134         CALL    send            ; and output
003A   0834           00135         MOVF    ones,W          ; load ones code
003B   2059           00136         CALL    send            ; and output
003C   3020           00137         MOVLW   ' '             ; load space code
003D   2059           00138         CALL    send            ; and output
003E   3056           00139         MOVLW   'V'             ; load volts code
003F   2059           00140         CALL    send            ; and output
0040   306F           00141         MOVLW   'o'             ; load volts code
0041   2059           00142         CALL    send            ; and output
0042   306C           00143         MOVLW   'l'             ; load volts code
MPASM 03.70.01 Released                              AMPS.ASM   3-28-2006  22:26:09         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0043   2059           00144         CALL    send            ; and output
0044   3074           00145         MOVLW   't'             ; load volts code
0045   2059           00146         CALL    send            ; and output
0046   3073           00147         MOVLW   's'             ; load volts code
0047   2059           00148         CALL    send            ; and output
                      00149 
0048   0008           00150         RETURN                  ; done
                      00151 
                      00152 ;----------------------------------------------------------
                      00153 ; INCLUDED ROUTINES
                      00154 ;----------------------------------------------------------
                      00155 ; Include LCD driver routine
                      00156 ;
                      00157         INCLUDE "LCDIS.INC"
                      00001 ;--------------------------------------------------------------
                      00002 ;       LCDIS.INC               MPB     19-12-05
                      00003 ;
                      00004 ;       Include file to operate 16x2 LCD display
                      00005 ;       Uses GPR 70 - 75
                      00006 ;       
                      00007 ;       Final version
                      00008 ;--------------------------------------------------------------
                      00009 
  00000070            00010 Timer1  EQU     70              ; 1ms count register
  00000071            00011 TimerX  EQU     71              ; Xms count register
  00000072            00012 Var     EQU     72              ; Output variable
  00000073            00013 Point   EQU     73              ; Program table pointer
  00000074            00014 Select  EQU     74              ; Used to set or clear RS bit
  00000075            00015 OutCod  EQU     75              ; Temp store for output code
                      00016 
  00000001            00017 RS      EQU     1               ; Register select output bit
  00000002            00018 E       EQU     2               ; Enable display input
                      00019 
                      00020 
                      00021 ;--------------------------------------------------------------
                      00022 ;       1ms delay with 1us cycle time (1000 cycles)
                      00023 ;--------------------------------------------------------------
0049   30F9           00024 onems   MOVLW   D'249'          ; Count for 1ms delay 
004A   00F0           00025         MOVWF   Timer1          ; Load count
004B   0000           00026 loop1   NOP                     ; Pad for 4 cycle loop
Message[305]: Using default destination of 1 (file).
004C   0BF0           00027         DECFSZ  Timer1          ; Count
004D   284B           00028         GOTO    loop1           ; until Z
004E   0008           00029         RETURN                  ; and finish

⌨️ 快捷键说明

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