annotate src/wait.asm @ 645:070528a88715

3.16 release
author heinrichsweikamp
date Sun, 07 Nov 2021 12:39:23 +0100
parents 4050675965ea
children 75e90cd0c2c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
3 ; File wait.asm * combined next generation V3.09.4
0
heinrichsweikamp
parents:
diff changeset
4 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
5 ; Wait routines
0
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
10 ; 2004-01-31 : [chsw] initial version
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
11 ; 2007-05-11 : updated (OSTC code)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
12 ; 2011-10-18 : [mH] timings tested with oscilloscope
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
13
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 0
diff changeset
14 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
15
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
16
0
heinrichsweikamp
parents:
diff changeset
17
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
18 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
19 wait1 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
20 ;=============================================================================
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
21
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
22 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
23 ; Wait 1 Second
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
24 ; Warning: do not use for time critical routines - can be between 0 and 1 sec!
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
25 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
26 global wait_1s
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
27 wait_1s:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
28 bcf trigger_full_second ; clear any left-over trigger
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
29 btfss trigger_full_second ; did a new trigger occurred?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
30 bra $-2 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
31 return ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
32
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
33
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
34 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
35 wait2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
36 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
37
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
38 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
39 ; Wait for a Multiple of 1 Second
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
40 ; Warning: do not use for time critical routines - can be up to 1 sec longer!
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
41 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
42 global WAITSX
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
43 WAITSX:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
44 bcf trigger_full_second ; clear any left-over trigger
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
45 btfss trigger_full_second ; did a new trigger occurred?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
46 bra $-2 ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
47 decfsz WREG,W ; YES - count down loop counter, became zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
48 bra WAITSX ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
49 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
50
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
51
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
52 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
53 wait3 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
54 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
55
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
56 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
57 ; Wait for a Multiple of 1 Millisecond
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
58 ; Remark: not exact: 1.008 ms +/- 30.5 µs + worst case ISR latency
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
59 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
60 global WAITMSX
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
61 WAITMSX:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
62 movwf wait_counter ; store number of milliseconds to wait
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
63 WAITMSX2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
64 setf TMR5H ; initialize timer 5, high byte first
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
65 movlw .255-.32 ; 32 x 31.5 µs = 1.008 ms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
66 movwf TMR5L ; initialize timer 5, low byte thereafter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
67 bcf PIR5,TMR5IF ; clear timer 5 overrun flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
68 WAITMSX3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
69 btfss PIR5,TMR5IF ; did timer 5 overrun?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
70 bra WAITMSX3 ; NO - repeat inner loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
71 decfsz wait_counter,F ; YES - decrement number of milliseconds to do, done?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
72 bra WAITMSX2 ; NO - repeat outer loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
73 return ; YES - done
0
heinrichsweikamp
parents:
diff changeset
74
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 623
diff changeset
75 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
76
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 275
diff changeset
77 END