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

📄 mplxad.lst

📁 四通道的AD采样转换数据
💻 LST
📖 第 1 页 / 共 3 页
字号:
0061 2866           00204         goto    Scan1           ;no then scan keypad
0062 0B93           00205         decfsz  Debnce, F       ;else dec debounce time
0063 0008           00206         return                  ;not over then return
0064 1092           00207         bcf     DebnceOn        ;over, clr debounce flag
0065 0008           00208         return                  ;and return
0066                00209 Scan1                           
0066 20A8           00210         call    SavePorts       ;save port values
0067 30EF           00211         movlw   B'11101111'     ;init TempD
0068 008D           00212         movwf   TempD
0069                00213 ScanNext
0069 0806           00214         movf    PORTB,W        ;read to init port
006A 100B           00215         bcf     INTCON,RBIF     ;clr flag
006B 0C8D           00216         rrf     TempD, F        ;get correct column
006C 1C03           00217         btfss   STATUS,C        ;if carry set?
006D 2880           00218         goto    NoKey           ;no then end
006E 080D           00219         movf    TempD,W         ;else output
006F 0086           00220         movwf   PORTB          ;low column scan line
0070 0000           00221         nop
0071 1C0B           00222         btfss   INTCON,RBIF     ;flag set? 
0072 2869           00223         goto    ScanNext        ;no then next
0073 1812           00224         btfsc   keyhit          ;last key released?
0074 287E           00225         goto    SKreturn        ;no then exit
0075 1412           00226         bsf     keyhit          ;set new key hit
0076 0E06           00227         swapf   PORTB,W        ;read port        
0077 008E           00228         movwf   TempE           ;save in TempE
0078 2082           00229         call    GetKeyValue     ;get key value 0 - F
0079 0094           00230         movwf   NewKey          ;save as New key
007A 1592           00231         bsf     ServKey         ;set service flag
007B 1492           00232         bsf     DebnceOn        ;set flag
007C 3004           00233         movlw   4
007D 0093           00234         movwf   Debnce          ;load debounce time
007E                00235 SKreturn
007E 20B5           00236         call    RestorePorts    ;restore ports
007F 0008           00237         return
                    00238 ;
0080                00239 NoKey
0080 1012           00240         bcf     keyhit          ;clr flag
0081 287E           00241         goto    SKreturn
                    00242 ;        
                    00243 ;GetKeyValue gets the key as per the following layout
                    00244 ;
                    00245 ;                  Col1    Col2    Col3    Col3       
                    00246 ;                  (RB3)   (RB2)   (RB1)   (RB0)
                    00247 ;
                    00248 ;Row1(RB4)           0       1       2       3
                    00249 ;
                    00250 ;Row2(RB5)           4       5       6       7
                    00251 ;
                    00252 ;Row3(RB6)           8       9       A       B
                    00253 ;
                    00254 ;Row4(RB7)           C       D       E       F
                    00255 ;
MPASM 01.40 Released           MPLXAD.ASM   1-16-1997  16:23:40         PAGE  6


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0082                00256 GetKeyValue
0082 018C           00257         clrf    TempC
0083 1D8D           00258         btfss   TempD,3         ;first column
0084 288C           00259         goto    RowValEnd
0085 0A8C           00260         incf    TempC, F
0086 1D0D           00261         btfss   TempD,2         ;second col.
0087 288C           00262         goto    RowValEnd
0088 0A8C           00263         incf    TempC, F
0089 1C8D           00264         btfss   TempD,1         ;3rd col.
008A 288C           00265         goto    RowValEnd
008B 0A8C           00266         incf    TempC, F        ;last col.
008C                00267 RowValEnd
008C 1C0E           00268         btfss   TempE,0         ;top row?
008D 2896           00269         goto    GetValCom       ;yes then get 0,1,2&3
008E 1C8E           00270         btfss   TempE,1         ;2nd row?
008F 2895           00271         goto    Get4567         ;yes the get 4,5,6&7
0090 1D0E           00272         btfss   TempE,2         ;3rd row?
0091 2893           00273         goto    Get89ab         ;yes then get 8,9,a&b
0092                00274 Getcdef
0092 150C           00275         bsf     TempC,2         ;set msb bits   
0093                00276 Get89ab
0093 158C           00277         bsf     TempC,3         ;       /
0094 2896           00278         goto    GetValCom       ;do common part
0095                00279 Get4567
0095 150C           00280         bsf     TempC,2
0096                00281 GetValCom
0096 080C           00282         movf    TempC,W
0097 0782           00283         addwf   PCL, F
0098 3400           00284         retlw   0
0099 3401           00285         retlw   1
009A 3402           00286         retlw   2
009B 3403           00287         retlw   3
009C 3404           00288         retlw   4
009D 3405           00289         retlw   5
009E 3406           00290         retlw   6
009F 3407           00291         retlw   7
00A0 3408           00292         retlw   8
00A1 3409           00293         retlw   9
00A2 340A           00294         retlw   0a
00A3 340B           00295         retlw   0b
00A4 340C           00296         retlw   0c
00A5 340D           00297         retlw   0d
00A6 340E           00298         retlw   0e
00A7 340F           00299         retlw   0f
                    00300 ;
                    00301 ;SavePorts, saves the porta and portb condition during a key scan
                    00302 ;operation.
00A8                00303 SavePorts
00A8 0805           00304         movf    PORTA,W        ;Get sink value
00A9 00A0           00305         movwf   PABuf           ;save in buffer
00AA 0185           00306         clrf    PORTA          ;disable all sinks
00AB 0806           00307         movf    PORTB,W        ;get port b
00AC 00A1           00308         movwf   PBBuf           ;save in buffer
MPASM 01.40 Released           MPLXAD.ASM   1-16-1997  16:23:40         PAGE  7


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

00AD 30FF           00309         movlw   0xff            ;make all high
00AE 0086           00310         movwf   PORTB          ;on port b
00AF 1683           00311         bsf     STATUS,RP0      ;select page 1
00B0 1381           00312         bcf     OptionReg,7     ;enable pull ups
00B1 30F0           00313         movlw   B'11110000'     ;port b hi nibble inputs
00B2 0086           00314         movwf   TRISB           ;lo nibble outputs
00B3 1283           00315         bcf     STATUS,RP0      ;page 0
00B4 0008           00316         return
                    00317 ;
                    00318 ;RestorePorts, restores the condition of porta and portb after a
                    00319 ;key scan operation.
00B5                00320 RestorePorts
00B5 0821           00321         movf    PBBuf,W         ;get port b
00B6 0086           00322         movwf   PORTB
00B7 0820           00323         movf    PABuf,W         ;get port a value
00B8 0085           00324         movwf   PORTA
00B9 1683           00325         bsf     STATUS,RP0      ;select page 1
00BA 1781           00326         bsf     OptionReg,7     ;disable pull ups
00BB 0185           00327         clrf    TRISA           ;make port a outputs
00BC 0186           00328         clrf    TRISB           ;as well as PORTB
00BD 1283           00329         bcf     STATUS,RP0      ;page 0
00BE 0008           00330         return
                    00331 ;
                    00332 ;
00BF                00333 UpdateDisplay
00BF 0805           00334         movf    PORTA,W        ;present sink value in w
00C0 0185           00335         clrf    PORTA          ;disable all digits sinks
00C1 390F           00336         andlw   0x0f                    
00C2 008C           00337         movwf   TempC           ;save sink value in tempC
00C3 160C           00338         bsf     TempC,4         ;preset for lsd sink
00C4 0C8C           00339         rrf     TempC, F        ;determine next sink value
00C5 1C03           00340         btfss   STATUS,C        ;c=1? 
00C6 118C           00341         bcf     TempC,3         ;no then reset LSD sink
00C7 180C           00342         btfsc   TempC,0         ;else see if Msd
00C8 28D6           00343         goto    UpdateMsd       ;yes then do Msd
00C9 188C           00344         btfsc   TempC,1         ;see if 3rdLsd
00CA 28D3           00345         goto    Update3rdLsd    ;yes then do 3rd Lsd
00CB 190C           00346         btfsc   TempC,2         ;see if 2nd Lsd
00CC 28D0           00347         goto    Update2ndLsd    ;yes then do 2nd lsd
00CD                00348 UpdateLsd                       
00CD 0811           00349         movf    LsdTime,W       ;get Lsd in w
00CE 390F           00350         andlw   0x0f            ;       /
00CF 28D8           00351         goto    DisplayOut
00D0                00352 Update2ndLsd        
00D0 0E11           00353         swapf   LsdTime,W       ;get 2nd Lsd in w
00D1 390F           00354         andlw   0x0f            ;mask rest
00D2 28D8           00355         goto    DisplayOut      ;enable display
00D3                00356 Update3rdLsd
00D3 0810           00357         movf    MsdTime,W       ;get 3rd Lsd in w
00D4 390F           00358         andlw   0x0f            ;mask low nibble
00D5 28D8           00359         goto    DisplayOut      ;enable display
00D6                00360 UpdateMsd
00D6 0E10           00361         swapf   MsdTime,W       ;get Msd in w
MPASM 01.40 Released           MPLXAD.ASM   1-16-1997  16:23:40         PAGE  8


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

00D7 390F           00362         andlw   0x0f            ;mask rest
00D8                00363 DisplayOut                      
00D8 20DD           00364         call    LedTable        ;get digit output
00D9 0086           00365         movwf   PORTB          ;drive leds
00DA 080C           00366         movf    TempC,W         ;get sink value in w
00DB 0085           00367         movwf   PORTA
00DC 0008           00368         return
                    00369 ;
                    00370 ;
00DD                00371 LedTable
00DD 0782           00372         addwf   PCL, F          ;add to PC low
00DE 343F           00373         retlw   B'00111111'     ;led drive for 0
00DF 3406           00374         retlw   B'00000110'     ;led drive for 1
00E0 345B           00375         retlw   B'01011011'     ;led drive for 2
00E1 344F           00376         retlw   B'01001111'     ;led drive for 3
00E2 3466           00377         retlw   B'01100110'     ;led drive for 4
00E3 346D           00378         retlw   B'01101101'     ;led drive for 5
00E4 347D           00379         retlw   B'01111101'     ;led drive for 6
00E5 3407           00380         retlw   B'00000111'     ;led drive for 7
00E6 347F           00381         retlw   B'01111111'     ;led drive for 8
00E7 3467           00382         retlw   B'01100111'     ;led drive for 9
00E8 3477           00383         retlw   B'01110111'     ;led drive for A
00E9 347C           00384         retlw   B'01111100'     ;led drive for b
00EA 3439           00385         retlw   B'00111001'     ;led drive for C
00EB 345E           00386         retlw   B'01011110'     ;led drive for d
00EC 3479           00387         retlw   B'01111001'     ;led drive for E
00ED 3471           00388         retlw   B'01110001'     ;led drive for F
                    00389 
                    00390 ;
                    00391 ;
00EE                00392 InitAd
00EE 30C0           00393         movlw   B'11000000'     ;internal rc for tad
00EF 0088           00394         movwf   ADCON0          ;       /
                    00395         ;note that adcon1 is set in InitPorts
00F0 0008           00396         return
                    00397 ;
00F1                00398 SampleAd
00F1 20A8           00399         call    SavePorts
00F2 20F8           00400         call    DoAd                    ;do a ad conversion
00F3                00401 AdDone
00F3 1908           00402         btfsc   ADCON0,GO               ;ad done?
00F4 28F3           00403         goto    AdDone                  ;no then loop
00F5 1612           00404         bsf     ADOver                  ;set a/d over flag
00F6 20B5           00405         call    RestorePorts            ;restore ports
00F7 0008           00406         return
                    00407 ;
                    00408 ;
00F8                00409 DoAd
00F8 0186           00410         clrf    PORTB                  ;turn off leds
00F9 1683           00411         bsf     STATUS,RP0              ;select pg 1
00FA 300F           00412         movlw   0x0f                    ;make port a hi-Z
00FB 0085           00413         movwf   TRISA                   ;       /
00FC 1283           00414         bcf     STATUS,RP0              ;select pg 0
MPASM 01.40 Released           MPLXAD.ASM   1-16-1997  16:23:40         PAGE  9


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

00FD 1408           00415         bsf     ADCON0,ADON             ;start a/d    
00FE 307D           00416         movlw   .125
00FF 2102           00417         call    Wait
0100 1508           00418         bsf     ADCON0,GO               ;start conversion
0101 0008           00419         return
                    00420 ;
                    00421 ;
0102                00422 Wait

⌨️ 快捷键说明

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