📄 gainewxiankong.lst
字号:
1 000000 ;*******************************************************************************
2 000000 ; FILENAME : 2501A_TEMPLATE.ASM for S8KE ICE
3 000000 ; AUTHOR : SONiX
4 000000 ; PURPOSE : Template Code for SN8P2501A
5 000000 ; REVISION : 06/05/2004 V1.0 First issue
6 000000 ; : 07/07/2004 V1.1 Remove ICE_MODE definition and some macro
7 000000 ; for SN8ICE 2K
8 000000 ;*******************************************************************************
9 000000 ;* (c) Copyright 2004, SONiX TECHNOLOGY CO., LTD.
10 000000 ;*******************************************************************************
11 000000
12 000000 CHIP SN8P2501b ; Select the CHIP
13 000000 //{{SONIX_CODE_OPTION
14 000000 .Code_Option Noise_Filter Enable
15 000000 .Code_Option Watch_Dog Enable ; Normal mode: Enable Watchdog Green and Sleep mode: Stop Watchdog
16 000000 .Code_Option Reset_Pin Reset
17 000000 .Code_Option High_Clk 4M_X'tal ; Crystal/Resonator: 2Mhz~10Mhz
18 000000 .Code_Option Fcpu #2 ; Fcpu = Fosc/4
19 000000 .Code_Option Security Enable
20 000000 .Code_Option LVD LVD_L ; 2.0V Reset
21 000000 ; .Code_Option 16M_IHRC #6 ; 16M_IHRC = Normal
22 000000
23 000000 //}}SONIX_CODE_OPTION
24 000000
25 000000 ;-------------------------------------------------------------------------------
26 000000 ; Include Files
27 000000 ;-------------------------------------------------------------------------------
28 000000
29 000000 ;-------------------------------------------------------------------------------
30 000000 ; Constants Definition
31 000000 ;-------------------------------------------------------------------------------
32 000000 ; ONE EQU 1
33 000000
34 000000 ;-------------------------------------------------------------------------------
35 000000 ; Variables Definition
36 000000 ;-------------------------------------------------------------------------------
37 000000 .DATA
38 000000 org 0h ;Data section start from RAM address 0
39 E 00000000 Wk00 EQU 00H ;Temporary buffer for main loop
40 E 00000001 Iwk00 EQU 01H ;Temporary buffer for ISR
41 E 00000002 AccBuf EQU 02H ;Accumulater buffer
42 E 00000003 PflagBuf EQU 03H ;PFLAG buffer
43 E 00000004 t1 EQU 04H
44 E 00000005 VAR1 EQU 05H
45 E 00000006 VAR2 EQU 06H
46 E 00000007 VAR3 EQU 07H
47 E 00000008 VAR4 EQU 08H
48 E 00000009 MOVE_TIME EQU 09H
49 E 0000000A RRCDATA EQU 0AH
50 E 0000000B DEVAR1 EQU 0BH
51 E 0000000C DEVAR2 EQU 0CH
52 E 0000000D DATAINDEX EQU 0DH
53 E 0000000E MOVETEMP EQU 0EH
54 E 0000000F keyvalue equ 0fh
55 E 00000010 DOWNTIME EQU 10H
56 E 00000011 UPTIME EQU 11H
57 E 00000012 voluplim equ 12h
58 E 00000013 voldownlim equ 13h
59 E 00000014 movetime equ 14h
60 E 00000015 sdata equ 15h
61 E 00000016 KEYFLAG EQU 16H
62 000000 ;-------------------------------------------------------------------------------
63 000000 ; Bit Variables Definition
64 000000 ;-------------------------------------------------------------------------------
65 000000
66 E 00000000 Wk00B0 EQU Wk00.0 ;Bit 0 of Wk00
67 E 00010001 Iwk00B1 EQU Iwk00.1 ;Bit 1 of Iwk00
68 E 00020086 FLAGC EQU PFLAG.2
69 E 00000086 FLAGZ EQU PFLAG.0
70 E 000200D2 RX equ fp22
71 E 000100D2 TX EQU FP21
72 E 000000D2 MUTEPIN EQU FP20
73 E 000400D5 lock equ fp54
74 E 000400D2 updown equ fp24
75 E 000300D2 clock equ fp23
76 000000 ;-------------------------------------------------------------------------------
77 000000 ; Code section
78 000000 ;-------------------------------------------------------------------------------
79 000000 .CODE
80 000000
81 000000 ORG 0 ;Code section start
82 000000
83 000000 8010(2) jmp Reset ;Reset vector
84 000001 ;Address 4 to 7 are reserved
85 000008 ORG 8
86 000008 8158(2) jmp Isr ;Interrupt vector
87 000009
88 000010 ORG 10h
89 000010 ;-------------------------------------------------------------------------------
90 000010 ; Program reset section
91 000010 ;-------------------------------------------------------------------------------
92 000010 Reset:
93 000010 2D7F(1) mov A,#07Fh ;Initial stack pointer and
94 000011 2FDF(1) b0mov STKP,A ;disable global interrupt
95 000012 2B86(1) clr PFLAG ;pflag = x,x,x,x,x,c,dc,z
96 000013 2D01(1) mov A,#01h ;Initial system mode
97 000014 2FCA(1) b0mov OSCM,A
98 000015 2D5A(1) mov A, #0x5A
99 000016 2FCC(1) b0mov WDTR, A ;Clear watchdog timer
100 000017 C16C(2) call ClrRAM ;Clear RAM
101 000018 C159(2) call SysInit ;System initial
102 000019 6FDF(1) b0bset FGIE ;Enable global interrupt
103 00001A 2D0A(1) mov a,#10
104 00001B 1F12(1) mov voluplim,a
105 00001C 2D0A(1) mov a,#10
106 00001D 1F13(1) mov voldownlim,a
107 00001E 2DFA(1) mov a,#250
108 00001F 1F14(1) mov movetime,a
109 000020 volmiusmius:
110 000020 C11E(2) call VOLMIUS
111 000021 C13B(2) call delay64
112 000022 2614(1+S) decms movetime
113 000023 8020(2) jmp volmiusmius
114 000024 2DFA(1) mov a,#250
115 000025 1F14(1) mov movetime,a
116 000026 volmiusmius_1:
117 000026 C11E(2) call VOLMIUS
118 000027 C13B(2) call delay64
119 000028 2614(1+S) decms movetime
120 000029 8026(2) jmp volmiusmius_1
121 00002A 2DFA(1) mov a,#250
122 00002B 1F14(1) mov movetime,a
123 00002C volmiusmius_2:
124 00002C C11E(2) call VOLMIUS
125 00002D C13B(2) call delay64
126 00002E 2614(1+S) decms movetime
127 00002F 802C(2) jmp volmiusmius_2
128 000030 2DFA(1) mov a,#250
129 000031 1F14(1) mov movetime,a
130 000032 volmiusmius_3:
131 000032 C11E(2) call VOLMIUS
132 000033 C13B(2) call delay64
133 000034 2614(1+S) decms movetime
134 000035 8032(2) jmp volmiusmius_3
135 000036 C117(2) call voladd
136 000037 C117(2) call voladd
137 000038 C117(2) call voladd
138 000039 ;-------------------------------------------------------------------------------
139 000039 ; Main routine
140 000039 SB_1:
141 000039 60C1(1) B0Bclr FP10M
142 00003A 2D5A(1) MOV A,#5AH
143 00003B 2FCC(1) B0MOV WDTR,A ; CLEAR WDT
144 00003C C149(2) call delay10ms
145 00003D 7CD5(1+S) B0BTS1 FP54
146 00003E 8039(2) JMP SB_1
147 00003F 68C1(1) B0Bset FP10M
148 000040 C149(2) call delay10ms
149 000041 68D1(1) B0BSET FP10
150 000042 C149(2) call delay10ms
151 000043 7DD2(1+S) b0bts1 fp25
152 000044 8057(2) jmp keyadvance
153 000045 78D0(1+S) b0bts1 FP00
154 000046 8053(2) JMP keyvolmius
155 000047 C149(2) call delay10ms
156 000048 60D1(1) B0BCLR FP10
157 000049 C149(2) call delay10ms
158 00004A 7DD2(1+S) B0BTS1 FP25
159 00004B 805F(2) JMP keyvoladd
160 00004C 78D0(1+S) B0BTS1 FP00
161 00004D 8065(2) JMP keyback
162 00004E 60C1(1) B0BCLR FP10M
163 00004F C149(2) call delay10ms
164 000050 70D1(1+S) B0BTS0 FP10
165 000051 8039(2) JMP SB_1
166 000052 805B(2) JMP keyplay
167 000053 ;-----------------------------------
168 000053 keyvolmius:
169 000053 C143(2) call delay1ms
170 000054 70D0(1+S) b0bts0 fp00
171 000055 8039(2) jmp sb_1
172 000056 8095(2) jmp volmiuskey
173 000057 keyadvance: ; rew
174 000057 C143(2) call delay1ms
175 000058 7DD2(1+S) b0bts1 fp25
176 000059 8088(2) jmp advance
177 00005A 8039(2) jmp SB_1
178 00005B keyplay:
179 00005B C143(2) call delay1ms
180 00005C 70D1(1+S) b0bts0 fp10
181 00005D 8039(2) jmp sb_1
182 00005E 806B(2) jmp playkey
183 00005F keyvoladd:
184 00005F 68D1(1) B0BSET FP10
185 000060 C131(2) CALL DELAY50
186 000061 C131(2) CALL DELAY50
187 000062 7DD2(1+S) B0BTS1 FP25
188 000063 8088(2) JMP advance
189 000064 80B2(2) jmp voladdkey
190 000065 keyback:
191 000065 68D1(1) B0BSET FP10
192 000066 C131(2) CALL DELAY50
193 000067 C131(2) CALL DELAY50
194 000068 78D0(1+S) b0bts1 fp00
195 000069 8095(2) jmp volmiuskey
196 00006A 8078(2) jmp back
197 00006B
198 00006B ;===================================
199 00006B playkey:
200 00006B 0000(1) nop
201 00006C C0DF(2) call leadzero
202 00006D 2D01(1) mov a,#01h
203 00006E 1F15(1) mov sdata,a
204 00006F C105(2) call SENDDATRA
205 000070 2DFA(1) mov a,#0fah
206 000071 1F15(1) mov sdata,a
207 000072 C105(2) call SENDDATRA
208 000073 C125(2) call delay12ms
209 000074 78D1(1+S) B0BTS1 FP10
210 000075 806B(2) jmp playkey
211 000076 C0EF(2) call buttonup
212 000077 8039(2) jmp sb_1
213 000078 back:
214 000078 0000(1) nop
215 000079 C0DF(2) call leadzero
216 00007A 2D10(1) mov a,#10h
217 00007B 1F15(1) mov sdata,a
218 00007C C105(2) call SENDDATRA
219 00007D 2DEB(1) mov a,#0ebh
220 00007E 1F15(1) mov sdata,a
221 00007F C105(2) call SENDDATRA
222 000080 C125(2) call delay12ms
223 000081 60D1(1) B0BCLR FP10
224 000082 C131(2) CALL DELAY50
225 000083 C131(2) CALL DELAY50
226 000084 78D0(1+S) B0BTS1 FP00
227 000085 8078(2) jmp back
228 000086 C0EF(2) call buttonup
229 000087 8039(2) jmp sb_1
230 000088 ;--------------------------------------
231 000088 advance:
232 000088 0000(1) nop
233 000089 C0DF(2) call leadzero
234 00008A 2D08(1) mov a,#08h
235 00008B 1F15(1) mov sdata,a
236 00008C C105(2) call SENDDATRA
237 00008D 2DF3(1) mov a,#0f3h
238 00008E 1F15(1) mov sdata,a
239 00008F C105(2) call SENDDATRA
240 000090 C125(2) call delay12ms
241 000091 7DD2(1+S) b0bts1 fp25
242 000092 8088(2) jmp advance
243 000093 C0EF(2) call buttonup
244 000094 8039(2) jmp sb_1
245 000095 ;----------------------------------
246 000095 volmiuskey:
247 000095 0000(1) nop
248 000096 C0DF(2) call leadzero
249 000097 2D04(1) mov a,#04h
250 000098 1F15(1) mov sdata,a
251 000099 C105(2) call SENDDATRA
252 00009A 2DF7(1) mov a,#0f7h
253 00009B 1F15(1) mov sdata,a
254 00009C C105(2) call SENDDATRA
255 00009D C12B(2) call VOLDELAY12MS
256 00009E 5810(1+S) BTS1 DOWNTIME.0
257 00009F 80A1(2) jmp downkey_1
258 0000A0 80AB(2) jmp downkey_2
259 0000A1 downkey_1:
260 0000A1 1E13(1) mov a,voldownlim
261 0000A2 060D(1+S) cmprs a,#13
262 0000A3 80A5(2) jmp downkey_1_1
263 0000A4 80AB(2) jmp downkey_2
264 0000A5 downkey_1_1:
265 0000A5 2D01(1) mov a,#1
266 0000A6 1313(1) add voldownlim,a
267 0000A7 1E12(1) mov a,voluplim
268 0000A8 2401(1) sub a,#1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -