📄 lmetx2.lst
字号:
LMETX2 PAGE 1
1 $mod51
0055 2 t1lo equ 55h
0056 3 t1hi equ 56h
0053 4 temp1 equ 53h
0054 5 temp2 equ 54h
0055 6 temp3 equ 55h
0056 7 temp4 equ 56h
8
0000 9 ORG 0
0000 0130 10 AJMP 30H
11
12
0030 13 ORG 30H
14
0030 758162 15 BEG: MOV SP,#62H
0033 75B0FF 16 MOV P3,#0FFH
17
0036 D290 18 SETB P1.0
0038 D291 19 SETB P1.1 ; TO ENABLE ANALOG COMPARATOR
003A 758961 20 MOV TMOD,#61H
21 ; pin 3.3 used for switching a second resistor
22 ; pin 3.7 used for segment 'a'
23 ; since pins 1.0 and 1.1 are used as comparator
24 ; pin 3.4 is used to control the switch for charging L
25 ;pins 3.1 to 3.2 used for LED anode current drive via pnp transistors
26 ; pin 3.6 is not available, but used internally by comparator output
27 ; the low range L is selected by switch manually, then resistors are 100 ohm each
28 ; in the highrange, they are 1k each.
29 ;p3.5 used for reading time values of L value low means time t2
003D 758C00 30 start: MOV TH0,#0H
0040 758A00 31 MOV TL0,#0H ; WE LOAD -0000
32
33
0043 D2B3 34 BEGINNING: setb p3.3 ; BEGIN; SHORTing second resistor ; apply voltage
0045 1200FE 35 CALL DELAY1
36
37
0048 C2B4 38 Lfind: clr P3.4 ; CMOS switch closed to apply 5V to L is now open
004A 1200FE 39 CALL DELAY1
004D 1200FE 40 CALL DELAY1
0050 C2B5 41 CLR P3.5
0052 1200FE 42 CALL DELAY1
0055 D2B4 43 setb P3.4 ; close switch to +5 V via L
0057 D28C 44 SETB TR0 ; START TIMER 0
0059 30B6FD 45 Chk: JNB P3.6,Chk ;when high, the voltage at L-R junction is Vcc/2, so
46
005C C28C 47 stopt: CLR TR0 ; STOP the TIMER
005E C2B4 48 clr p3.4 ; remove supply for charging L with resistor 2K series
0060 D2B5 49 SETB P3.5 ;SHORT CIRCUIT INDUCTOR
50 ; read timer count
51 ; NOW WE GOT FIRST CHRAGING TIME T1
0062 7E0A 52 MOV R6,#10
0064 1200FE 53 wAIT1: CALL DELAY1
54
0067 DEFB 55 DJNZ R6,wAIT1
0069 C2B5 56 CLR P3.5 ;OPEN SHORT ACROSS L
57 ;now open the second resisor so that we charge through 2K(200 ohm)
006B 858A55 58 mov t1lo,tl0
LMETX2 PAGE 2
006E 858C56 59 mov t1hi,th0
0071 C2B3 60 clr p3.3 ; opens 2nd resistor switch, removes the second 1K(100 ohm) series wi
th L
0073 1200FE 61 call delay1 ;wait till the decay transient has died.
0076 1200FE 62 call delay1
0079 1200FE 63 call delay1
007C 1200FE 64 call delay1
007F 1200FE 65 call delay1
0082 1200FE 66 call delay1
0085 1200FE 67 call delay1
68
0088 7400 69 mov a,#0
008A F58A 70 mov TL0,a ; zero the time registers
008C F58C 71 mov TH0,a
008E D2B4 72 setb p3.4 ; apply Vcc to L and R(now 1K) in series
0090 D28C 73 setb tr0 ; start timer
0092 30B6FD 74 chk2: jnb p3.6,chk2 ; see if the voltage across 2R has risen to 50%
0095 C28C 75 stop2: clr tr0 ;stop timer
0097 C2B4 76 clr p3.4
0099 AA8A 77 mov r2,tl0
009B AB8C 78 MOV r3,TH0
79 ;NOW WE HAVE GOT THE SECOND TIME T2 (TO BE <t1)
009D D2B5 80 SETB P3.5
009F 1200FE 81 CALL DELAY1
00A2 1200FE 82 CALL DELAY1
00A5 C2B5 83 clr p3.5
84 ; TO FIND THE RATIO OF T1 TO T2
00A7 120105 85 call calc
86
87
00AA 75497F 88 dr: mov 49h,#07Fh ; 256 times the display is refreshed before another reading
00AD 1200B8 89 CALL DISP1
00B0 1200C1 90 dis_wait:call refresh1 ;DISPLAY for some time before doing another reading
00B3 D549FA 91 djnz 49h,dis_wait
92
00B6 013D 93 AJMP start
94
95
96
97
98
00B8 99 DISP1:
00B8 100 REFRESH: ; content of 18 to 1B memory locations are output on LEDs
101 ;only numbers 0 to 9 and A to F are valid data in these locations
00B8 8B18 102 MOV 18H,r3 ; least significant digit
00BA 8C19 103 MOV 19H,r4 ; next significant digit
00BC 8D1A 104 MOV 1AH,r5
00BE 8E1B 105 MOV 1BH,R6 ; most
106 ; significant digit (max:9999)
00C0 22 107 ret
00C1 7818 108 refresh1: MOV R0,#18h ; 1b,1a,19,18, holds values for 4 digits
00C3 7C04 109 MOV R4,#4 ; pin p3.3_ 0 made low one by one starts wth 18
00C5 1200CC 110 PQ2: CALL SEGDISP
00C8 08 111 INC R0
00C9 DCFA 112 djnz r4, PQ2
00CB 113 PV3:
00CB 22 114 RET
115
LMETX2 PAGE 3
00CC 9000EE 116 SEGDISP: mov dptr,#ledcode
00CF E6 117 MOV A,@R0
00D0 540F 118 ANL A,#0FH
00D2 93 119 MOVC A,@A+dptr
120
00D3 121 segcode:
00D3 FD 122 MOV R5,A
00D4 4403 123 ORL A,#03H ;WE WANT TO USE PORT 1 BITS 0 AND 1 FOR INPUT ANLOG
124 ; so retain them high
00D6 F590 125 S3: MOV P1,A ;SEGMENT_PORT
00D8 EC 126 S1: MOV A,R4 ;get digit code from r4
00D9 13 127 rrc a
00DA 92B0 128 mov p3.0,c ; output to 74138 pins ABC
00DC 13 129 rrc a
00DD 92B1 130 mov p3.1,c
00DF 13 131 rrc a
00E0 92B2 132 mov p3.2,c
133
134 ;but dont disturb pin 3.5,3.7
135
136
00E2 ED 137 MOV A,R5 ;we use p3.7 for the segment 'a' of display
00E3 13 138 RRC A ;so get that bit D1 into carry
00E4 13 139 rrc a
00E5 92B7 140 mov p3.7,c ;segment 'a;
00E7 141 S5:
00E7 11FE 142 S4: ACALL DELAY1 ; let it burn for some time
00E9 7407 143 MOV A,#07H ;extinguish the digit after that time
00EB F5B0 144 MOV P3,A ; to prevent shadow
00ED 22 145 s6: RET
00EE 146 ledcode:
00EE 7E0CB69E 147 DB 7EH,0CH,0B6H,9EH,0CCH,0DAH,0FAH
00F2 CCDAFA
00F5 0EFECEEE 148 DB 0EH,0FEH,0CEH,0EEH,0F8H,72H,0BCH,0F6H,0E2H
00F9 F872BCF6
00FD E2
149 ;these are code for the numbers 0 to 9 and A to F
00FE 7FFF 150 DELAY1: MOV R7,#0ffH
0100 00 151 N: NOP
0101 00 152 nop
0102 DFFC 153 DJNZ R7,N
0104 22 154 RET
155
156
157
158
159
0105 160 calc:
0105 A855 161 mov r0,t1lo
0107 A956 162 mov r1,t1hi
0109 8A55 163 mov temp3,r2
164
010B 8B56 165 mov temp4,r3
166
010D 8853 167 mov temp1,r0
010F 8954 168 mov temp2,r1
0111 7D04 169 mov r5,#4
0113 C3 170 rotate2: clr c ;shift TIME T1 by 4 bits
LMETX2 PAGE 4
0114 E8 171 mov a,r0
0115 33 172 rlc a
0116 F8 173 mov r0,a
0117 E9 174 mov a,r1
0118 33 175 rlc a
0119 F9 176 mov r1,a
011A DDF7 177 djnz r5,rotate2
178
179
011C 12014E 180 call udiv16 ;FIND T1/T2
181
011F AA53 182 mov r2,temp1
0121 AB54 183 mov r3,temp2
0123 7900 184 mov r1,#0
0125 E8 185 mov a,r0
0126 C3 186 clr c
0127 9420 187 subb a,#20h ;FIND THE FRACTIONAL VALUE ABOVE 2.0
0129 33 188 rlc a
012A FE 189 mov r6,a
012B 900184 190 mov dptr,#sloptabl1 ;GET SLOPE FOR L =SLOPE X T1
012E 93 191 movc a,@a+dptr
012F F8 192 mov r0,a
0130 A3 193 inc dptr
0131 EE 194 mov a,r6
0132 93 195 movc a,@a+dptr
0133 F9 196 mov r1,a
0134 1201FF 197 call umul16 ; MUL BY T1
198 ;pick from R2:R1 three hex digits
0137 7D04 199 mov r5,#4
0139 C3 200 shif: clr c
013A EA 201 mov a,r2
013B 13 202 rrc a
013C FA 203 mov r2,a
013D E9 204 mov a,r1
013E 13 205 rrc a
013F F9 206 mov r1,a
207
0140 DDF7 208 djnz r5,shif
0142 8953 209 mov temp1,r1
0144 8A54 210 mov temp2,r2
0146 AA53 211 mov r2,temp1
0148 A954 212 mov r1,temp2
014A 1201B6 213 call hex2bcd ;CONVERT TO BCD
214
014D 22 215 ret
216
217
014E 7F00 218 UDIV16: mov r7, #0 ; clear partial remainder
0150 7E00 219 mov r6, #0
0152 75F010 220 mov B, #16 ; set loop count
221
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -