📄 vintest.lst
字号:
MPASM 03.70.01 Released VINTEST.ASM 3-28-2006 22:42:41 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00002 ;
00003 ; Project: Interfacing PICs
00004 ; Source File Name: VINTEST.ASM
00005 ; Devised by: MPB
00006 ; Date: 19-12-05
00007 ; Status: Final version
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 16F877A
00019 ; Clock = XT 4MHz, standard fuse settings
2007 3731 00020 __CONFIG 0x3731
00021
00022 ; LABEL EQUATES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00023
00024 #INCLUDE "P16F877A.INC" ; standard labels
00001 LIST
00002 ; P16F877A.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
00398 LIST
00025
00026 ; GPR 70 - 75 allocated to included LCD display routine
00027
00000030 00028 count EQU 30 ; Counter for ADC setup delay
00000031 00029 ADbin EQU 31 ; Binary input value
00000032 00030 huns EQU 32 ; Hundreds digit in decimal value
00000033 00031 tens EQU 33 ; Tens digit in decimal value
00000034 00032 ones EQU 34 ; Ones digit in decimal value
00033
00034 ; PROGRAM BEGINS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00035
0000 00036 ORG 0 ; Default start address
0000 0000 00037 NOP ; required for ICD mode
00038
00039 ; Port & display setup.....................................
00040
0001 1683 1303 00041 BANKSEL TRISC ; Select bank 1
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0003 0188 00042 CLRF TRISD ; Display port is output
0004 3003 00043 MOVLW B'00000011' ; Analogue input setup code
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0005 009F 00044 MOVWF ADCON1 ; Left justify result,
00045 ; Port A = analogue inputs
00046
0006 1283 1303 00047 BANKSEL PORTC ; Select bank 0
0008 0188 00048 CLRF PORTD ; Clear display outputs
MPASM 03.70.01 Released VINTEST.ASM 3-28-2006 22:42:41 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0009 3041 00049 MOVLW B'01000001' ; Analogue input setup code
000A 009F 00050 MOVWF ADCON0 ; f/8, RA0, done, enable
00051
000B 2069 00052 CALL inid ; Initialise the display
00053
00054 ; MAIN LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00055
000C 2010 00056 start CALL getADC ; read input
000D 2015 00057 CALL condec ; convert to decimal
000E 202C 00058 CALL putLCD ; display input
000F 280C 00059 GOTO start ; jump to main loop
00060
00061 ; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00062
00063 ; Read ADC input and store ................................
00064
0010 151F 00065 getADC BSF ADCON0,GO ; start ADC..
0011 191F 00066 wait BTFSC ADCON0,GO ; ..and wait for finish
0012 2811 00067 GOTO wait
0013 081E 00068 MOVF ADRESH,W ; store result high byte
0014 0008 00069 RETURN
00070
00071 ; Convert input to decimal ................................
00072
0015 00B1 00073 condec MOVWF ADbin ; get ADC result
0016 01B2 00074 CLRF huns ; zero hundreds digit
0017 01B3 00075 CLRF tens ; zero tens digit
0018 01B4 00076 CLRF ones ; zero ones digit
00077
00078 ; Calclulate hundreds......................................
00079
0019 1403 00080 BSF STATUS,C ; set carry for subtract
001A 3064 00081 MOVLW D'100' ; load 100
Message[305]: Using default destination of 1 (file).
001B 02B1 00082 sub1 SUBWF ADbin ; and subtract from result
Message[305]: Using default destination of 1 (file).
001C 0AB2 00083 INCF huns ; count number of loops
001D 1803 00084 BTFSC STATUS,C ; and check if done
001E 281B 00085 GOTO sub1 ; no, carry on
00086
Message[305]: Using default destination of 1 (file).
001F 07B1 00087 ADDWF ADbin ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
0020 03B2 00088 DECF huns ; and correct loop count
00089
00090 ; Calculate tens digit.....................................
00091
0021 1403 00092 BSF STATUS,C ; repeat process for tens
0022 300A 00093 MOVLW D'10' ; load 10
Message[305]: Using default destination of 1 (file).
0023 02B1 00094 sub2 SUBWF ADbin ; and subtract from result
Message[305]: Using default destination of 1 (file).
0024 0AB3 00095 INCF tens ; count number of loops
MPASM 03.70.01 Released VINTEST.ASM 3-28-2006 22:42:41 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0025 1803 00096 BTFSC STATUS,C ; and check if done
0026 2823 00097 GOTO sub2 ; no, carry on
00098
Message[305]: Using default destination of 1 (file).
0027 07B1 00099 ADDWF ADbin ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
0028 03B3 00100 DECF tens ; and correct loop count
0029 0831 00101 MOVF ADbin,W ; load remainder
002A 00B4 00102 MOVWF ones ; and store as ones digit
00103
002B 0008 00104 RETURN ; done
00105
00106 ; Output to display........................................
00107
002C 10F4 00108 putLCD BCF Select,RS ; set display command mode
002D 3080 00109 MOVLW 080 ; code to home cursor
002E 2059 00110 CALL send ; output it to display
002F 14F4 00111 BSF Select,RS ; and restore data mode
00112
00113 ; Convert digits to ASCII and display......................
00114
0030 3030 00115 MOVLW 030 ; load ASCII offset
Message[305]: Using default destination of 1 (file).
0031 07B2 00116 ADDWF huns ; convert hundreds to ASCII
Message[305]: Using default destination of 1 (file).
0032 07B3 00117 ADDWF tens ; convert tens to ASCII
Message[305]: Using default destination of 1 (file).
0033 07B4 00118 ADDWF ones ; convert ones to ASCII
00119
0034 0832 00120 MOVF huns,W ; load hundreds code
0035 2059 00121 CALL send ; and send to display
0036 302E 00122 MOVLW '.' ; load point code
0037 2059 00123 CALL send ; and output
0038 0833 00124 MOVF tens,W ; load tens code
0039 2059 00125 CALL send ; and output
003A 0834 00126 MOVF ones,W ; load ones code
003B 2059 00127 CALL send ; and output
003C 3020 00128 MOVLW ' ' ; load space code
003D 2059 00129 CALL send ; and output
003E 3056 00130 MOVLW 'V' ; load volts code
003F 2059 00131 CALL send ; and output
0040 306F 00132 MOVLW 'o' ; load volts code
0041 2059 00133 CALL send ; and output
0042 306C 00134 MOVLW 'l' ; load volts code
0043 2059 00135 CALL send ; and output
0044 3074 00136 MOVLW 't' ; load volts code
0045 2059 00137 CALL send ; and output
0046 3073 00138 MOVLW 's' ; load volts code
0047 2059 00139 CALL send ; and output
00140
0048 0008 00141 RETURN ; done
00142
00143 ; INCLUDED ROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MPASM 03.70.01 Released VINTEST.ASM 3-28-2006 22:42:41 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00144
00145 ; Include LCD driver routines
00146 ;
00147 #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 ;--------------------------------------------------------------------------------------------
0049 30F9 00023 onems MOVLW D'249' ; Count for 1ms delay
004A 00F0 00024 MOVWF Timer1 ; Load count
004B 0000 00025 loop1 NOP ; Pad for 4 cycle loop
Message[305]: Using default destination of 1 (file).
004C 0BF0 00026 DECFSZ Timer1 ; Count
004D 284B 00027 GOTO loop1 ; until Z
004E 0008 00028 RETURN ; and finish
00029
00030 ;---------------------------------------------------------------------------------------------
00031 ; Delay Xms
00032 ; Receives count in W, uses Onems
00033 ;---------------------------------------------------------------------------------------------
004F 00F1 00034 xms MOVWF TimerX ; Count for X ms
0050 2049 00035 loopX CALL onems ; Delay 1ms
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -