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

📄 sample.lst

📁 MT506MV触摸屏示例
💻 LST
📖 第 1 页 / 共 3 页
字号:
MPASM  4.00 Released                               SAMPLE.ASM   9-19-2005  23:12:24         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;OSC 20MHZ
                      00002 ;CX1-V1.SCH\PCB
                      00003 ;PIC16F877A
                      00004 ;050729程序框架示例
                      00005 ;050802输入口去抖后存入keyh\keyl
                      00006 ;050919modbus通信协议的CRC16校验
                      00007 
                      00008         include <p16F877A.inc>;;标准头文件,这样所有的特殊寄存器都定义好了
                      00001         LIST
                      00002 ; P16F877A.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                      00398         LIST
2007   3F76           00009         __config (_LVP_OFF&_BODEN_ON&_PWRTE_ON&_WDT_ON&_HS_OSC);;烧写设置,可参考伪指令手册
                      00010                ;低电压烧写关、掉电保护、上电延时、看门狗、高速晶振    
                      00011 ;*******************************BANK0
  00000020            00012 status_temp     equ     20H     ;中断 status暂存
  00000021            00013 PCLATH_TMP      equ     21H     ;中断 PCLATH暂存
  00000022            00014 FSR_TMP         equ     22H     ;中断 FSR暂存
  00000023            00015 flag            equ     23H     ;中断 标记寄存器
  00000024            00016 t10ms           equ     24H     ;中断 10ms发生寄存器  20000000/4/256=195
                      00017 
  00000026            00018 t1ms            EQU     26H     ;输入口扫描1MS
                      00019 
  00000028            00020 timeout         equ     28H     ;超时倒计时
  00000029            00021 sec             equ     29h     ;时基秒发生寄存器
                      00022 
  00000040            00023 keyh            EQU     40H     ;输入口扫描
  00000041            00024 key_ah          EQU     41H
  00000042            00025 key_bh          EQU     42H
  00000043            00026 keyl            EQU     43H
  00000044            00027 key_al          EQU     44H
  00000045            00028 key_bl          EQU     45H
  00000046            00029 key_tim         EQU     46H     ;延时计数
  00000047            00030 key_set         EQU     47H     ;延时设定0-255MS
                      00031 
  00000060            00032 Crc00           EQU     60H
  00000061            00033 Crc0            EQU     61H     
  00000062            00034 Crc1            EQU     62H
  00000063            00035 Crc2            EQU     63H     
  00000064            00036 Crc3            EQU     64H
  00000065            00037 Crc4            EQU     65H     
  00000066            00038 Crc5            EQU     66H
  00000067            00039 Crc6            EQU     67H     ;|
  00000067            00040 CrcL            EQU     67H     ;|
  00000068            00041 Crc7            EQU     68H     ; |
  00000068            00042 CrcH            EQU     68H     ; |
  00000069            00043 Crc8            EQU     69H     ;       
  0000006A            00044 Crc9            EQU     6AH     ;
  0000006B            00045 Crc10           EQU     6BH     ;       
  0000006C            00046 Crc11           EQU     6CH     ;
  0000006D            00047 Crc12           EQU     6DH     ;
  0000006E            00048 CrcL1           EQU     6EH     
  0000006F            00049 CrcH1           EQU     6FH
                      00050 
MPASM  4.00 Released                               SAMPLE.ASM   9-19-2005  23:12:24         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00051 
                      00052 
                      00053 ;*******************************BANK0\1\2\3共用
                      00054 ;               EQU     70h     ;ICD2仿真占用
  00000071            00055 w_temp          EQU     71h     ;w暂存
                      00056 
  00000077            00057 temp            EQU     77h     ;暂存
  00000078            00058 tempy           EQU     78h     ;暂存
                      00059 
                      00060 ;*******************************BANK1
                      00061 
                      00062 ;*******************************BANK2
                      00063 
                      00064 ;*******************************BANK3
                      00065 ;               EQU     1E5H    ;ICD2仿真占用
                      00066 ;               EQU     1EFh    ;ICD2仿真占用
                      00067  
                      00068 
                      00069 ;flag                           ;标记寄存器每位的定义
  00000000            00070 time1_f equ     0               ;=1 10ms到
                      00071 ;       EQU     1       
                      00072 ;       equ     2
                      00073 ;       equ     4       
                      00074 ;       equ     5
                      00075 ;       equ     6
                      00076 ;       equ     7       
                      00077 ;       equ     8
                      00078 
                      00079 ;*********************************************************************************
0000                  00080         org     0
0000   0000           00081         nop                     ;ICD2仿真占用
0001   2825           00082         goto    start
0004                  00083         org     0x04
0004                  00084 service                         ;中断入口
0004   00F1           00085         movwf   w_temp          ;保护W\STATUS\PCLATH\FSR,和你认为要保护的寄存器        
0005   0E03           00086         swapf   STATUS,W
0006   0183           00087         clrf    STATUS          ;Bank0
0007   00A0           00088         movwf   status_temp
0008   080A           00089         MOVFW   PCLATH
0009   00A1           00090         MOVWF   PCLATH_TMP
000A   0804           00091         MOVFW   FSR
000B   00A2           00092         MOVWF   FSR_TMP
000C   118A           00093         BCF     PCLATH,3        ;in column 0
000D   120A           00094         BCF     PCLATH,4        ;in column 0
000E                  00095 service_time0
000E   1D0B           00096         BTFSS   INTCON,T0IF     ;T0IF=1  是TIMER0中断?
000F   281C           00097         goto    service_r       ;N
0010   110B           00098         bcf     INTCON,T0IF     ;Y CLR int flag 
0011   0BA4           00099         decfsz  t10ms,F         ;
0012   2816           00100         goto    $+4
0013   30C3           00101         movlw   .195            ;10ms  20000000/4/256=195
0014   00A4           00102         MOVWF   t10ms   
0015   1423           00103         BSF     flag,time1_f    ;10ms标记,给时基子程序用
MPASM  4.00 Released                               SAMPLE.ASM   9-19-2005  23:12:24         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00104         
0016   0BA6           00105         decfsz  t1ms,F
0017   281C           00106         goto    service_time0_r
0018   3013           00107         movlw   .19             ;1ms
0019   00A6           00108         MOVWF   t1ms
001A   205A           00109         CALL    scan_input      ;(34Tcyc)       ;输入扫描
001B   281C           00110         goto    service_r
001C                  00111 service_time0_r
001C                  00112 service_r
001C   0822           00113         MOVFW   FSR_TMP         ;恢复被保护的寄存器
001D   0084           00114         MOVWF   FSR
001E   0821           00115         MOVFW   PCLATH_TMP
001F   008A           00116         MOVWF   PCLATH          ;column X
0020   0E20           00117         swapf   status_temp,W
0021   0083           00118         movwf   STATUS          ;bank X
0022   0EF1           00119         swapf   w_temp,F
0023   0E71           00120         swapf   w_temp,W
0024   0009           00121         retfie                  ;exit interrupt 
                      00122 
                      00123 
                      00124 
                      00125 ;**********************************************
0025                  00126 start   
0025   0183           00127         clrf    STATUS
0026   018A           00128         CLRF    PCLATH
0027   1683           00129         BSF     STATUS,RP0      ;Bank1  
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0028   188E           00130         BTFSC   PCON,NOT_POR    ;上电复位?
0029   2835           00131         GOTO    LOOP            ;N
                      00132 
                      00133 ;*********************************************上电复位
002A                  00134 start2  
002A   0183           00135         clrf    STATUS          ;上电时需初始化的变量   
002B   01A3           00136         clrf    flag
002C   3064           00137         movlw   .100            ;1000ms
002D   00A9           00138         MOVWF   sec             ;
                      00139         
002E   30FF           00140         movlw   0xff            ;输入口初始化
002F   00C0           00141         MOVWF   keyh
0030   00C3           00142         MOVWF   keyl
0031   01C6           00143         CLRF    key_tim
0032   301E           00144         MOVLW   .30
0033   00C7           00145         MOVWF   key_set         ;延时设定0-255MS
                      00146         
0034   2835           00147         GOTO    LOOP
                      00148 ;**********************************************其它复位                                 
0035                  00149 LOOP
0035   0183           00150         clrf    STATUS
0036   0064           00151         CLRWDT                  ;清狗   
0037   1683           00152         BSF     STATUS, RP0     ;Bank1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0038   148E           00153         BSF     PCON,NOT_POR    ;RESET NOT_POR
0039   30FF           00154         MOVLW   B'11111111'     ;PORTA\B\C\D\E方向设定1:IN 0:OUT  
MPASM  4.00 Released                               SAMPLE.ASM   9-19-2005  23:12:24         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
003A   0085           00155         MOVWF   TRISA
003B   30FF           00156         MOVLW   B'11111111'     ;
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
003C   0086           00157         MOVWF   TRISB
003D   30FF           00158         MOVLW   B'11111111'     ;
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
003E   0087           00159         MOVWF   TRISC           ; 
003F   30FF           00160         MOVLW   B'11111111'     ; 
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0040   0088           00161         MOVWF   TRISD
0041   300F           00162         MOVLW   B'00001111'     ; 
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0042   0089           00163         MOVWF   TRISE
0043   3007           00164         movlw   B'00000111'     ;select DDDDDDDD,ADC不用
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0044   009F           00165         movwf   ADCON1          ;analog inputs
0045   3088           00166         movlw   B'10001000'
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0046   0081           00167         MOVWF   OPTION_REG      ;1:1 for  WDT(18ms)预分频给看门狗
0047   3000           00168         MOVLW   B'00000000'     ;Off OTHER IE   关了不用的中断
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0048   008C           00169         MOVWF   PIE1
0049   130B           00170         BCF     INTCON,6        ;Off OTHER IE   关了不用的中断
004A   178B           00171         BSF     INTCON,7        ;ON GIE 开总中断
004B   168B           00172         BSF     INTCON,5        ;ON TIMER0 开TIMER0开总中断
004C   0183           00173         clrf    STATUS
004D   2051           00174         CALL    time1           ;CALL 时基1
004E   3069           00175         MOVLW   Crc8
004F   2079           00176         CALL    ACrcJs          ;计算Crc0--Crc8的CRC检验码,用于MODBUS 结果CrcH1 CrcL1
0050   2835           00177         GOTO    LOOP            ;不断循环运行
                      00178 
                      00179         
0051                  00180 time1                           ;时基1
0051   1823           00181         btfsc   flag,time1_f    ;10ms到?
0052   2854           00182         goto    time1_1         ;y
0053   2859           00183         goto    time1_r         ;n
0054                  00184 time1_1
0054   1023           00185         bcf     flag,time1_f    ;CLR time1_f 10ms到了
                      00186         ;TSTF   timeout ;       ;超时倒计时==0?
                      00187         ;btfss  3,2             
                      00188         ;decf   timeout,F       ;n -1
                      00189         
                      00190         
0055   0BA9           00191         decfsz  sec,F           ;sec-1==0?      
0056   2859           00192         goto    time1_r         ;n 
0057   3064           00193         movlw   .100            ;y 1000ms
0058   00A9           00194         MOVWF   sec             ;1s到了
                      00195 
0059                  00196 time1_r
0059   0008           00197         return
                      00198         
                      00199 ;输入口扫描(中断服务)

⌨️ 快捷键说明

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