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

📄 lab6.lst

📁 时间片系统time slicing system
💻 LST
📖 第 1 页 / 共 2 页
字号:
                      00113 ; * USAGE:      Run the "Dly32" macro which then calls this routine 
                      00114 ; *             automatically.
                      00115 ; *             You must ensure that all variables are in the same bank.
                      00116 ; *************************************************************************
0401                  00117 DoDly32
0401   30FF           00118         movlw   H'FF'           ; Start with -1 in W  
                      00119 
0402   07A0           00120         addwf   Dly0,F          ; LSB decrement
0403   1803           00121         btfsc   STATUS,C        ; was the carry flag set?
0404   0103           00122         clrw                        ; if so, 0 is put in W
                      00123 
0405   07A1           00124         addwf   Dly1,F          ; else, we continue.
0406   1803           00125         btfsc   STATUS,C        ; etc.
0407   0103           00126         clrw                        ; if so, 0 is put in W
                      00127 
0408   07A2           00128         addwf   Dly2,F          ; 
0409   1803           00129         btfsc   STATUS,C        ; etc.
040A   0103           00130         clrw                        ; if so, 0 is put in W
                      00131 
040B   07A3           00132         addwf   Dly3,F          ;
040C   1803           00133         btfsc   STATUS,C        ; etc.
040D   0103           00134         clrw                        ; if so, 0 is put in W
                      00135 
040E   0420           00136         iorwf   Dly0,W          ; * Inclusive-OR all variables
040F   0421           00137         iorwf   Dly1,W          ; * together to see if we have reached 0
0410   0422           00138         iorwf   Dly2,W          ; * on all of them.
0411   0423           00139         iorwf   Dly3,W          ; *
                      00140         
0412   1D03           00141         btfss   STATUS,Z        ; Test if result of Inclusive-OR's is 0
0413   2C01           00142         goto    DoDly32         ; It was NOT zero, so continue counting
0414   3400           00143         retlw   0               ; It WAS zero, so exit this subroutine.
                      00144 ; *************************************************************************
                      00145 
                      00146 
                      00147 ; ****************************************************************
                      00148 ; *           !! YOU NEED THESE VARIABLES (if using Dly32) !!    *
                      00149 ; * You may locate them where you wish                           *
                      00150 ; ****************************************************************
  00000020            00151 Dly0    EQU     0x20    ; * Stores 4 bytes of data for the delay count
  00000021            00152 Dly1    EQU     0x21    ; * Dly0 is the least significant byte
  00000022            00153 Dly2    EQU     0x22    ; * while Dly3 is the most significant byte
  00000023            00154 Dly3    EQU     0x23    ; *
MPASM  5.06                          LAB6.ASM   5-28-2007  15:28:23         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00155 ; ****************************************************************
                      00156 
                      00157 ; ****************************************************************
                      00158 ; * !! YOU NEED THESE VARIABLES (if using ISRSave or ISRRestore) *
                      00159 ; * You may locate them where you wish                           *
                      00160 ; ****************************************************************
  00000028            00161 STATUS_TEMP     EQU     0x28    ; * Stores copy of STATUS when in ISR
  00000029            00162 W_TEMP          EQU     0x29    ; * Stores copy of WREG when in ISR
                      00163 ; ****************************************************************
                      00003         #DEFINE DEVICE_FREQ_HZ D'4000000'  ; Needed by Piezo series macros
Warning[205]: Found directive in column 1. (__CONFIG)
2007   3F39           00004 __CONFIG   _CP_OFF &  _WDT_OFF &  _XT_OSC & _LVP_OFF & _BODEN_OFF
  00000030            00005 LEDCtr  EQU     0x30            ; Counter for LED timing
  00000031            00006 PiezoCtr        EQU     0x31            ; Counter for Piezo timing
                      00007 
0000                  00008                 ORG     H'00'           ; Reset Vector
0000                  00009 Start
0000   2810           00010                 goto    Initialize              ; Jump to Initialization code
                      00011 
0004                  00012                 ORG     H'04'           ; 中断 Vector
0004                  00013 ISR
                      00014                 ISRSave                                 ; Macro to context save in ISR
0004   00A9               M         movwf   W_TEMP                  ; 
0005   0803               M         movf    STATUS,W                ; (swapf will also work here)
0006   00A8               M         movwf   STATUS_TEMP             ;
0007   110B           00015                 BCF     INTCON,TMR0IF                                           ; Clear the TMR0 中断 co
                            ndition
0008   0AB0           00016                 INCF    LEDCtr,F                                                ; Add 1 to LEDCtr
Message[305]: Using default destination of 1 (file).
0009   0AB1           00017                 INCF    PiezoCtr                                                ; Add 1 to PiezoCtr
000A   2050           00018                 CALL    DoReloadTimer                                   ; Reload the Timer for accurate 
                            timing
                      00019                 ISRRestore                                              ; Macro to context restore when 
                            leaving ISR
000B   0828               M         movf    STATUS_TEMP,W   ; (swapf will also work here)
000C   0083               M         movwf   STATUS                  ;
000D   0EA9               M         swapf   W_TEMP,F                ; movf changes STATUS bit Z, but 
000E   0E29               M         swapf   W_TEMP,W                ; swapf does not change STATUS
000F   0009           00020                 RETFIE                                          ; Return from 中断
                      00021 
0010                  00022 Initialize
                      00023                 LEDOff  0                               ; Turn off both LEDs
0010   30FE               M         movlw   H'FF' - ((1 << 0)         & H'00FF')
0011   0586               M         andwf   PORTB,F
                      00024                 LEDOff  1                               ;  "
0012   30FD               M         movlw   H'FF' - ((1 << 1)         & H'00FF')
0013   0586               M         andwf   PORTB,F
0014   01B0           00025                 clrf    LEDCtr                  ; Initialze Task Couters to 0
0015   01B1           00026                 CLRF    PiezoCtr                                                ;  " (both LED and Piezo
                            )
                      00027                 LEDEnable       H'FC'                                           ; MACRO to setup I/O por
                            t to drive LEDs RB1 and RB0
0016   1683 1303          M         BANKSEL TRISB
MPASM  5.06                          LAB6.ASM   5-28-2007  15:28:23         PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0018   30FC               M         movlw   H'FC'
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0019   0086               M         movwf   TRISB
001A   1283 1303          M         BANKSEL PORTB
                      00028                 PiezoEnable     D'500'                                  ; 500 Hz Beep when PiezoOn is us
                            ed
001C   1683 1303          M         BANKSEL TRISC
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
001E   1107               M         bcf             TRISC,2
001F   307C               M         movlw   ((DEVICE_FREQ_HZ/D'64')/D'500')-1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0020   0092               M         movwf   PR2
0021   303E               M         movlw   ((DEVICE_FREQ_HZ/D'128')/D'500')
0022   1283 1303          M         BANKSEL CCPR1L
0024   0095               M         movwf   CCPR1L
0025   3006               M         movlw   0x06            ; Turn on TMR2 (for PWM) 
0026   0092               M         movwf   T2CON           ; and /16 prescale
0027   2050           00029                 CALL    DoReloadTimer                                           ; Preload the timer for 
                            appropriate time delay
0028   1683 1303      00030                 BANKSEL TRISA                                           ; set banking to access OPTION_R
                            EG in bank 1
002A   30C7           00031                 MOVLW   B'11000111'                                             ; Set up TMR0 for 256 pr
                            escale and 
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
002B   0081           00032                 MOVWF   OPTION_REG                                              ;  internal clock mode
002C   1283 1303      00033                 BANKSEL PORTA                                           ; Return to accessing BANK 0
002E   178B           00034                 BSF     INTCON, GIE
002F   168B           00035                 BSF     INTCON, TMR0IE                                          ; Turn on GIE and TMR0 

⌨️ 快捷键说明

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