0
|
1 ; OSTC - diving computer code
|
|
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR
|
|
3 ; This program is free software: you can redistribute it and/or modify
|
|
4 ; it under the terms of the GNU General Public License as published by
|
|
5 ; the Free Software Foundation, either version 3 of the License, or
|
|
6 ; (at your option) any later version.
|
|
7 ; This program is distributed in the hope that it will be useful,
|
|
8 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 ; GNU General Public License for more details.
|
|
11 ; You should have received a copy of the GNU General Public License
|
|
12 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
13 ; Wait routines
|
|
14 ; written by: chsw, info@heinrichsweikamp.com
|
|
15 ; written: 01/31/04
|
|
16 ; last updated: 11/05/07
|
|
17 ; known bugs:
|
|
18 ; ToDo:
|
|
19 IFDEF Clk_4_MHZ
|
|
20 MESSG "wait_v2i: switched to 4 MHZ operation"
|
|
21 ELSE
|
|
22 IFDEF Clk_8_MHZ
|
|
23 MESSG "wait_v2i: switched to 8 MHZ operation"
|
|
24 ELSE
|
|
25 IFDEF Clk_16_MHZ
|
|
26 MESSG "wait_v2i: switched to 16 MHZ operation"
|
|
27 ELSE
|
|
28 IFDEF Clk_20_MHZ
|
|
29 MESSG "wait_v2i: switched to 20 MHZ operation"
|
|
30 ELSE
|
|
31 ERROR "wait_v2i: Operating Frequency has to be specified by #DEFINE Clk_4_MHZ or Clk_8_MHZ"
|
|
32 ENDIF
|
|
33 ENDIF
|
|
34 ENDIF
|
|
35 IFDEF Clk_16_MHZ
|
|
36 ; ==========================================================
|
|
37 ; WAIT 10 MICROSECONDS - 16 MHZ
|
|
38 ; ==========================================================
|
|
39 WAIT10US macro wait_temp
|
|
40 movlw wait_temp
|
|
41 IFNDEF DEBUG
|
|
42 call WAIT10USX
|
|
43 ENDIF
|
|
44 endm
|
|
45
|
|
46 WAIT10USX movwf wait_temp
|
|
47 goto JumpIn10us
|
|
48 WAIT10USX2 nop
|
|
49 nop
|
|
50 nop
|
|
51 nop
|
|
52 nop
|
|
53 nop
|
|
54 nop
|
|
55 nop
|
|
56 nop
|
|
57 JumpIn10us:
|
|
58 nop
|
|
59 nop
|
|
60 nop
|
|
61 nop
|
|
62 nop
|
|
63 nop
|
|
64 nop
|
|
65 nop
|
|
66 nop
|
|
67 nop
|
|
68 nop
|
|
69 nop
|
|
70 nop
|
|
71 nop
|
|
72 nop
|
|
73 nop
|
|
74 nop
|
|
75 nop
|
|
76 nop
|
|
77 nop
|
|
78 nop
|
|
79 nop
|
|
80 nop
|
|
81 nop
|
|
82 nop
|
|
83 nop
|
|
84 nop
|
|
85 nop
|
|
86 decfsz wait_temp,1
|
|
87 goto WAIT10USX2
|
|
88 return
|
|
89 ; ==========================================================
|
|
90 ; WAIT 1 MILLISECOND - 16 MHZ
|
|
91 ; ==========================================================
|
|
92 WAITMS macro waitms_temp
|
|
93 movlw waitms_temp
|
|
94 IFNDEF DEBUG
|
|
95 call WAITMSX
|
|
96 ENDIF
|
|
97 endm
|
|
98 WAITMSX movwf waitms_temp
|
|
99 goto JumpInMSX
|
|
100 WAITMSX2 nop
|
|
101 nop
|
|
102 nop
|
|
103 nop
|
|
104 nop
|
|
105 nop
|
|
106 nop
|
|
107 nop
|
|
108 nop
|
|
109 JumpInMSX:
|
|
110 nop
|
|
111 nop
|
|
112 nop
|
|
113 nop
|
|
114 nop
|
|
115 nop
|
|
116 nop
|
|
117 nop
|
|
118 nop
|
|
119 nop
|
|
120 nop
|
|
121 nop
|
|
122 nop
|
|
123 nop
|
|
124 nop
|
|
125 nop
|
|
126 nop
|
|
127 nop
|
|
128 nop
|
|
129 nop
|
|
130 nop
|
|
131 nop
|
|
132 nop
|
|
133 nop
|
|
134 nop
|
|
135 nop
|
|
136 nop
|
|
137 nop
|
|
138 nop
|
|
139 WAIT10US d'99'
|
|
140 decfsz waitms_temp,1
|
|
141 goto WAITMSX2
|
|
142 return
|
|
143 ELSE
|
|
144 IFDEF Clk_8_MHZ
|
|
145 ; ==========================================================
|
|
146 ; WAIT 10 MICROSECONDS - 8 MHZ
|
|
147 ; ==========================================================
|
|
148 WAIT10US macro wait_temp
|
|
149 movlw wait_temp
|
|
150 IFNDEF DEBUG
|
|
151 call WAIT10USX
|
|
152 ENDIF
|
|
153 endm
|
|
154 WAIT10USX movwf wait_temp
|
|
155 goto JumpIn10us
|
|
156 WAIT10USX2 nop
|
|
157 nop
|
|
158 nop
|
|
159 nop
|
|
160 nop
|
|
161 nop
|
|
162 nop
|
|
163 JumpIn10us:
|
|
164 nop
|
|
165 nop
|
|
166 nop
|
|
167 nop
|
|
168 nop
|
|
169 nop
|
|
170 nop
|
|
171 nop
|
|
172 nop
|
|
173 nop
|
|
174 decfsz wait_temp,1
|
|
175 goto WAIT10USX2
|
|
176 return
|
|
177 ; ==========================================================
|
|
178 ; WAIT 1 MILLISECOND - 8 MHZ
|
|
179 ; ==========================================================
|
|
180 WAITMS macro waitms_temp
|
|
181 movlw waitms_temp
|
|
182 IFNDEF DEBUG
|
|
183 call WAITMSX
|
|
184 ENDIF
|
|
185 endm
|
|
186 WAITMSX movwf waitms_temp
|
|
187 goto JumpInMSX
|
|
188
|
|
189 WAITMSX2 nop
|
|
190 nop
|
|
191 nop
|
|
192 nop
|
|
193 nop
|
|
194 nop
|
|
195 nop
|
|
196 JumpInMSX:
|
|
197 nop
|
|
198 nop
|
|
199 nop
|
|
200 nop
|
|
201 nop
|
|
202 nop
|
|
203 nop
|
|
204 nop
|
|
205 nop
|
|
206 nop
|
|
207 WAIT10US d'99'
|
|
208 decfsz waitms_temp,1
|
|
209 goto WAITMSX2
|
|
210 return
|
|
211 ELSE
|
|
212 IFDEF Clk_4_MHZ
|
|
213 ; ==========================================================
|
|
214 ; WAIT 10 MICROSECONDS - 4 MHZ
|
|
215 ; ==========================================================
|
|
216 WAIT10US macro wait_temp
|
|
217 movlw wait_temp
|
|
218 IFNDEF DEBUG
|
|
219 call WAIT10USX
|
|
220 ENDIF
|
|
221 endm
|
|
222 WAIT10USX movwf wait_temp
|
|
223 goto JumpIn10us
|
|
224 WAIT10USX2 nop
|
|
225 nop
|
|
226 nop
|
|
227 nop
|
|
228 nop
|
|
229 nop
|
|
230 nop
|
|
231 JumpIn10us:
|
|
232 decfsz wait_temp,1
|
|
233 goto WAIT10USX2
|
|
234 return
|
|
235 ; ==========================================================
|
|
236 ; WAIT 1 MILLISECOND - 4 MHZ
|
|
237 ; ==========================================================
|
|
238 WAITMS macro waitms_temp
|
|
239 movlw waitms_temp
|
|
240 IFNDEF DEBUG
|
|
241 call WAITMSX
|
|
242 ENDIF
|
|
243 endm
|
|
244 WAITMSX movwf waitms_temp
|
|
245 goto JumpInMSX
|
|
246
|
|
247 WAITMSX2 nop
|
|
248 nop
|
|
249 nop
|
|
250 nop
|
|
251 nop
|
|
252 nop
|
|
253 nop
|
|
254 JumpInMSX:
|
|
255 WAIT10US d'99'
|
|
256 decfsz waitms_temp,1
|
|
257 goto WAITMSX2
|
|
258 return
|
|
259 ELSE
|
|
260 IFDEF Clk_20_MHZ
|
|
261 ==========================================================
|
|
262 ; WAIT 10 MICROSECONDS - 20 MHZ
|
|
263 ; ==========================================================
|
|
264 WAIT10US macro wait_temp
|
|
265 movlw wait_temp
|
|
266 IFNDEF DEBUG
|
|
267 call WAIT10USX
|
|
268 ENDIF
|
|
269 endm
|
|
270 WAIT10USX movwf wait_temp
|
|
271 goto JumpIn10us
|
|
272 WAIT10USX2 nop
|
|
273 nop
|
|
274 nop
|
|
275 nop
|
|
276 nop
|
|
277 nop
|
|
278 nop
|
|
279 JumpIn10us:
|
|
280 nop
|
|
281 nop
|
|
282 nop
|
|
283 nop
|
|
284 nop
|
|
285 nop
|
|
286 nop
|
|
287 nop
|
|
288 nop
|
|
289 nop
|
|
290 nop
|
|
291 nop
|
|
292 nop
|
|
293 nop
|
|
294 nop
|
|
295 nop
|
|
296 nop
|
|
297 nop
|
|
298 nop
|
|
299 nop
|
|
300 nop
|
|
301 nop
|
|
302 nop
|
|
303 nop
|
|
304 nop
|
|
305 nop
|
|
306 nop
|
|
307 nop
|
|
308 nop
|
|
309 nop
|
|
310 nop
|
|
311 nop
|
|
312 nop
|
|
313 nop
|
|
314 nop
|
|
315 nop
|
|
316 nop
|
|
317 nop
|
|
318 nop
|
|
319 nop
|
|
320 decfsz wait_temp,1
|
|
321 goto WAIT10USX2
|
|
322 return
|
|
323 ; ==========================================================
|
|
324 ; WAIT 1 MILLISECOND - 20 MHZ
|
|
325 ; ==========================================================
|
|
326 WAITMS macro waitms_temp
|
|
327 movlw waitms_temp
|
|
328 IFNDEF DEBUG
|
|
329 call WAITMSX
|
|
330 ENDIF
|
|
331 endm
|
|
332 WAITMSX movwf waitms_temp
|
|
333 goto JumpInMSX
|
|
334
|
|
335 WAITMSX2 nop
|
|
336 nop
|
|
337 nop
|
|
338 nop
|
|
339 nop
|
|
340 nop
|
|
341 nop
|
|
342 JumpInMSX:
|
|
343 nop
|
|
344 nop
|
|
345 nop
|
|
346 nop
|
|
347 nop
|
|
348 nop
|
|
349 nop
|
|
350 nop
|
|
351 nop
|
|
352 nop
|
|
353 nop
|
|
354 nop
|
|
355 nop
|
|
356 nop
|
|
357 nop
|
|
358 nop
|
|
359 nop
|
|
360 nop
|
|
361 nop
|
|
362 nop
|
|
363 nop
|
|
364 nop
|
|
365 nop
|
|
366 nop
|
|
367 nop
|
|
368 nop
|
|
369 nop
|
|
370 nop
|
|
371 nop
|
|
372 nop
|
|
373 nop
|
|
374 nop
|
|
375 nop
|
|
376 nop
|
|
377 nop
|
|
378 nop
|
|
379 nop
|
|
380 nop
|
|
381 nop
|
|
382 nop
|
|
383 WAIT10US d'99'
|
|
384 decfsz waitms_temp,1
|
|
385 goto WAITMSX2
|
|
386 return
|
|
387 ENDIF
|
|
388 ENDIF
|
|
389 ENDIF
|
|
390 ENDIF
|
|
391 ENDIF
|
|
392
|
|
393
|
|
394 wait_one_second:
|
|
395 WAITMS d'250'
|
|
396 WAITMS d'250'
|
|
397 WAITMS d'250'
|
|
398 WAITMS d'250'
|
|
399 return
|