📄 qei_sim.lst
字号:
MPASM 4.01 Released QEI_SIM.ASM 6-10-2005 16:21:14 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ; This file is a basic code template for assembly code generation *
00002 ; on the PICmicro PIC12F675. This file contains the basic code *
00003 ; building blocks to build upon. *
00004 ; *
00005 ; If interrupts are not used all code presented between the ORG *
00006 ; 0x004 directive and the label main can be removed. In addition *
00007 ; the variable assignments for 'w_temp' and 'status_temp' can *
00008 ; be removed. If the internal RC oscillator is not implemented *
00009 ; then the first four instructions following the label 'main' can *
00010 ; be removed. *
00011 ; *
00012 ; Refer to the MPASM User's Guide for additional information on *
00013 ; features of the assembler (Document DS33014). *
00014 ; *
00015 ; Refer to the respective PICmicro data sheet for additional *
00016 ; information on the instruction set. *
00017 ; *
00018 ;**********************************************************************
00019 ; *
00020 ; Filename: xxx.asm *
00021 ; Date: *
00022 ; File Version: *
00023 ; *
00024 ; Author: *
00025 ; Company: *
00026 ; *
00027 ; *
00028 ;**********************************************************************
00029 ; *
00030 ; Files required: *
00031 ; *
00032 ; *
00033 ; *
00034 ;**********************************************************************
00035 ; *
00036 ; Notes: *
00037 ; *
00038 ; *
00039 ; *
00040 ; *
00041 ;**********************************************************************
00042
00043 list p=12f675 ; list directive to define processor
00044 #include <p12f675.inc> ; processor specific variable definitions
00001 LIST
00002 ; P12F675.INC Standard Header File, Version 1.04 Microchip Technology, Inc.
00284 LIST
00045
00046 errorlevel -302 ; suppress message 302 from list file
00047
2007 3F84 00048 __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCL
KOUT
00049
MPASM 4.01 Released QEI_SIM.ASM 6-10-2005 16:21:14 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00050 ; '__CONFIG' directive is used to embed configuration word within .asm file.
00051 ; The lables following the directive are located in the respective .inc file.
00052 ; See data sheet for additional information on configuration word settings.
00053
00054
00055 #define LED GPIO,4
00056 #define RESET_SW GPIO,3
00057 #define OUTA GPIO,1
00058 #define OUTB GPIO,2
00059 #define INDEX GPIO,5
00060
00061 #define RPM_3600 .53
00062
00063 ;***** VARIABLE DEFINITIONS
00000020 00064 w_temp EQU 0x20 ; variable used for context saving
00000021 00065 status_temp EQU 0x21 ; variable used for context saving
00066
00067 CBLOCK 0x30
00000030 00068 DelayVar1 : 1
00000031 00069 DelayVar2 : 1
00000032 00070 Flags : 1
00000033 00071 Step_Var : 1
00000034 00072 Buf_TMR1L : 1
00000035 00073 Buf_TMR1H : 1
00000036 00074 TempVar : 1
00000037 00075 Base_TMR1L : 1
00000038 00076 Base_TMR1H : 1
00000039 00077 Index_Location : 1
00078 ENDC
00079
00080 #define DIRECTION 0
00081
00082
00083
00084
00085 ;**********************************************************************
0000 00086 ORG 0x000 ; processor reset vector
0000 2850 00087 goto main ; go to beginning of program
00088
00089
0004 00090 ORG 0x004 ; interrupt vector location
0004 00A0 00091 movwf w_temp ; save off current W register contents
0005 0803 00092 movf STATUS,w ; move status register into W register
0006 00A1 00093 movwf status_temp ; save off contents of STATUS register
00094
0007 0834 00095 movf Buf_TMR1L,W ; Update the initialize value of TMR1
0008 008E 00096 movwf TMR1L
0009 0835 00097 movf Buf_TMR1H,W
000A 008F 00098 movwf TMR1H
00099
000B 0833 00100 movf Step_Var,W
00101
000C 1832 00102 btfsc Flags,DIRECTION ; DIRECTION = 0 > FWD
MPASM 4.01 Released QEI_SIM.ASM 6-10-2005 16:21:14 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000D 282F 00103 goto REW_OUT ; Reverse Direction
000E 00104 FWD_OUT
000E 0782 00105 addwf PCL,F
000F 1085 00106 bcf OUTA ; Phase 0
0010 1105 00107 bcf OUTB
0011 08B9 00108 movf Index_Location,F
0012 1903 00109 btfsc STATUS,Z
0013 1685 00110 bsf INDEX
0014 0AB9 00111 incf Index_Location,F
0015 3008 00112 movlw 0x08
0016 2828 00113 goto Exit_ISRF
00114
0017 0339 00115 decf Index_Location,W ; ( 0x08 )Phase 1 , clear INDEX pin if Index_Location ==
1
0018 1903 00116 btfsc STATUS,Z
0019 1285 00117 bcf INDEX
001A 0AB9 00118 incf Index_Location,F
001B 1485 00119 bsf OUTA
001C 1105 00120 bcf OUTB
001D 3010 00121 movlw 0x10
001E 2828 00122 goto Exit_ISRF
00123
001F 1485 00124 bsf OUTA ; ( 0x10 )Phase 3
0020 1505 00125 bsf OUTB
0021 0AB9 00126 incf Index_Location,F
0022 3015 00127 movlw 0x15
0023 2828 00128 goto Exit_ISRF
00129
0024 1085 00130 bcf OUTA ; ( 0x15 )Phase 4
0025 1505 00131 bsf OUTB
0026 0AB9 00132 incf Index_Location,F
0027 3000 00133 movlw 0x00
00134
0028 00135 Exit_ISRF
0028 00B3 00136 movwf Step_Var
0029 100C 00137 bcf PIR1,TMR1IF
002A 0821 00138 movf status_temp,w ; retrieve copy of STATUS register
002B 0083 00139 movwf STATUS ; restore pre-isr STATUS register contents
002C 0EA0 00140 swapf w_temp,f
002D 0E20 00141 swapf w_temp,w ; restore pre-isr W register contents
002E 0009 00142 retfie ; return from interrupt
002F 00143 REW_OUT
002F 0782 00144 addwf PCL,F
0030 1085 00145 bcf OUTA ; Phase 0
0031 1105 00146 bcf OUTB
0032 08B9 00147 movf Index_Location,F
0033 1903 00148 btfsc STATUS,Z
0034 1685 00149 bsf INDEX
0035 03B9 00150 decf Index_Location,F
0036 3008 00151 movlw 0x08
0037 2849 00152 goto Exit_ISRR
00153
0038 0A39 00154 incf Index_Location,W ; (0x08 ) Phase 1 for reverse !!
MPASM 4.01 Released QEI_SIM.ASM 6-10-2005 16:21:14 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0039 1903 00155 btfsc STATUS,Z
003A 1285 00156 bcf INDEX
003B 03B9 00157 decf Index_Location,F
003C 1085 00158 bcf OUTA
003D 1505 00159 bsf OUTB
003E 3010 00160 movlw 0x010
003F 2849 00161 goto Exit_ISRR
00162
0040 1485 00163 bsf OUTA ; (0x10 ) Phase 3
0041 1505 00164 bsf OUTB
0042 03B9 00165 decf Index_Location,F
0043 3015 00166 movlw 0x15
0044 2849 00167 goto Exit_ISRR
00168
0045 1485 00169 bsf OUTA ; ( 0x15 ) Phase 4
0046 1105 00170 bcf OUTB
Message[305]: Using default destination of 1 (file).
0047 03B9 00171 decf Index_Location
0048 3000 00172 movlw 0x00
00173
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -