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

📄 mplx.lst

📁 四通道的AD采样转换数据
💻 LST
📖 第 1 页 / 共 2 页
字号:
MPASM 01.40 Released             MPLX.ASM   1-16-1997  16:20:47         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                    00001 ;*********************************************************************
                    00002 ;This program is to demonstrate how to multiplex four 7 segment LED
                    00003 ;digits using a PIC16C71. The four digits will start at 0000 and
                    00004 ;increment at a 1 sec rate up to 9999.
                    00005 ;The LEDs are updated every 5 mS, for a multiplexing rate of 20 mS.
                    00006 ;The TMR0 timer is used in internal interrupt mode to generate the
                    00007 ;5 mS.
                    00008 ;
                    00009 ;                                       Stan D'Souza 5/8/93
                    00010 ;
                    00011 ;       Program:          MPLX.ASM 
                    00012 ;       Revision Date:   
                    00013 ;                         1-15-97      Compatibility with MPASMWIN 1.40
                    00014 ;
                    00015 ;**********************************************************************
                    00016         LIST P=16C71
                    00017         ERRORLEVEL  -302
                    00018 ;
                    00019         include   <p16c71.inc>
                    00001         LIST
                    00002 ; P16C71.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                    00142         LIST
                    00020 ;
  0000000C          00021 TempC   equ     0x0c            ;temp general purpose regs
  0000000D          00022 TempD   equ     0x0d
  0000000E          00023 TempE   equ     0x0e
  0000000F          00024 Count   equ     0x0f            ;count
  00000010          00025 MsdTime equ     0x10            ;most significant Timer
  00000011          00026 LsdTime equ     0x11            ;Least significant Timer
  00000001          00027 OptionReg equ   1
  00000002          00028 PCL     equ     2
  00000026          00029 BcdMsd  equ     26
  00000027          00030 Bcd     equ     27 
                    00031 ;
0000                00032         org     0
0000 2805           00033         goto    Start           ;skip over interrupt vector
                    00034 ;        
0004                00035         org     4
0004 281D           00036         goto    ServiceInterrupts
                    00037 ;
0005                00038 Start
0005 2008           00039         call    InitPorts
0006 2012           00040         call    InitTimers
0007                00041 loop
0007 2807           00042         goto    loop
                    00043 ;
0008                00044 InitPorts
0008 1683           00045         bsf     STATUS,RP0              ;select pg 1
0009 3003           00046         movlw   3                       ;make RA0-3 digital I/O
000A 0088           00047         movwf   ADCON1                  ;       /
000B 0185           00048         clrf    TRISA                   ;make RA0-4 outputs
000C 0186           00049         clrf    TRISB                   ;make RB0-7 outputs
000D 1283           00050         bcf     STATUS,RP0              ;select page 0
MPASM 01.40 Released             MPLX.ASM   1-16-1997  16:20:47         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

000E 0185           00051         clrf    PORTA                  ;make all outputs low
000F 0186           00052         clrf    PORTB                  ;       /
0010 1585           00053         bsf     PORTA,3                ;enable MSB digit sink
0011 0008           00054         return
                    00055 ;
                    00056 ;
                    00057 ;The clock speed is 4.096Mhz. Dividing internal clk. by a 32 prescaler,
                    00058 ;the rtcc will be incremented every 31.25uS. If rtcc is preloaded 
                    00059 ;with 96, it will take (256-96)*31.25uS to overflow i.e. 5mS. So the 
                    00060 ;end result is that we get a rtcc interrupt every 5mS.
0012                00061 InitTimers
0012 0190           00062         clrf    MsdTime                 ;clr timers
0013 0191           00063         clrf    LsdTime                 ;       /
0014 1683           00064         bsf     STATUS,RP0              ;select pg 1
0015 3084           00065         movlw   B'10000100'             ;assign ps to rtcc
0016 0081           00066         movwf   OptionReg               ;ps = 32
0017 1283           00067         bcf     STATUS,RP0              ;select pg 0
0018 3020           00068         movlw   B'00100000'             ;enable rtcc interrupt
0019 008B           00069         movwf   INTCON                  ;
001A 3060           00070         movlw   .96                     ;preload rtcc
001B 0081           00071         movwf   TMR0                    ;start counter
001C 0009           00072         retfie
                    00073 ;
001D                00074 ServiceInterrupts
001D 190B           00075         btfsc   INTCON,T0IF             ;rtcc interrupt?
001E 2822           00076         goto    ServiceTMR0             ;yes then service
001F 3020           00077         movlw   B'00100000'             ;else clr rest
0020 008B           00078         movwf   INTCON
0021 0009           00079         retfie
                    00080 ;
0022                00081 ServiceTMR0
0022 3060           00082         movlw   .96                     ;initialize rtcc
0023 0081           00083         movwf   TMR0
0024 110B           00084         bcf     INTCON,T0IF             ;clr int flag
0025 2028           00085         call    IncTimer                ;inc timer
0026 2050           00086         call    UpdateDisplay           ;update display
0027 0009           00087         retfie
                    00088 ;
                    00089 ;The display is incremented every 200*5mS = 1 Sec.
0028                00090 IncTimer
0028 0A0F           00091         incf    Count,W                 ;inc count
0029 3AC8           00092         xorlw   .200                    ;= 200?
002A 1903           00093         btfsc   STATUS,Z                ;no then skip
002B 282E           00094         goto    DoIncTime               ;else inc time
002C 0A8F           00095         incf    Count, F
002D 0008           00096         return
002E                00097 DoIncTime
002E 018F           00098         clrf    Count                   ;clr count
002F 0A11           00099         incf    LsdTime,W               ;get lsd
0030 390F           00100         andlw   0x0F                    ;mask high nibble
0031 3A0A           00101         xorlw   0x0a                    ; = 10?
0032 1903           00102         btfsc   STATUS,Z                ;no then skip
0033 2836           00103         goto    IncSecondLsd            ;inc next lsd
MPASM 01.40 Released             MPLX.ASM   1-16-1997  16:20:47         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0034 0A91           00104         incf    LsdTime, F              ;else inc timer
0035 0008           00105         return
0036                00106 IncSecondLsd
0036 0E11           00107         swapf   LsdTime,W               ;get hi in low nibble
0037 390F           00108         andlw   0x0F                    ;mask hi nibble
0038 3E01           00109         addlw   1                       ;inc it
0039 0091           00110         movwf   LsdTime                 ;restore back
003A 0E91           00111         swapf   LsdTime, F              ;       /
003B 3A0A           00112         xorlw   0x0a                    ; = 10?
003C 1903           00113         btfsc   STATUS,Z                ;no then skip
003D 283F           00114         goto    IncThirdLsd             ;else inc next lsd
003E 0008           00115         return                          
003F                00116 IncThirdLsd
003F 0191           00117         clrf    LsdTime
0040 0A10           00118         incf    MsdTime,W               ;get 3rd lsd
0041 390F           00119         andlw   0x0F                    ;mask hi nibble
0042 3A0A           00120         xorlw   0x0a                    ;= 10?
0043 1903           00121         btfsc   STATUS,Z                ;no then skip
0044 2847           00122         goto    IncMsd                  ;else Msd
0045 0A90           00123         incf    MsdTime, F              ;else inc timer
0046 0008           00124         return
0047                00125 IncMsd
0047 0E10           00126         swapf   MsdTime,W               ;get hi in lo nibble
0048 390F           00127         andlw   0x0F                    ;mask hi nibble
0049 3E01           00128         addlw   1                       ;inc timer
004A 0090           00129         movwf   MsdTime                 ;restore back
004B 0E90           00130         swapf   MsdTime, F              ;       /
004C 3A0A           00131         xorlw   0x0a                    ;= 10?
004D 1903           00132         btfsc   STATUS,Z                ;no then skip
004E 0190           00133         clrf    MsdTime                 ;clr msd
004F 0008           00134         return
                    00135 ;
                    00136 ;
0050                00137 UpdateDisplay
0050 0805           00138         movf    PORTA,W                ;present sink value in w
0051 0185           00139         clrf    PORTA                  ;disable all digits sinks
0052 390F           00140         andlw   0x0f                    
0053 008C           00141         movwf   TempC                   ;save sink value in tempC
0054 160C           00142         bsf     TempC,4                 ;preset for lsd sink
0055 0C8C           00143         rrf     TempC, F                ;determine next sink value
0056 1C03           00144         btfss   STATUS,C            ;c=1? 
0057 118C           00145         bcf     TempC,3                 ;no then reset LSD sink
0058 180C           00146         btfsc   TempC,0                 ;else see if Msd
0059 286B           00147         goto    UpdateMsd               ;yes then do Msd
005A 188C           00148         btfsc   TempC,1                 ;see if 3rdLsd
005B 2866           00149         goto    Update3rdLsd            ;yes then do 3rd Lsd
005C 190C           00150         btfsc   TempC,2                 ;see if 2nd Lsd
005D 2861           00151         goto    Update2ndLsd            ;yes then do 2nd lsd
005E                00152 UpdateLsd
005E 0811           00153         movf    LsdTime,W               ;get Lsd in w
005F 390F           00154         andlw   0x0f                    ;       /
0060 286F           00155         goto    DisplayOut              ;enable display
0061                00156 Update2ndLsd        
MPASM 01.40 Released             MPLX.ASM   1-16-1997  16:20:47         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0061 2080           00157         call    Chk2LsdZero             ;msd = 0 & 2 lsd 0?
0062 1D03           00158         btfss   STATUS,Z                ;yes then skip
0063 0E11           00159         swapf   LsdTime,W               ;get 2nd Lsd in w
0064 390F           00160         andlw   0x0f                    ;mask rest
0065 286F           00161         goto    DisplayOut              ;enable display

⌨️ 快捷键说明

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