0
|
1 ;=============================================================================
|
|
2 ;
|
623
|
3 ; File wait.asm combined next generation V3.02.1
|
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
|
623
|
16 wait CODE
|
604
|
17
|
0
|
18
|
582
|
19 ; =============================================================================
|
623
|
20 ; WAIT 1 second
|
|
21 ; Warning: Do not use for time critical routines - can be between 0 and 1 sec!
|
|
22 ; =============================================================================
|
|
23
|
|
24 global wait_1s
|
|
25 wait_1s:
|
|
26 bcf trigger_full_second ; clear any left-over trigger
|
|
27 btfss trigger_full_second ; did a new trigger occurred?
|
|
28 bra $-2 ; NO - loop
|
|
29 return ; YES - done
|
|
30
|
|
31
|
|
32 ; =============================================================================
|
|
33 ; WAIT for multiples of 1 Millisecond
|
|
34 ; Remark: not exact: 1.008 ms +/- 30.5 µs + worst case ISR latency
|
582
|
35 ; =============================================================================
|
0
|
36
|
582
|
37 global WAITMSX
|
|
38 WAITMSX:
|
623
|
39 movwf wait_counter ; store number of milliseconds to wait
|
582
|
40 WAITMSX2:
|
623
|
41 setf TMR5H ; initialize timer 5, high byte first
|
|
42 movlw .255-.32 ; 32 x 31.5 µs = 1.008 ms
|
|
43 movwf TMR5L ; initialize timer 5, low byte thereafter
|
|
44 bcf PIR5,TMR5IF ; clear timer 5 overrun flag
|
582
|
45 WAITMSX3:
|
623
|
46 btfss PIR5,TMR5IF ; did timer 5 overrun?
|
|
47 bra WAITMSX3 ; NO - repeat inner loop
|
|
48 decfsz wait_counter,F ; YES - decrement number of milliseconds to do, done?
|
|
49 bra WAITMSX2 ; NO - repeat outer loop
|
|
50 return ; YES - done
|
0
|
51
|
|
52 ;=============================================================================
|
|
53
|
582
|
54 END |