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

📄 instamp.lst

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


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00002 ;
                      00003 ;       Project:                Interfacing PICs 
                      00004 ;       Source File Name:       INSTAMP.ASM             
                      00005 ;       Devised by:             MPB             
                      00006 ;       Date:                   21-12-05
                      00007 ;       Status:                 Final
                      00008 ;
                      00009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00010 ;
                      00011 ;       Demonstrates simple analogue input
                      00012 ;       using an external reference voltage of 2.56V
                      00013 ;       The 8-bit result is converted to BCD for display
                      00014 ;       as a voltage using the standard LCD routines.
                      00015 ;       
                      00016 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00017 
                      00018         PROCESSOR 16F877
                      00019 ;       Clock = XT 4MHz, standard fuse settings
2007   3731           00020         __CONFIG 0x3731
                      00021 
                      00022 ;       LABEL EQUATES   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00023 
                      00024         INCLUDE "P16F877A.INC"  
                      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
                      00025         ; standard register labels      
                      00026 
                      00027 ;----------------------------------------------------------
                      00028 ; User register labels
                      00029 ;----------------------------------------------------------
                      00030 ; GPR 20 - 2F allocated to included LCD display routine
                      00031 
  00000030            00032 count   EQU     30      ; Counter for ADC setup delay
  00000031            00033 ADbin   EQU     31      ; Binary input value
  00000032            00034 huns    EQU     32      ; Hundreds digit in decimal value
  00000033            00035 tens    EQU     33      ; Tens digit in decimal value
  00000034            00036 ones    EQU     34      ; Ones digit in decimal value
                      00037 
                      00038 ;----------------------------------------------------------
                      00039 ; PROGRAM BEGINS
                      00040 ;----------------------------------------------------------
                      00041 
0000                  00042         ORG     0               ; Default start address 
0000   0000           00043         NOP                     ; required for ICD mode
                      00044 
                      00045 ;----------------------------------------------------------     
                      00046 ; Port & display setup
                      00047 
0001   1683 1303      00048         BANKSEL TRISC           ; Select bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
MPASM 03.70.01 Released                           INSTAMP.ASM   3-28-2006  22:38:49         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0003   0188           00049         CLRF    TRISD           ; Display port is output
0004   3003           00050         MOVLW   B'00000011'     ; Analogue input setup code
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0005   009F           00051         MOVWF   ADCON1          ; Left justify result, 
                      00052                                 ; Port A = analogue inputs
                      00053 
0006   1283 1303      00054         BANKSEL PORTC           ; Select bank 0
0008   0188           00055         CLRF    PORTD           ; Clear display outputs
0009   3041           00056         MOVLW   B'01000001'     ; Analogue input setup code
000A   009F           00057         MOVWF   ADCON0          ; f/8, RA0, done, enable  
                      00058 
000B   2067           00059         CALL    inid            ; Initialise the display
                      00060 
                      00061 ;----------------------------------------------------------
                      00062 ; MAIN LOOP
                      00063 ;----------------------------------------------------------
                      00064 
000C   2010           00065 start   CALL    getADC          ; read input
000D   2019           00066         CALL    condec          ; convert to decimal
000E   2030           00067         CALL    putLCD          ; display input
000F   280C           00068         GOTO    start           ; jump to main loop
                      00069 
                      00070 ;-----------------------------------------------------------
                      00071 ; SUBROUTINES
                      00072 ;-----------------------------------------------------------
                      00073 ; Read ADC input and store .................................
                      00074 
0010   3007           00075 getADC  MOVLW   007             ; load counter
0011   00B0           00076         MOVWF   count
Message[305]: Using default destination of 1 (file).
0012   0BB0           00077 down    DECFSZ  count           ; and delay 20us
0013   2812           00078         GOTO    down
                      00079 
0014   151F           00080         BSF     ADCON0,GO       ; start ADC..
0015   191F           00081 wait    BTFSC   ADCON0,GO       ; ..and wait for finish
0016   2815           00082         GOTO    wait
                      00083         
0017   081E           00084         MOVF    ADRESH,W        ; store result, high 8 bits
0018   0008           00085         RETURN                          
                      00086         
                      00087 ;-----------------------------------------------------------
                      00088 ; Convert input to decimal 
                      00089 
0019   00B1           00090 condec  MOVWF   ADbin           ; get ADC result
001A   01B2           00091         CLRF    huns            ; zero hundreds digit
001B   01B3           00092         CLRF    tens            ; zero tens digit
001C   01B4           00093         CLRF    ones            ; zero ones digit
                      00094 
                      00095 ; Calclulate hundreds digit.................................
                      00096 
001D   1403           00097         BSF     STATUS,C        ; set carry for subtract
001E   3064           00098         MOVLW   D'100'          ; load 100
Message[305]: Using default destination of 1 (file).
MPASM 03.70.01 Released                           INSTAMP.ASM   3-28-2006  22:38:49         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

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


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

003C   302E           00142         MOVLW   '.'             ; load point code
003D   2057           00143         CALL    send            ; and output
003E   0834           00144         MOVF    ones,W          ; load ones code
003F   2057           00145         CALL    send            ; and output
0040   3020           00146         MOVLW   ' '             ; load space code
0041   2057           00147         CALL    send            ; and output
0042   306D           00148         MOVLW   'm'             ; load volts code
0043   2057           00149         CALL    send            ; and output    
0044   3056           00150         MOVLW   'V'             ; load volts code
0045   2057           00151         CALL    send            ; and output    
                      00152 
0046   0008           00153         RETURN                  ; done
                      00154 
                      00155 ;----------------------------------------------------------
                      00156 ; INCLUDED ROUTINES
                      00157 ;----------------------------------------------------------
                      00158 ; Include LCD driver routine
                      00159 ;
                      00160         INCLUDE "LCDIS.INC"
                      00001 ;       LCDIS.INC               MPB     19-12-05
                      00002 ;
                      00003 ;       Include file to operate 16x2 LCD display
                      00004 ;       Uses GPR 70 - 75
                      00005 ;       
                      00006 ;       Final version
                      00007 ;-------------------------------------------------------------------------------------------
                      00008 
  00000070            00009 Timer1  EQU     70              ; 1ms count register
  00000071            00010 TimerX  EQU     71              ; Xms count register
  00000072            00011 Var     EQU     72              ; Output variable
  00000073            00012 Point   EQU     73              ; Program table pointer
  00000074            00013 Select  EQU     74              ; Used to set or clear RS bit
  00000075            00014 OutCod  EQU     75              ; Temp store for output code
                      00015 
  00000001            00016 RS      EQU     1               ; Register select output bit
  00000002            00017 E       EQU     2               ; Enable output clocks display input
                      00018 
                      00019 
                      00020 ;--------------------------------------------------------------------------------------------   
                      00021 ;       1ms delay with 1us cycle time (1000 cycles)
                      00022 ;--------------------------------------------------------------------------------------------   
0047   30F9           00023 onems   MOVLW   D'249'          ; Count for 1ms delay 
0048   00F0           00024         MOVWF   Timer1          ; Load count
0049   0000           00025 loop1   NOP                     ; Pad for 4 cycle loop
Message[305]: Using default destination of 1 (file).

⌨️ 快捷键说明

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