📄 tic.lst
字号:
TIC PAGE 1
1 ;********************************************************************
2 ;
3 ; Author : ADI - Apps www.analog.com/MicroConverter
4 ;
5 ; Date : July 2003
6 ;
7 ; File : TIC.asm
8 ;
9 ; Hardware : ADuC845
10 ;
11 ; Description : Demonstrates a use of a timer interval counter for
12 ; counting longer intervals than the standard 8052
13 ; timers are capable of.
14 ;
15 ; The LED will, on power up, flash at 12Hz. By pressing
16 ; the external interrupt button INT0 the counter will
17 ; count how long the button is pressed correct to
18 ; 1/128th of a second. When released the program will
19 ; flash the light at the measured time correct only to
20 ; the nearest unit (1/128s, seconds, minutes or hours)
21 ; rounded DOWN.
22 ; eg) If the button was pressed for 0.91000s the light
23 ; would complement every 0.90625s (less than 1 second
24 ; therefore it measures in 1/128s and the nearest unit
25 ; less than 0.91000s is 0.90625s). However if the light
26 ; was on for 1.6s it complements every 1s as the nearest
27 ; unit is now the second.
28 ; Pressing the INT0 button again will record a new
29 ; time interval which will flash the light in the same
30 ; way.
31
32 ;********************************************************************
33
34 $MOD845 ; Use ADuC845 predefined symbols
35
00B4 36 LED EQU P3.4 ; P3.4 drives red LED on eval board
00B2 37 BUTTON EQU P3.2 ; P3.2 drives the INT0 button on the
38 ; eval board
39
40 ;____________________________________________________________________
41 ; BEGINNING OF CODE
---- 42 CSEG
0000 43 ORG 0000h
0000 020100 44 JMP MAIN ; jump to main program
45
46 ;____________________________________________________________________
47 ; EXTERNAL INTERRUPT VECTOR SPACE
0003 48 ORG 0003h ; (INT0 ISR)
49
0003 D2B4 50 SETB LED ; Turn ON the LED while the INT0
51 ; is pressed
52
53 ; reset all counters and then start counting
0005 53A1FE 54 ANL TIMECON, #0FEh ; Clear the TCEN bits to clear the
55 ; registers;
56 ; -Hthsec
57 ; -sec
58 ; -min
TIC PAGE 2
59 ; -hour.
60 ; and to clears the internal counter
61
0008 43A101 62 ORL TIMECON, #01h ; Set the TCEN bit to restart counting
63
000B 30B2FD 64 JNB BUTTON, $ ; Wait here while button is pressed
65
000E 53A1FD 66 ANL TIMECON, #0FDh ; Clear the TIEN bit to stop the
67 ; counter
68
69 ; after button is released we can store the value in intval
70
0011 C2B4 71 LOOP: CLR LED ; Turn off LED to indicate that the
72 ; button is released.
0013 E5A5 73 MOV A, HOUR
0015 B40028 74 CJNE A, #00H, HOURS ; Check if any hrs have been counted
75 ; If so jump to HOURS
0018 E5A4 76 MOV A, MIN
001A B40019 77 CJNE A, #00H, MINS ; Check if any mins have been counted
78 ; If so jump to MINS
001D E5A3 79 MOV A, SEC
001F B4000A 80 CJNE A, #00H, SECS ; Check if any secs have been counted
81 ; If so jump to SECS
82
0022 85A2A6 83 HUNTHS: MOV INTVAL, HTHSEC ;load the value of HTHSEC into INTVAL
0025 75A100 84 MOV TIMECON, #00h ; clear TCEN to reset the registers
0028 75A103 85 MOV TIMECON, #03H ; change TIMECON to measure in 1/128s
86 ; reset TIEN
002B 32 87 RETI
88
002C 85A3A6 89 SECS: MOV INTVAL, SEC ; load the value of SEC into INTVAL
002F 75A100 90 MOV TIMECON, #00h ; clear TCEN to reset the registers
0032 75A113 91 MOV TIMECON, #13H ; change TIMECON to measure in secs
0035 32 92 RETI
93
0036 85A4A6 94 MINS: MOV INTVAL, MIN ; load the value of MIN into INTVAL
0039 75A100 95 MOV TIMECON, #00h ; clear TCEN to reset the registers
003C 75A123 96 MOV TIMECON, #23H ; change TIMECON to measure in mins
003F 32 97 RETI
98
0040 85A5A6 99 HOURS: MOV INTVAL, HOUR ; load the value of HOUR onto INTVAL
0043 75A100 100 MOV TIMECON, #00h ; clear TCEN to reset the registers
0046 75A133 101 MOV TIMECON, #33H ; change TIMECON to measure in hours
0049 32 102 RETI
103 ;____________________________________________________________________
104 ; TII INTERRUPT VECTOR SPACE
0053 105 ORG 0053h
106
0053 B2B4 107 CPL LED ; Complement the LED every time the
108 ; measured time runs up.
0055 32 109 RETI
110 ;_____________________________________________________________________
111
0100 112 ORG 0100h
113
0100 114 MAIN:
115
116 ; Configure Time Interval Counter
TIC PAGE 3
117 ;MOV PLLCON, #07h
0100 75A200 118 MOV HTHSEC, #00h
0103 75A300 119 MOV SEC, #00h
0106 75A400 120 MOV min, #00h
0109 75A500 121 mov hour, #00h
122
010C 75A103 123 MOV TIMECON, #03h ; initialise timecon to count in 1/128s
124 ; -set TCEN to enable the time clock
125 ; -set TIEN to enable the TIC
126 ; -clear STI to allow automatic relaod
127 ; of interval timeout
128 ; -clear TFH to disable 24 hr counting
129
010F 75A60A 130 MOV INTVAL, #0Ah ; initialise to blink LED every 10 units
131 ; the units are 1/128s ....
132 ;1/(10 * 1/128) = 12.8Hz = LED toggle rate
133
134 ; Configure External Interrupt
0112 D288 135 SETB IT0 ; INT0 edge triggered
0114 D2A8 136 SETB EX0 ; enable INT0 (button on eval board)
0116 75A904 137 MOV IEIP2,#04H ; enable time interval interrupt
138
0119 D2AF 139 SETB EA ; enable global interrupts
140
141
011B 80FE 142 JMP $ ; wait here for interrupts
143 ; main program can be inserted here
144
145 ;____________________________________________________________________
146
147 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
TIC PAGE 4
BUTTON . . . . . . . . . . . . . NUMB 00B2H
EA . . . . . . . . . . . . . . . B ADDR 00AFH PREDEFINED
EX0. . . . . . . . . . . . . . . B ADDR 00A8H PREDEFINED
HOUR . . . . . . . . . . . . . . D ADDR 00A5H PREDEFINED
HOURS. . . . . . . . . . . . . . C ADDR 0040H
HTHSEC . . . . . . . . . . . . . D ADDR 00A2H PREDEFINED
HUNTHS . . . . . . . . . . . . . C ADDR 0022H NOT USED
IEIP2. . . . . . . . . . . . . . D ADDR 00A9H PREDEFINED
INTVAL . . . . . . . . . . . . . D ADDR 00A6H PREDEFINED
IT0. . . . . . . . . . . . . . . B ADDR 0088H PREDEFINED
LED. . . . . . . . . . . . . . . NUMB 00B4H
LOOP . . . . . . . . . . . . . . C ADDR 0011H NOT USED
MAIN . . . . . . . . . . . . . . C ADDR 0100H
MIN. . . . . . . . . . . . . . . D ADDR 00A4H PREDEFINED
MINS . . . . . . . . . . . . . . C ADDR 0036H
P3 . . . . . . . . . . . . . . . D ADDR 00B0H PREDEFINED
SEC. . . . . . . . . . . . . . . D ADDR 00A3H PREDEFINED
SECS . . . . . . . . . . . . . . C ADDR 002CH
TIMECON. . . . . . . . . . . . . D ADDR 00A1H PREDEFINED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -