?? clock.lst
字號:
MPASM 01.40 Released CLOCK.ASM 1-16-1997 17:05:59 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 LIST P = 16C74, n = 66
00002 ERRORLEVEL -302
00003 ;
00004 ;******************************************************************************
00005 ;
00006 ; This program implements a real time clock using the TMR1 module of the
00007 ; PIC16Cxx family. A LCD display module is used to display (update) the time
00008 ; every second. Three keys are used to set the time.
00009 ;
00010 ; Program = CLOCK.ASM
00011 ; Revision Date: 5-15-94
00012 ; 1-15-97 Compatibility with MPASMWIN 1.40
00013 ;
00014 ;******************************************************************************
00015 ;
00016 ;
00017 ; HARDWARE SETUP
00018 ; LCD Control Lines
00019 ; RA0 = E (Enable)
00020 ; RA1 = RW (Read/Write)
00021 ; RA2 = RS (Register Select)
00022 ; LCD Data Lines
00023 ; RB<3:0>
00024 ; Switch Inputs
00025 ; RB7 = Select Hour / Minute / Off
00026 ; RB6 = Increment Hour / Minute
00027 ; RB5 = Reset Minutes to 00
00028 ;
00029 INCLUDE <p16c74.inc>
00001 LIST
00002 ; P16C74.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
00318 LIST
00030
00000000 00031 FALSE EQU 0
00000001 00032 TRUE EQU 1
00033
00034 INCLUDE <CLOCK.h>
00076 list
00035 ;
00000006 00036 LCD_DATA EQU PORTB ; The LCD data is on the lower 4-bits
00000086 00037 LCD_DATA_TRIS EQU TRISB ; The TRIS register for the LCD data
00000005 00038 LCD_CNTL EQU PORTA ; Three control lines
00039 ;
00000000 00040 PICMaster EQU FALSE ; A Debugging Flag
00000000 00041 Debug EQU FALSE ; A Debugging Flag
00000001 00042 Debug_PU EQU TRUE ; A Debugging Flag
00043 ;
00044 ;
00045 ; Reset address. Determine type of RESET
00046 ;
0000 00047 org RESET_V ; RESET vector location
0000 1683 00048 RESET BSF STATUS, RP0 ; Bank 1
0001 188E 00049 BTFSC PCON, NOT_POR ; Power-up reset?
0002 290C 00050 GOTO START ; YES
0003 295E 00051 GOTO OTHER_RESET ; NO, a WDT or MCLR reset
00052 ;
00053 ; This is the Periperal Interrupt routine. Need to determine the type
00054 ; of interrupt that occurred. The following interrupts are enabled:
00055 ; 1. PORTB Change (RBIF)
00056 ; 2. TMR1 Overflow Interrupt (T1IF)
MPASM 01.40 Released CLOCK.ASM 1-16-1997 17:05:59 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00057 ;
MPASM 01.40 Released CLOCK.ASM 1-16-1997 17:05:59 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00058 page
0004 00059 org ISR_V ; Interrupt vector location
0004 00060 PER_INT_V
00061 if ( Debug )
00062 bsf PORTD, 0 ; Set high, use to measure total
00063 endif ; time in Int Service Routine
00064 ;
0004 1283 00065 BCF STATUS, RP0 ; Bank 0
0005 180C 00066 BTFSC PIR1, TMR1IF ; Timer 1 overflowed?
0006 2843 00067 GOTO T1_OVRFL ; YES, Service the Timer1 Overflow Interrupt
0007 1C0B 00068 BTFSS INTCON, RBIF ; NO, Did PORTB change?
0008 28D0 00069 GOTO ERROR1 ; NO, Error Condition - Unknown Interrupt
00070 ;
0009 00071 PORTB_FLAG ; Are any of PORTB's inputs active?
0009 0806 00072 MOVF PORTB, W ;
000A 39E0 00073 ANDLW 0xE0 ; Keep only the 3 switch values
000B 00B5 00074 DEBOUNCE MOVWF TEMP ;
000C 3002 00075 MOVLW DB_HI_BYTE ; This is the debounce delay
000D 08B3 00076 MOVF MSD, F ;
000E 01B4 00077 CLRF LSD ;
000F 0BB4 00078 KB_D_LP1 DECFSZ LSD, F ;
0010 280F 00079 GOTO KB_D_LP1 ;
0011 0BB3 00080 DECFSZ MSD, F ;
0012 280F 00081 GOTO KB_D_LP1 ;
0013 0806 00082 END_DELAY MOVF PORTB, W ;
0014 39E0 00083 ANDLW 0xE0 ; Keep only the 3 switch values
0015 02B5 00084 SUBWF TEMP, F ;
0016 1D03 00085 BTFSS STATUS, Z ; Is the Zero bit set?
00086 ; (switches were the same on 2 reads)
0017 280B 00087 GOTO DEBOUNCE ; NO, Try another read
0018 00B5 00088 KEY_MATCH MOVWF TEMP ; YES, need to see which is depressed.
00089 ;
0019 3080 00090 MOVLW 0x80 ; Since doing key inputs, clear TMR1
001A 008F 00091 MOVWF TMR1H ; for 1 sec overflow.
001B 018E 00092 CLRF TMR1L ;
001C 100C 00093 BCF PIR1, TMR1IF ; Clear Timer 1 Interrupt Flag
00094
001D 1FB5 00095 BTFSS TEMP, HR_MIN_SW ; Is the hour-min-off switch depressed?
001E 2826 00096 GOTO SELECT_UNITS ; YES, specify the units selected
001F 1F35 00097 BTFSS TEMP, INC_SW ; Is the inc switch depressed?
0020 282B 00098 GOTO INC_UNIT ; YES, Increment the selected Units
0021 1EB5 00099 BTFSS TEMP, CLR_MIN_SW ; Is the clear minute switch depressed?
0022 2835 00100 GOTO CLR_MIN ; YES, clear the minutes.
00101 ;
00102 ; No key match occured, or finished with PortB interrupt and need to clear interrupt condition.
00103 ;
0023 00104 CLR_RB ; No RB<7:5> keys are depressed (rising edge Int.)
0023 0886 00105 MOVF PORTB, F ; Clear the PORTB mismatch condition
0024 100B 00106 BCF INTCON, RBIF ; Clear the PORTB Int Flag
00107 if ( Debug )
00108 bcf PORTD, 0 ; Set low, use to measure total
00109 ; time in Int Service Routine
00110 endif
0025 0009 00111 RETFIE ; Return / Enable Global Interrupts
00112 ;
MPASM 01.40 Released CLOCK.ASM 1-16-1997 17:05:59 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00113 page
0026 00114 SELECT_UNITS
0026 30FF 00115 MOVLW 0xFF ;
0027 00C0 00116 MOVWF WAIT_CNTR ; WAIT_CNTR has LSb set after each SELECT UNIT key press.
0028 0AA0 00117 INCF FLAG_REG, F ; Increment the pointer to the MIN_UNIT:HR_UNIT
0029 1620 00118 BSF FLAG_REG, KEY_INPUT ;
002A 2875 00119 GOTO DISPLAY ; Flash the Display of the selected unit
00120 ;
002B 00121 INC_UNIT
002B 01C0 00122 CLRF WAIT_CNTR ; WAIT_CNTR is cleared to zero after each key press.
002C 1820 00123 BTFSC FLAG_REG, HR_UNIT ; Are the hour units selected?
002D 285C 00124 GOTO INC_HRS ; YES, Increment the hour units
002E 1CA0 00125 BTFSS FLAG_REG, MIN_UNIT ; Are the minute units selected?
002F 2823 00126 GOTO CLR_RB ; NO, Not a valid key. Clear flags
00127 ;
0030 0AB1 00128 INCF MIN, F ; YES, Increment the minute units
0031 303C 00129 MOVLW 0x3C ; This is Decimal 60
0032 0231 00130 SUBWF MIN, W ; MIN - 60 = ?
0033 1D03 00131 BTFSS STATUS, Z ; MIN = 60?
0034 2875 00132 GOTO DISPLAY ; NO, display time
00133 ; YES, MIN = 0 (use code from CLR_MIN)
0035 01B1 00134 CLR_MIN CLRF MIN ; MIN = 0
0036 3004 00135 MOVLW 0x04 ; Clear the seconds
0037 00B2 00136 MOVWF SECS ; Initial Second count = 4
0038 3080 00137 MOVLW 0x80 ; Clear Timer 1, for 1 sec overflow
0039 008F 00138 MOVWF TMR1H ;
003A 018E 00139 CLRF TMR1L ;
003B 100C 00140 BCF PIR1, TMR1IF ; Clear the TMR1 overflow interrupt.
003C 01C0 00141 CLRF WAIT_CNTR ; WAIT_CNTR is cleared to zero after each key press.
003D 1AB5 00142 BTFSC TEMP, CLR_MIN_SW ; Is the clear minute switch depressed?
003E 2875 00143 GOTO DISPLAY ; NO. Rollover from increment key
003F 10A0 00144 BCF FLAG_REG, MIN_UNIT ; YES, Clear ALL relevant flags
0040 1020 00145 BCF FLAG_REG, HR_UNIT ;
0041 1220 00146 BCF FLAG_REG, KEY_INPUT ;
0042 2875 00147 GOTO DISPLAY ;
00148 ;
MPASM 01.40 Released CLOCK.ASM 1-16-1997 17:05:59 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00149 page
00150 ;
0043 00151 T1_OVRFL
0043 100C 00152 BCF PIR1, TMR1IF ; Clear Timer 1 Interrupt Flag
0044 1E20 00153 BTFSS FLAG_REG, KEY_INPUT ; Are we using the key inputs?
0045 284F 00154 GOTO INC_TIME ; NO, Need to Increment the time
0046 0AC0 00155 INCF WAIT_CNTR, F ; YES,
0047 300A 00156 MOVLW 0x0A ; 10 counts x 1 seconds
0048 0240 00157 SUBWF WAIT_CNTR, W ; Has the 10 Sec wait for key expired?
0049 1D03 00158 BTFSS STATUS, Z ; Is the result 0?
004A 2875 00159 GOTO DISPLAY ; NO, Display value
004B 01C0 00160 CLRF WAIT_CNTR ; YES, Clear WAIT_CNTR
004C 1220 00161 BCF FLAG_REG, KEY_INPUT ;
004D 1020 00162 BCF FLAG_REG, HR_UNIT ;
004E 10A0 00163 BCF FLAG_REG, MIN_UNIT ;
00164 ;
00165 ;
004F 3080 00166 INC_TIME MOVLW 0x80 ;
0050 008F 00167 MOVWF TMR1H ; 1 Second Overflow
0051 0AB2 00168 INCF SECS, F ;
0052 1F32 00169 BTFSS SECS, 6 ;
0053 2875 00170 GOTO DISPLAY ;
0054 3004 00171 MOVLW 0x04 ;
0055 00B2 00172 MOVWF SECS ;
0056 0AB1 00173 INCF MIN, F ;
0057 303C 00174 MOVLW 0x3C ; W = 60d
0058 0231 00175 SUBWF MIN, W ;
0059 1D03 00176 BTFSS STATUS, Z ;
005A 2875 00177 GOTO DISPLAY ;
005B 01B1 00178 CLRF MIN ;
005C 0AB0 00179 INC_HRS INCF HRS, F ;
00180
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -