0
|
1 ;=============================================================================
|
|
2 ;
|
604
|
3 ; File wait.asm V2.98c
|
0
|
4 ;
|
582
|
5 ; Wait routines
|
0
|
6 ;
|
|
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
8 ;=============================================================================
|
|
9 ; HISTORY
|
604
|
10 ; 2004-01-31 : [chsw] initial version
|
|
11 ; 2007-05-11 : updated (OSTC code)
|
|
12 ; 2011-10-18 : [mH] timings tested with oscilloscope
|
582
|
13
|
275
|
14 #include "hwos.inc"
|
0
|
15
|
604
|
16 wait CODE
|
|
17
|
|
18
|
|
19 ; ==========================================================
|
|
20 ; WAIT 1 second (Warning: Do not use for time critical routines. Can be between 0 and 1 sec!)
|
|
21 ; ==========================================================
|
|
22 global wait_1s
|
|
23 wait_1s:
|
|
24 ; Wait until "next second" flag is set
|
|
25 bcf onesecupdate
|
|
26 btfss onesecupdate
|
|
27 bra $-2
|
|
28 return
|
|
29
|
0
|
30
|
582
|
31 ; =============================================================================
|
|
32 ; WAIT 1 MILLISECOND (Not exact: 1,008ms +/- 30,5µs + worst case ISR latency)
|
|
33 ; =============================================================================
|
0
|
34
|
582
|
35 global WAITMSX
|
|
36 WAITMSX:
|
|
37 movwf wait_counter
|
|
38 WAITMSX2:
|
|
39 setf TMR5H
|
604
|
40 movlw .255-.32 ; 32 x 31,5µs = 1,008ms
|
582
|
41 movwf TMR5L
|
604
|
42 bcf PIR5,TMR5IF ; clear flag
|
582
|
43 WAITMSX3:
|
|
44 btfss PIR5,TMR5IF
|
604
|
45 bra WAITMSX3 ; wait loop
|
582
|
46 decfsz wait_counter,F
|
|
47 bra WAITMSX2
|
|
48 return
|
0
|
49
|
|
50 ;=============================================================================
|
|
51
|
582
|
52 END |