annotate src/isr.asm @ 571:1a7957306d49

French updates
author heinrichsweikamp
date Sun, 11 Feb 2018 12:20:59 +0100
parents c8ea60294175
children b455b31ce022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
3 ; File isr.asm REFACTORED VERSION V2.92
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; INTERUPT subroutines
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
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code.
heinrichsweikamp
parents:
diff changeset
11
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 271
diff changeset
12 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
14 #include "ms5541.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "adc_lightsensor.inc"
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
16 #include "eeprom_rs232.inc"
0
heinrichsweikamp
parents:
diff changeset
17
heinrichsweikamp
parents:
diff changeset
18 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
19
heinrichsweikamp
parents:
diff changeset
20 extern start
heinrichsweikamp
parents:
diff changeset
21
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
22 isr_high CODE 0x0008 ; High Priority Interrups
0
heinrichsweikamp
parents:
diff changeset
23 bra HighInt
heinrichsweikamp
parents:
diff changeset
24 nop
heinrichsweikamp
parents:
diff changeset
25 nop
heinrichsweikamp
parents:
diff changeset
26 nop
heinrichsweikamp
parents:
diff changeset
27 nop
heinrichsweikamp
parents:
diff changeset
28 nop
heinrichsweikamp
parents:
diff changeset
29 nop
heinrichsweikamp
parents:
diff changeset
30 bra HighInt
heinrichsweikamp
parents:
diff changeset
31
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
32 isr_low CODE 0x00018 ; Low Priority Interrups
0
heinrichsweikamp
parents:
diff changeset
33 ; *** low priority interrupts not used
heinrichsweikamp
parents:
diff changeset
34 retfie FAST ; Restores BSR, STATUS and WREG
heinrichsweikamp
parents:
diff changeset
35
heinrichsweikamp
parents:
diff changeset
36 HighInt:
heinrichsweikamp
parents:
diff changeset
37 movff PRODL,isr_prod+0
heinrichsweikamp
parents:
diff changeset
38 movff PRODH,isr_prod+1
heinrichsweikamp
parents:
diff changeset
39
heinrichsweikamp
parents:
diff changeset
40 ; Buttons
heinrichsweikamp
parents:
diff changeset
41 btfsc PIR1,TMR1IF ; Timer1 INT (Button hold-down Timer)
heinrichsweikamp
parents:
diff changeset
42 rcall timer1int
heinrichsweikamp
parents:
diff changeset
43 btfsc INTCON,INT0IF ; Buttons
heinrichsweikamp
parents:
diff changeset
44 rcall isr_switch_right
heinrichsweikamp
parents:
diff changeset
45 btfsc INTCON3,INT1IF ; Buttons
heinrichsweikamp
parents:
diff changeset
46 rcall isr_switch_left
heinrichsweikamp
parents:
diff changeset
47
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
48 ; IR/S8-Linktimer1int
113
heinrichsweikamp
parents: 50
diff changeset
49 btfsc PIR3,RC2IF ; UART2
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
50 rcall isr_uart2 ; IR/S8-Link
0
heinrichsweikamp
parents:
diff changeset
51 btfsc PIR2,TMR3IF ; Timer 3
heinrichsweikamp
parents:
diff changeset
52 rcall isr_timer3 ; IR-Link Timeout
113
heinrichsweikamp
parents: 50
diff changeset
53
heinrichsweikamp
parents: 50
diff changeset
54 ; Pressure sensor and others
heinrichsweikamp
parents: 50
diff changeset
55 btfsc PIR5,TMR7IF ; Timer 7
heinrichsweikamp
parents: 50
diff changeset
56 rcall isr_tmr7 ; Every 62,5ms
heinrichsweikamp
parents: 50
diff changeset
57
0
heinrichsweikamp
parents:
diff changeset
58 ; RTCC
heinrichsweikamp
parents:
diff changeset
59 btfsc PIR3,RTCCIF ; Real-time-clock interrupt
heinrichsweikamp
parents:
diff changeset
60 rcall isr_rtcc ; May return in bank common!
heinrichsweikamp
parents:
diff changeset
61
heinrichsweikamp
parents:
diff changeset
62 movff isr_prod+1,PRODH
heinrichsweikamp
parents:
diff changeset
63 movff isr_prod+0,PRODL
heinrichsweikamp
parents:
diff changeset
64 retfie FAST ; Restores BSR, STATUS and WREG
heinrichsweikamp
parents:
diff changeset
65
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
66 isr_set_speed_to_normal:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
67 ; Set Speed to normal
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
68 movlw b'01110010'
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
69 movwf OSCCON ; 16MHz INTOSC
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
70 movlw b'00000000'
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
71 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
72 movlw b'00001101' ; 1:2 Postscaler, 1:4 Prescaler, Timer 2 start -> 1960Hz (no-flicker)
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
73 movwf T2CON
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
74 btfss OSCCON,HFIOFS
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
75 bra $-2 ; Wait until clock is stable
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
76 return
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
77
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
78 isr_dimm_tft: ; Adjust until max_CCPR1L=CCPR1L !
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
79 banksel common
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
80 btfsc tft_is_dimming ; Ignore while dimming
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
81 return
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
82 banksel isr_backup
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
83 movf max_CCPR1L,W
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
84 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L?
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
85 bra isr_dimm_tft2 ; No, dimm up
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
86 ; dimm down
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
87 decf CCPR1L,F ; -1
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
88 return
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
89 isr_dimm_tft2:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
90 movf max_CCPR1L,W
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
91 sublw ambient_light_min_eco
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
92 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L-ambient_light_min_eco?
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
93 bra isr_dimm_tft3 ; No, dimm up slow
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
94 ; dimm up faster
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
95 movlw .10
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
96 addwf CCPR1L,F
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
97 isr_dimm_tft3:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
98 incf CCPR1L,F ; +1
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
99 return
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
100 nop
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
101 nop ; block flash here
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
102
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
103 isr_restore CODE 0x00080 ; Restore first flash page from EEPROM
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
104 restore_flash_0x00080:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
105 goto restore_flash
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
106
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
107 isr_routines; CODE
0
heinrichsweikamp
parents:
diff changeset
108 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
109
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
110 isr_uart2: ; IR/S8-Link
0
heinrichsweikamp
parents:
diff changeset
111 banksel RCREG2
heinrichsweikamp
parents:
diff changeset
112 movf RCREG2,W
heinrichsweikamp
parents:
diff changeset
113 bcf RCSTA2,CREN ; Clear receiver status
heinrichsweikamp
parents:
diff changeset
114 bsf RCSTA2,CREN
heinrichsweikamp
parents:
diff changeset
115 banksel isr_backup
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
116 incf ir_s8_counter,F ; Increase counter
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
117 movff ir_s8_counter,isr1_temp ; Copy
0
heinrichsweikamp
parents:
diff changeset
118 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
119 movwf ir_s8_buffer+.0
0
heinrichsweikamp
parents:
diff changeset
120 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
121 movwf ir_s8_buffer+.1
0
heinrichsweikamp
parents:
diff changeset
122 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
123 movwf ir_s8_buffer+.2
0
heinrichsweikamp
parents:
diff changeset
124 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
125 movwf ir_s8_buffer+.3
0
heinrichsweikamp
parents:
diff changeset
126 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
127 movwf ir_s8_buffer+.4
0
heinrichsweikamp
parents:
diff changeset
128 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
129 movwf ir_s8_buffer+.5
0
heinrichsweikamp
parents:
diff changeset
130 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
131 movwf ir_s8_buffer+.6
0
heinrichsweikamp
parents:
diff changeset
132 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
133 movwf ir_s8_buffer+.7
0
heinrichsweikamp
parents:
diff changeset
134 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
135 movwf ir_s8_buffer+.8
0
heinrichsweikamp
parents:
diff changeset
136 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
137 movwf ir_s8_buffer+.9
0
heinrichsweikamp
parents:
diff changeset
138 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
139 movwf ir_s8_buffer+.10
0
heinrichsweikamp
parents:
diff changeset
140 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
141 movwf ir_s8_buffer+.11
0
heinrichsweikamp
parents:
diff changeset
142 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
143 movwf ir_s8_buffer+.12
0
heinrichsweikamp
parents:
diff changeset
144 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
145 movwf ir_s8_buffer+.13
0
heinrichsweikamp
parents:
diff changeset
146 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
147 movwf ir_s8_buffer+.14
0
heinrichsweikamp
parents:
diff changeset
148 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
149 movwf ir_s8_buffer+.15
113
heinrichsweikamp
parents: 50
diff changeset
150 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
151 movwf ir_s8_buffer+.16
113
heinrichsweikamp
parents: 50
diff changeset
152 dcfsnz isr1_temp,F
204
heinrichsweikamp
parents: 200
diff changeset
153 movwf ir_s8_buffer+.17
113
heinrichsweikamp
parents: 50
diff changeset
154
0
heinrichsweikamp
parents:
diff changeset
155 clrf TMR3L ; Preload timer
heinrichsweikamp
parents:
diff changeset
156 movlw .253
heinrichsweikamp
parents:
diff changeset
157 movwf TMR3H
heinrichsweikamp
parents:
diff changeset
158 bsf T3CON,TMR3ON ; (Re)Start Timeout counter
heinrichsweikamp
parents:
diff changeset
159 return
heinrichsweikamp
parents:
diff changeset
160
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
161 isr_timer3: ; IR/S8-Link Timeout
0
heinrichsweikamp
parents:
diff changeset
162 bcf T3CON,TMR3ON ; Stop Timer3
heinrichsweikamp
parents:
diff changeset
163 banksel isr_backup ; Select Bank0 for ISR data.
heinrichsweikamp
parents:
diff changeset
164 movlw .15
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
165 cpfseq ir_s8_counter ; Got exact 15bytes?
0
heinrichsweikamp
parents:
diff changeset
166 bra isr_timer3_1 ; No, test for 16bytes
113
heinrichsweikamp
parents: 50
diff changeset
167 bra isr_timer3_ir ; Got 15 bytes, compute local checksum
0
heinrichsweikamp
parents:
diff changeset
168 isr_timer3_1:
heinrichsweikamp
parents:
diff changeset
169 movlw .16
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
170 cpfseq ir_s8_counter ; Got exact 16bytes?
113
heinrichsweikamp
parents: 50
diff changeset
171 bra isr_timer3_2 ; No, test for 17bytes
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
172 tstfsz ir_s8_buffer+.15 ; Last byte=0x00
0
heinrichsweikamp
parents:
diff changeset
173 bra isr_timer3_exit ; No, exit
113
heinrichsweikamp
parents: 50
diff changeset
174 bra isr_timer3_ir ; Got 16 bytes, compute local checksum
heinrichsweikamp
parents: 50
diff changeset
175 isr_timer3_2:
heinrichsweikamp
parents: 50
diff changeset
176 movlw .17
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
177 cpfseq ir_s8_counter ; Got exact 17bytes?
113
heinrichsweikamp
parents: 50
diff changeset
178 bra isr_timer3_exit ; No, exit
heinrichsweikamp
parents: 50
diff changeset
179 bra isr_timer3_s8 ; S8 data
0
heinrichsweikamp
parents:
diff changeset
180
113
heinrichsweikamp
parents: 50
diff changeset
181 isr_timer3_ir: ; IR input
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
182 movff ir_s8_buffer+.0,PRODL
0
heinrichsweikamp
parents:
diff changeset
183 clrf PRODH
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
184 movf ir_s8_buffer+.1,W
0
heinrichsweikamp
parents:
diff changeset
185 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
186 movf ir_s8_buffer+.2,W
0
heinrichsweikamp
parents:
diff changeset
187 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
188 movf ir_s8_buffer+.3,W
0
heinrichsweikamp
parents:
diff changeset
189 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
190 movf ir_s8_buffer+.4,W
0
heinrichsweikamp
parents:
diff changeset
191 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
192 movf ir_s8_buffer+.5,W
0
heinrichsweikamp
parents:
diff changeset
193 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
194 movf ir_s8_buffer+.6,W
0
heinrichsweikamp
parents:
diff changeset
195 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
196 movf ir_s8_buffer+.7,W
0
heinrichsweikamp
parents:
diff changeset
197 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
198 movf ir_s8_buffer+.8,W
0
heinrichsweikamp
parents:
diff changeset
199 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
200 movf ir_s8_buffer+.9,W
0
heinrichsweikamp
parents:
diff changeset
201 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
202 movf ir_s8_buffer+.10,W
0
heinrichsweikamp
parents:
diff changeset
203 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
204 movf ir_s8_buffer+.11,W
0
heinrichsweikamp
parents:
diff changeset
205 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
206 movf ir_s8_buffer+.12,W
0
heinrichsweikamp
parents:
diff changeset
207 rcall isr_timer3_checksum
heinrichsweikamp
parents:
diff changeset
208
heinrichsweikamp
parents:
diff changeset
209 ; Compare checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
210 movf ir_s8_buffer+.13,W
0
heinrichsweikamp
parents:
diff changeset
211 cpfseq PRODL ; Checksum ok?
heinrichsweikamp
parents:
diff changeset
212 bra isr_timer3_exit ; No, exit
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
213 movf ir_s8_buffer+.14,W
0
heinrichsweikamp
parents:
diff changeset
214 cpfseq PRODH ; Checksum ok?
heinrichsweikamp
parents:
diff changeset
215 bra isr_timer3_exit ; No, exit
heinrichsweikamp
parents:
diff changeset
216
heinrichsweikamp
parents:
diff changeset
217 ; Checksum OK, copy results
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
218 movff ir_s8_buffer+.1,hud_status_byte
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
219 movff ir_s8_buffer+.2,o2_mv_sensor1+0
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
220 movff ir_s8_buffer+.3,o2_mv_sensor1+1
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
221 movff ir_s8_buffer+.4,o2_mv_sensor2+0
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
222 movff ir_s8_buffer+.5,o2_mv_sensor2+1
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
223 movff ir_s8_buffer+.6,o2_mv_sensor3+0
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
224 movff ir_s8_buffer+.7,o2_mv_sensor3+1
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
225 movff ir_s8_buffer+.8,o2_ppo2_sensor1
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
226 movff ir_s8_buffer+.9,o2_ppo2_sensor2
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
227 movff ir_s8_buffer+.10,o2_ppo2_sensor3
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
228 movff ir_s8_buffer+.11,hud_battery_mv+0
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
229 movff ir_s8_buffer+.12,hud_battery_mv+1
0
heinrichsweikamp
parents:
diff changeset
230
heinrichsweikamp
parents:
diff changeset
231 movlw ir_timeout_value ; multiples of 62,5ms
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
232 movwf ir_S8_timeout ; Reload timeout
227
03946aa48fa5 NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents: 204
diff changeset
233
03946aa48fa5 NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents: 204
diff changeset
234 banksel hud_status_byte
03946aa48fa5 NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents: 204
diff changeset
235 bsf hud_connection_ok ; Set manually for hwHUD w/o the HUD module...
03946aa48fa5 NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents: 204
diff changeset
236 banksel isr_backup ; Select Bank0 for ISR data.
0
heinrichsweikamp
parents:
diff changeset
237
heinrichsweikamp
parents:
diff changeset
238 isr_timer3_exit:
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
239 clrf ir_s8_counter ; Clear pointer
0
heinrichsweikamp
parents:
diff changeset
240 bcf PIR2,TMR3IF ; Clear flag
heinrichsweikamp
parents:
diff changeset
241 return
heinrichsweikamp
parents:
diff changeset
242
heinrichsweikamp
parents:
diff changeset
243 isr_timer3_checksum:
heinrichsweikamp
parents:
diff changeset
244 addwf PRODL,F
heinrichsweikamp
parents:
diff changeset
245 movlw .0
heinrichsweikamp
parents:
diff changeset
246 addwfc PRODH,F
heinrichsweikamp
parents:
diff changeset
247 return
heinrichsweikamp
parents:
diff changeset
248
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
249 isr_timer3_s8: ; S8 input
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
250 movff ir_s8_buffer+.0,PRODL
113
heinrichsweikamp
parents: 50
diff changeset
251 clrf PRODH
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
252 movf ir_s8_buffer+.1,W
113
heinrichsweikamp
parents: 50
diff changeset
253 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
254 movf ir_s8_buffer+.2,W
113
heinrichsweikamp
parents: 50
diff changeset
255 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
256 movf ir_s8_buffer+.3,W
113
heinrichsweikamp
parents: 50
diff changeset
257 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
258 movf ir_s8_buffer+.4,W
113
heinrichsweikamp
parents: 50
diff changeset
259 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
260 movf ir_s8_buffer+.5,W
113
heinrichsweikamp
parents: 50
diff changeset
261 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
262 movf ir_s8_buffer+.6,W
113
heinrichsweikamp
parents: 50
diff changeset
263 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
264 movf ir_s8_buffer+.7,W
113
heinrichsweikamp
parents: 50
diff changeset
265 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
266 movf ir_s8_buffer+.8,W
113
heinrichsweikamp
parents: 50
diff changeset
267 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
268 movf ir_s8_buffer+.9,W
113
heinrichsweikamp
parents: 50
diff changeset
269 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
270 movf ir_s8_buffer+.10,W
113
heinrichsweikamp
parents: 50
diff changeset
271 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
272 movf ir_s8_buffer+.11,W
113
heinrichsweikamp
parents: 50
diff changeset
273 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
274 movf ir_s8_buffer+.12,W
113
heinrichsweikamp
parents: 50
diff changeset
275 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
276 movf ir_s8_buffer+.13,W
113
heinrichsweikamp
parents: 50
diff changeset
277 rcall isr_timer3_checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
278 movf ir_s8_buffer+.14,W
113
heinrichsweikamp
parents: 50
diff changeset
279 rcall isr_timer3_checksum
heinrichsweikamp
parents: 50
diff changeset
280
heinrichsweikamp
parents: 50
diff changeset
281 ; Compare checksum
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
282 movf ir_s8_buffer+.15,W
113
heinrichsweikamp
parents: 50
diff changeset
283 cpfseq PRODL ; Checksum ok?
heinrichsweikamp
parents: 50
diff changeset
284 bra isr_timer3_exit ; No, exit
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
285 movf ir_s8_buffer+.16,W
113
heinrichsweikamp
parents: 50
diff changeset
286 cpfseq PRODH ; Checksum ok?
heinrichsweikamp
parents: 50
diff changeset
287 bra isr_timer3_exit ; No, exit
heinrichsweikamp
parents: 50
diff changeset
288
heinrichsweikamp
parents: 50
diff changeset
289 ; Checksum OK, copy results
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
290 movff ir_s8_buffer+.3,hud_status_byte
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
291 movff ir_s8_buffer+.13,hud_battery_mv+0
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
292 movff ir_s8_buffer+.14,hud_battery_mv+1
113
heinrichsweikamp
parents: 50
diff changeset
293
heinrichsweikamp
parents: 50
diff changeset
294 banksel common
271
d316d44530a3 Update digital ppO2 data automatically
heinrichsweikamp
parents: 268
diff changeset
295 btfsc new_s8_data_available ; =1: Old data already processed?
268
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
296 bra isr_timer3_skip ; No, skip copying new results
113
heinrichsweikamp
parents: 50
diff changeset
297
268
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
298 movff ir_s8_buffer+.6,s8_rawdata_sensor1+2
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
299 movff ir_s8_buffer+.5,s8_rawdata_sensor1+1
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
300 movff ir_s8_buffer+.4,s8_rawdata_sensor1+0
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
301 movff ir_s8_buffer+.9,s8_rawdata_sensor2+2
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
302 movff ir_s8_buffer+.8,s8_rawdata_sensor2+1
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
303 movff ir_s8_buffer+.7,s8_rawdata_sensor2+0
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
304 movff ir_s8_buffer+.12,s8_rawdata_sensor3+2
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
305 movff ir_s8_buffer+.11,s8_rawdata_sensor3+1
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
306 movff ir_s8_buffer+.10,s8_rawdata_sensor3+0
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
307 banksel common
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
308 bsf new_s8_data_available ; set flag
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
309
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
310 isr_timer3_skip:
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
311 banksel ir_S8_timeout
113
heinrichsweikamp
parents: 50
diff changeset
312 movlw ir_timeout_value ; multiples of 62,5ms
268
29acdb601548 BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents: 236
diff changeset
313 movwf ir_S8_timeout ; Reload timeout
113
heinrichsweikamp
parents: 50
diff changeset
314 bra isr_timer3_exit ; Exit
heinrichsweikamp
parents: 50
diff changeset
315
heinrichsweikamp
parents: 50
diff changeset
316
0
heinrichsweikamp
parents:
diff changeset
317 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
318
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
319 isr_tmr7: ; each 62,5ms
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
320 bcf PIR5,TMR7IF ; clear flag
469
heinrichsweikamp
parents: 453
diff changeset
321 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
heinrichsweikamp
parents: 453
diff changeset
322 movlw .248
0
heinrichsweikamp
parents:
diff changeset
323 movwf TMR7H ; -> Rollover after 2048 cycles -> 62,5ms
heinrichsweikamp
parents:
diff changeset
324
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
325 banksel common
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
326 call get_analog_switches ; Get analog readings
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
327 btfss INTCON3,INT1IE
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
328 bra isr_tmr7_a
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
329 btfsc analog_sw2_pressed
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
330 rcall isr_switch_left
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
331 isr_tmr7_a:
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
332 banksel common
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
333 btfss INTCON,INT0IE
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
334 bra isr_tmr7_b
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
335 btfsc analog_sw1_pressed
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
336 rcall isr_switch_right
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
337 isr_tmr7_b:
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
338 banksel common
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
339 btfss no_sensor_int ; No sensor interrupt (because it's addressed during sleep)
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
340 bra isr_tmr7_c ; No, continue
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
341 banksel isr_backup ; Back to Bank0 ISR data
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
342 return
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
343 isr_tmr7_c:
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
344 banksel isr_backup
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
345 movf max_CCPR1L,W ; Dimm value
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
346 cpfseq CCPR1L ; = current PWM value?
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 469
diff changeset
347 rcall isr_dimm_tft ; No, adjust until max_CCPR1L=CCPR1L !
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 410
diff changeset
348
0
heinrichsweikamp
parents:
diff changeset
349 banksel isr_backup
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
350 decfsz ir_S8_timeout,F ; IR Data still valid?
0
heinrichsweikamp
parents:
diff changeset
351 bra isr_tmr7_2 ; Yes, continue
heinrichsweikamp
parents:
diff changeset
352 ; timeout, clear IR-Data
heinrichsweikamp
parents:
diff changeset
353
heinrichsweikamp
parents:
diff changeset
354 movlw ir_timeout_value ; multiples of 62,5ms
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 178
diff changeset
355 movwf ir_S8_timeout ; Reload timeout
0
heinrichsweikamp
parents:
diff changeset
356
heinrichsweikamp
parents:
diff changeset
357 banksel common
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
358 btfss analog_o2_input
113
heinrichsweikamp
parents: 50
diff changeset
359 bra isr_tmr7_1a ; Always with normal ostc3 hardware
heinrichsweikamp
parents: 50
diff changeset
360 btfss s8_digital
heinrichsweikamp
parents: 50
diff changeset
361 bra isr_tmr7_2 ; only when digital
heinrichsweikamp
parents: 50
diff changeset
362 isr_tmr7_1a:
565
0ba88db66492 CHANGE: Limit button sensitivity to 80%
heinrichsweikamp
parents: 560
diff changeset
363 clrf o2_mv_sensor1+0 ; S8/IR timeout clears all analog input readings to zero -> Fallback will be triggered when sensor mode was used
0
heinrichsweikamp
parents:
diff changeset
364 clrf o2_mv_sensor1+1
heinrichsweikamp
parents:
diff changeset
365 clrf o2_mv_sensor2+0
heinrichsweikamp
parents:
diff changeset
366 clrf o2_mv_sensor2+1
heinrichsweikamp
parents:
diff changeset
367 clrf o2_mv_sensor3+0
heinrichsweikamp
parents:
diff changeset
368 clrf o2_mv_sensor3+1
378
7faa688db105 BUGFIX: BLE timings for MAC issues
heinrichsweikamp
parents: 357
diff changeset
369 banksel hud_battery_mv
0
heinrichsweikamp
parents:
diff changeset
370 clrf hud_battery_mv+0
heinrichsweikamp
parents:
diff changeset
371 clrf hud_battery_mv+1
378
7faa688db105 BUGFIX: BLE timings for MAC issues
heinrichsweikamp
parents: 357
diff changeset
372 banksel hud_status_byte
0
heinrichsweikamp
parents:
diff changeset
373 clrf hud_status_byte
565
0ba88db66492 CHANGE: Limit button sensitivity to 80%
heinrichsweikamp
parents: 560
diff changeset
374 clrf o2_ppo2_sensor1 ; For IR/S8 HUD
0
heinrichsweikamp
parents:
diff changeset
375 clrf o2_ppo2_sensor2
heinrichsweikamp
parents:
diff changeset
376 clrf o2_ppo2_sensor3
570
c8ea60294175 react to external S8 HUD disconnect or failure in surface mode
heinrichsweikamp
parents: 565
diff changeset
377 banksel common
c8ea60294175 react to external S8 HUD disconnect or failure in surface mode
heinrichsweikamp
parents: 565
diff changeset
378 bsf new_s8_data_available ; set flag to update in surface mode
c8ea60294175 react to external S8 HUD disconnect or failure in surface mode
heinrichsweikamp
parents: 565
diff changeset
379
0
heinrichsweikamp
parents:
diff changeset
380 isr_tmr7_2:
heinrichsweikamp
parents:
diff changeset
381 banksel common
heinrichsweikamp
parents:
diff changeset
382 btfss no_sensor_int ; No sensor interrupt (because it's addressed during sleep)
heinrichsweikamp
parents:
diff changeset
383 bra isr_sensor_state2 ; No, continue
heinrichsweikamp
parents:
diff changeset
384 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
385 return
heinrichsweikamp
parents:
diff changeset
386
heinrichsweikamp
parents:
diff changeset
387 isr_sensor_state2:
heinrichsweikamp
parents:
diff changeset
388 banksel common
heinrichsweikamp
parents:
diff changeset
389 movff sensor_state_counter,WREG
heinrichsweikamp
parents:
diff changeset
390 btfss WREG,0 ; every 1/4 second
heinrichsweikamp
parents:
diff changeset
391 bsf quarter_second_update ; Set flag
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 275
diff changeset
392 banksel isr_backup ; Back to Bank0 ISR data
0
heinrichsweikamp
parents:
diff changeset
393 movlw d'2'
heinrichsweikamp
parents:
diff changeset
394 cpfseq speed_setting ; Set to normal in case it's not already in normal speed mode
heinrichsweikamp
parents:
diff changeset
395 rcall isr_set_speed_to_normal
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 275
diff changeset
396
0
heinrichsweikamp
parents:
diff changeset
397 incf sensor_state_counter,F ; counts to eight for state maschine
heinrichsweikamp
parents:
diff changeset
398
heinrichsweikamp
parents:
diff changeset
399 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us)
heinrichsweikamp
parents:
diff changeset
400 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
heinrichsweikamp
parents:
diff changeset
401 ; State 3: Get temperature (51us) and start pressure integration (73,5us)
heinrichsweikamp
parents:
diff changeset
402 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
heinrichsweikamp
parents:
diff changeset
403 ; State 5: Get temperature (51us) and start pressure integration (73,5us)
heinrichsweikamp
parents:
diff changeset
404 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
heinrichsweikamp
parents:
diff changeset
405 ; State 7: Get temperature (51us) and start pressure integration (73,5us)
heinrichsweikamp
parents:
diff changeset
406 ; State 8: Get pressure (51us), start temperature integration (73,5us), calculate temperature compensated pressure (233us) and build average for half-second update of tempperature and pressure
heinrichsweikamp
parents:
diff changeset
407
heinrichsweikamp
parents:
diff changeset
408 movff sensor_state_counter,WREG ; WREG used as temp here...
heinrichsweikamp
parents:
diff changeset
409 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
410 bra sensor_int_state1_plus_restart ; Do State 1
heinrichsweikamp
parents:
diff changeset
411 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
412 bra sensor_int_state2 ; Do State 2
heinrichsweikamp
parents:
diff changeset
413 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
414 bra sensor_int_state1 ; Do State 3
heinrichsweikamp
parents:
diff changeset
415 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
416 bra sensor_int_state2 ; Do State 4
heinrichsweikamp
parents:
diff changeset
417 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
418 bra sensor_int_state1 ; Do State 5
heinrichsweikamp
parents:
diff changeset
419 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
420 bra sensor_int_state2 ; Do State 6
heinrichsweikamp
parents:
diff changeset
421 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
422 bra sensor_int_state1 ; Do State 7
heinrichsweikamp
parents:
diff changeset
423 ; bra sensor_int2_plus_average ; Do State 8
heinrichsweikamp
parents:
diff changeset
424 ;sensor_int2_plus_average:
heinrichsweikamp
parents:
diff changeset
425 ; First, do state2:
heinrichsweikamp
parents:
diff changeset
426 call get_pressure_value ; State2: Get pressure (51us)
heinrichsweikamp
parents:
diff changeset
427 call get_temperature_start ; and start temperature integration (73,5us)
heinrichsweikamp
parents:
diff changeset
428 call calculate_compensation ; calculate temperature compensated pressure (27us)
heinrichsweikamp
parents:
diff changeset
429 ; Build average
heinrichsweikamp
parents:
diff changeset
430 bcf STATUS,C ; clear carry bit.
heinrichsweikamp
parents:
diff changeset
431 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2
heinrichsweikamp
parents:
diff changeset
432 rrcf amb_pressure_avg+0
heinrichsweikamp
parents:
diff changeset
433 bcf STATUS,C ; clear carry bit, twice.
heinrichsweikamp
parents:
diff changeset
434 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4
heinrichsweikamp
parents:
diff changeset
435 rrcf amb_pressure_avg+0
heinrichsweikamp
parents:
diff changeset
436
heinrichsweikamp
parents:
diff changeset
437 movff amb_pressure_avg+1,amb_pressure+1 ; copy into actual register
heinrichsweikamp
parents:
diff changeset
438 movff amb_pressure_avg+0,amb_pressure+0
heinrichsweikamp
parents:
diff changeset
439
heinrichsweikamp
parents:
diff changeset
440 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
441 btfsc temperature_avg+1,7 ; Copy sign bit to carry
heinrichsweikamp
parents:
diff changeset
442 bsf STATUS,C
heinrichsweikamp
parents:
diff changeset
443 rrcf temperature_avg+1 ; Signed temperature /2
heinrichsweikamp
parents:
diff changeset
444 rrcf temperature_avg+0
heinrichsweikamp
parents:
diff changeset
445 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
446 btfsc temperature_avg+1,7 ; Copy sign bit to carry
heinrichsweikamp
parents:
diff changeset
447 bsf STATUS,C
heinrichsweikamp
parents:
diff changeset
448 rrcf temperature_avg+1 ; Signed temperature /4
heinrichsweikamp
parents:
diff changeset
449 rrcf temperature_avg+0
heinrichsweikamp
parents:
diff changeset
450
heinrichsweikamp
parents:
diff changeset
451 movff temperature_avg+1,temperature+1 ; copy into actual register
heinrichsweikamp
parents:
diff changeset
452 movff temperature_avg+0,temperature+0
heinrichsweikamp
parents:
diff changeset
453
heinrichsweikamp
parents:
diff changeset
454 banksel common ; flag1 is in Bank1
heinrichsweikamp
parents:
diff changeset
455 bcf temp_changed ; Clear flag for temperature update
heinrichsweikamp
parents:
diff changeset
456 bcf pressure_refresh ; Clear flag for pressure update
heinrichsweikamp
parents:
diff changeset
457 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
458
heinrichsweikamp
parents:
diff changeset
459 ; Temp changed?
heinrichsweikamp
parents:
diff changeset
460 movf temperature+0,W
heinrichsweikamp
parents:
diff changeset
461 cpfseq last_temperature+0
heinrichsweikamp
parents:
diff changeset
462 bra isr_sensor_state2_2 ; Yes
heinrichsweikamp
parents:
diff changeset
463 movf temperature+1,W
heinrichsweikamp
parents:
diff changeset
464 cpfseq last_temperature+1
heinrichsweikamp
parents:
diff changeset
465 bra isr_sensor_state2_2 ; Yes
heinrichsweikamp
parents:
diff changeset
466
heinrichsweikamp
parents:
diff changeset
467 bra isr_sensor_state2_3 ; no change
heinrichsweikamp
parents:
diff changeset
468
heinrichsweikamp
parents:
diff changeset
469 isr_sensor_state2_2:
heinrichsweikamp
parents:
diff changeset
470 banksel common ; flag1 is in Bank1
heinrichsweikamp
parents:
diff changeset
471 bsf temp_changed ; Yes
heinrichsweikamp
parents:
diff changeset
472 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
473 isr_sensor_state2_3:
heinrichsweikamp
parents:
diff changeset
474 movff temperature+0,last_temperature+0 ; Copy for compare
heinrichsweikamp
parents:
diff changeset
475 movff temperature+1,last_temperature+1
heinrichsweikamp
parents:
diff changeset
476
heinrichsweikamp
parents:
diff changeset
477 movf amb_pressure+0,W
heinrichsweikamp
parents:
diff changeset
478 cpfseq last_pressure+0
heinrichsweikamp
parents:
diff changeset
479 bra isr_sensor_state2_4 ; Yes
heinrichsweikamp
parents:
diff changeset
480 movf amb_pressure+1,W
heinrichsweikamp
parents:
diff changeset
481 cpfseq last_pressure+1
heinrichsweikamp
parents:
diff changeset
482 bra isr_sensor_state2_4 ; Yes
heinrichsweikamp
parents:
diff changeset
483
heinrichsweikamp
parents:
diff changeset
484 bra isr_sensor_state2_5 ; No change
heinrichsweikamp
parents:
diff changeset
485 isr_sensor_state2_4:
heinrichsweikamp
parents:
diff changeset
486 banksel common ; flag1 is in Bank1
heinrichsweikamp
parents:
diff changeset
487 bsf pressure_refresh ; Yes
heinrichsweikamp
parents:
diff changeset
488 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
489 isr_sensor_state2_5:
heinrichsweikamp
parents:
diff changeset
490 movff amb_pressure+0,last_pressure+0 ; Copy for compare
heinrichsweikamp
parents:
diff changeset
491 movff amb_pressure+1,last_pressure+1
heinrichsweikamp
parents:
diff changeset
492
heinrichsweikamp
parents:
diff changeset
493 clrf sensor_state_counter ; Then reset State counter
176
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
494 banksel common ; flag2 is in Bank1
0
heinrichsweikamp
parents:
diff changeset
495 btfss simulatormode_active ; are we in simulator mode?
heinrichsweikamp
parents:
diff changeset
496 bra comp_air_pressure ; no
176
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
497 ; Always set pressure_refresh flag in simulator mode
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
498 bsf pressure_refresh ; Yes
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
499 banksel isr_backup ; Back to Bank0 ISR data
0
heinrichsweikamp
parents:
diff changeset
500 movlw LOW d'1000' ; yes, so simulate 1000mbar surface pressure
heinrichsweikamp
parents:
diff changeset
501 movwf last_surfpressure+0
heinrichsweikamp
parents:
diff changeset
502 movlw HIGH d'1000'
heinrichsweikamp
parents:
diff changeset
503 movwf last_surfpressure+1
heinrichsweikamp
parents:
diff changeset
504
heinrichsweikamp
parents:
diff changeset
505 comp_air_pressure:
176
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
506 banksel isr_backup ; Back to Bank0 ISR data
0
heinrichsweikamp
parents:
diff changeset
507 movf last_surfpressure+0,W ; compensate airpressure
heinrichsweikamp
parents:
diff changeset
508 subwf amb_pressure+0,W
heinrichsweikamp
parents:
diff changeset
509 movwf rel_pressure+0 ; rel_pressure stores depth!
heinrichsweikamp
parents:
diff changeset
510
heinrichsweikamp
parents:
diff changeset
511 movf last_surfpressure+1,W
heinrichsweikamp
parents:
diff changeset
512 subwfb amb_pressure+1,W
heinrichsweikamp
parents:
diff changeset
513 movwf rel_pressure+1
heinrichsweikamp
parents:
diff changeset
514 btfss STATUS,N ; result is below zero?
heinrichsweikamp
parents:
diff changeset
515 bra sensor_int_state_exit
heinrichsweikamp
parents:
diff changeset
516 clrf rel_pressure+0 ; Yes, do not display negative depths
heinrichsweikamp
parents:
diff changeset
517 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive
heinrichsweikamp
parents:
diff changeset
518 bra sensor_int_state_exit
heinrichsweikamp
parents:
diff changeset
519
heinrichsweikamp
parents:
diff changeset
520 sensor_int_state1_plus_restart:
heinrichsweikamp
parents:
diff changeset
521 clrf amb_pressure_avg+0 ; pressure average registers
heinrichsweikamp
parents:
diff changeset
522 clrf amb_pressure_avg+1
heinrichsweikamp
parents:
diff changeset
523 clrf temperature_avg+0
heinrichsweikamp
parents:
diff changeset
524 clrf temperature_avg+1
heinrichsweikamp
parents:
diff changeset
525
heinrichsweikamp
parents:
diff changeset
526 sensor_int_state1:
heinrichsweikamp
parents:
diff changeset
527 call get_temperature_value ; State 1: Get temperature
heinrichsweikamp
parents:
diff changeset
528 call get_pressure_start ; and start pressure integration.
heinrichsweikamp
parents:
diff changeset
529 bra sensor_int_state_exit
heinrichsweikamp
parents:
diff changeset
530
heinrichsweikamp
parents:
diff changeset
531 sensor_int_state2:
heinrichsweikamp
parents:
diff changeset
532 call get_pressure_value ; State2: Get pressure (51us)
heinrichsweikamp
parents:
diff changeset
533 call get_temperature_start ; and start temperature integration (73,5us)
heinrichsweikamp
parents:
diff changeset
534 call calculate_compensation ; calculate temperature compensated pressure (233us)
heinrichsweikamp
parents:
diff changeset
535 ; bra sensor_int_state_exit
heinrichsweikamp
parents:
diff changeset
536 sensor_int_state_exit:
heinrichsweikamp
parents:
diff changeset
537 rcall isr_restore_clock ; Restore clock
heinrichsweikamp
parents:
diff changeset
538 return
heinrichsweikamp
parents:
diff changeset
539 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
540
heinrichsweikamp
parents:
diff changeset
541
heinrichsweikamp
parents:
diff changeset
542
heinrichsweikamp
parents:
diff changeset
543 isr_rtcc: ; each second
heinrichsweikamp
parents:
diff changeset
544 bcf PIR3,RTCCIF ; clear flag
heinrichsweikamp
parents:
diff changeset
545 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
heinrichsweikamp
parents:
diff changeset
546 bsf RTCCFG,RTCPTR1
heinrichsweikamp
parents:
diff changeset
547 bsf RTCCFG,RTCPTR0 ; year
heinrichsweikamp
parents:
diff changeset
548 movff RTCVALL,year ; format is BCD!
heinrichsweikamp
parents:
diff changeset
549 movff RTCVALH,day ; dummy read
heinrichsweikamp
parents:
diff changeset
550 movff RTCVALL,day ; format is BCD!
heinrichsweikamp
parents:
diff changeset
551 movff RTCVALH,month ; format is BCD!
heinrichsweikamp
parents:
diff changeset
552 movff RTCVALL,hours ; format is BCD!
heinrichsweikamp
parents:
diff changeset
553 movff RTCVALH,secs ; format is BCD!
heinrichsweikamp
parents:
diff changeset
554 movff RTCVALL,secs ; format is BCD!
heinrichsweikamp
parents:
diff changeset
555 movff RTCVALH,mins ; format is BCD!
heinrichsweikamp
parents:
diff changeset
556 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
557
heinrichsweikamp
parents:
diff changeset
558 ; Convert BCD to DEC and set registers
heinrichsweikamp
parents:
diff changeset
559 movff mins, isr1_temp
heinrichsweikamp
parents:
diff changeset
560 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
561 movff WREG,mins
heinrichsweikamp
parents:
diff changeset
562 movff secs, isr1_temp
heinrichsweikamp
parents:
diff changeset
563 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
564 movff WREG,secs
heinrichsweikamp
parents:
diff changeset
565 movff hours, isr1_temp
heinrichsweikamp
parents:
diff changeset
566 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
567 movff WREG,hours
heinrichsweikamp
parents:
diff changeset
568 movff month, isr1_temp
heinrichsweikamp
parents:
diff changeset
569 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
570 movff WREG,month
heinrichsweikamp
parents:
diff changeset
571 movff day, isr1_temp
heinrichsweikamp
parents:
diff changeset
572 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
573 movff WREG,day
heinrichsweikamp
parents:
diff changeset
574 movff year, isr1_temp
heinrichsweikamp
parents:
diff changeset
575 rcall isr_rtcc_convert ; Converts to dec with result in WREG
heinrichsweikamp
parents:
diff changeset
576 movff WREG,year
heinrichsweikamp
parents:
diff changeset
577
heinrichsweikamp
parents:
diff changeset
578 ; Place once/second tasks for ISR here (Be sure of the right bank!)
heinrichsweikamp
parents:
diff changeset
579 banksel common ; flag1 is in Bank1
heinrichsweikamp
parents:
diff changeset
580 btfss sleepmode ; in Sleepmode?
heinrichsweikamp
parents:
diff changeset
581 call get_ambient_level ; No, get ambient light level and set max_CCPR1L
heinrichsweikamp
parents:
diff changeset
582
heinrichsweikamp
parents:
diff changeset
583 rcall isr_battery_gauge ; Add amount of battery consumption to battery_gauge:6
heinrichsweikamp
parents:
diff changeset
584
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
585 ; update uptime
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
586 banksel uptime+0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
587 incf uptime+0,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
588 movlw .0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
589 addwfc uptime+1,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
590 addwfc uptime+2,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
591 addwfc uptime+3,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
592
0
heinrichsweikamp
parents:
diff changeset
593 banksel common ; flag1 is in Bank1
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
594 bsf onesecupdate ; A new second has begun
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
595 btfsc divemode ; in divemode?
0
heinrichsweikamp
parents:
diff changeset
596 rcall isr_divemode_1sec ; Yes, do some divemode stuff in bank common
heinrichsweikamp
parents:
diff changeset
597
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
598 btfss divemode ; in divemode?
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
599 rcall isr_update_lastdive_time ; No, update the lastdive timer
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
600
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
601 tstfsz secs ; Secs == 0 ?
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
602 return ; No, Done.
0
heinrichsweikamp
parents:
diff changeset
603
heinrichsweikamp
parents:
diff changeset
604 bsf oneminupdate ; A new minute has begun
heinrichsweikamp
parents:
diff changeset
605
heinrichsweikamp
parents:
diff changeset
606 btfss divemode ; In Divemode?
heinrichsweikamp
parents:
diff changeset
607 rcall check_nofly_desat_time ; No, so reduce NoFly and Desat and increase interval
heinrichsweikamp
parents:
diff changeset
608
heinrichsweikamp
parents:
diff changeset
609 ; Check if a new hour has just begun
heinrichsweikamp
parents:
diff changeset
610 tstfsz mins ; mins=0?
heinrichsweikamp
parents:
diff changeset
611 bra isr_rtcc2 ; No
heinrichsweikamp
parents:
diff changeset
612 bsf onehourupdate ; Yes, set flag
heinrichsweikamp
parents:
diff changeset
613
heinrichsweikamp
parents:
diff changeset
614 isr_rtcc2:
heinrichsweikamp
parents:
diff changeset
615 banksel isr_backup ; Back to Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
616 return ; Done.
heinrichsweikamp
parents:
diff changeset
617
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
618 isr_update_lastdive_time:
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
619 ; update uptime
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
620 banksel lastdive_time+0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
621 incf lastdive_time+0,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
622 movlw .0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
623 addwfc lastdive_time+1,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
624 addwfc lastdive_time+2,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
625 addwfc lastdive_time+3,F
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
626 banksel common
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
627 return
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 451
diff changeset
628
0
heinrichsweikamp
parents:
diff changeset
629 isr_battery_gauge:
heinrichsweikamp
parents:
diff changeset
630 banksel isr_backup ; Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
631 movlw current_sleepmode ; 100µA/3600 -> nAs (Sleepmode current)
heinrichsweikamp
parents:
diff changeset
632 movwf isr1_temp ; Store value (low byte)
heinrichsweikamp
parents:
diff changeset
633 clrf isr2_temp ; High byte
heinrichsweikamp
parents:
diff changeset
634
heinrichsweikamp
parents:
diff changeset
635 banksel common ; flag1 is in Bank1
heinrichsweikamp
parents:
diff changeset
636 btfss sleepmode ; in Sleepmode?
heinrichsweikamp
parents:
diff changeset
637 rcall isr_battery_gauge2 ; No, compute current consumtion value into isr1_temp and isr2_temp
heinrichsweikamp
parents:
diff changeset
638
heinrichsweikamp
parents:
diff changeset
639 banksel isr_backup ; Bank0 ISR data
heinrichsweikamp
parents:
diff changeset
640 movf isr1_temp,W ; 48Bit add of isr1_temp and isr2_temp into battery_gauge:6
heinrichsweikamp
parents:
diff changeset
641 addwf battery_gauge+0,F
heinrichsweikamp
parents:
diff changeset
642 movf isr2_temp,W
heinrichsweikamp
parents:
diff changeset
643 addwfc battery_gauge+1,F
heinrichsweikamp
parents:
diff changeset
644 movlw .0
heinrichsweikamp
parents:
diff changeset
645 addwfc battery_gauge+2,F
heinrichsweikamp
parents:
diff changeset
646 addwfc battery_gauge+3,F
heinrichsweikamp
parents:
diff changeset
647 addwfc battery_gauge+4,F
heinrichsweikamp
parents:
diff changeset
648 addwfc battery_gauge+5,F
heinrichsweikamp
parents:
diff changeset
649 return
heinrichsweikamp
parents:
diff changeset
650
heinrichsweikamp
parents:
diff changeset
651 isr_battery_gauge2:
heinrichsweikamp
parents:
diff changeset
652 ; set consumtion rate in nAs for an one second interval
heinrichsweikamp
parents:
diff changeset
653 ; Example:
heinrichsweikamp
parents:
diff changeset
654 ; movlw LOW .55556 ; 0,2A/3600*1e9s = nAs
heinrichsweikamp
parents:
diff changeset
655 ; movwf isr1_temp ; Low byte
heinrichsweikamp
parents:
diff changeset
656 ; movlw HIGH .55556 ; 0,2A/3600*1e9s = nAs
heinrichsweikamp
parents:
diff changeset
657 ; movwf isr2_temp ; High byte
heinrichsweikamp
parents:
diff changeset
658
heinrichsweikamp
parents:
diff changeset
659 ; Current consumption for LED backlight is 47*CCPR1L+272
heinrichsweikamp
parents:
diff changeset
660 movf CCPR1L,W
heinrichsweikamp
parents:
diff changeset
661 mullw current_backlight_multi
heinrichsweikamp
parents:
diff changeset
662 movlw LOW current_backlight_offset
heinrichsweikamp
parents:
diff changeset
663 addwf PRODL,F
heinrichsweikamp
parents:
diff changeset
664 movlw HIGH current_backlight_offset
heinrichsweikamp
parents:
diff changeset
665 addwfc PRODH,F
heinrichsweikamp
parents:
diff changeset
666 movff PRODL,isr1_temp
heinrichsweikamp
parents:
diff changeset
667 movff PRODH,isr2_temp ; isr1_temp and isr2_temp hold value for backlight
heinrichsweikamp
parents:
diff changeset
668
heinrichsweikamp
parents:
diff changeset
669 ; Add current for CPU and GPU
heinrichsweikamp
parents:
diff changeset
670 ; speed_setting=1: ECO (3,1mA -> 861nAs), =2: NORMAL (5,50mA -> 1528nAs) or =3: FASTEST (8,04mA -> 2233nAs)
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 275
diff changeset
671 banksel isr_backup ; Bank0 ISR data
0
heinrichsweikamp
parents:
diff changeset
672 movlw .1
heinrichsweikamp
parents:
diff changeset
673 cpfseq speed_setting
heinrichsweikamp
parents:
diff changeset
674 bra isr_battery_gauge3
heinrichsweikamp
parents:
diff changeset
675 movlw LOW current_speed_eco
heinrichsweikamp
parents:
diff changeset
676 addwf isr1_temp,F
heinrichsweikamp
parents:
diff changeset
677 movlw HIGH current_speed_eco
heinrichsweikamp
parents:
diff changeset
678 addwfc isr2_temp,F
heinrichsweikamp
parents:
diff changeset
679 bra isr_battery_gauge5
heinrichsweikamp
parents:
diff changeset
680 isr_battery_gauge3:
heinrichsweikamp
parents:
diff changeset
681 movlw .2
heinrichsweikamp
parents:
diff changeset
682 cpfseq speed_setting
heinrichsweikamp
parents:
diff changeset
683 bra isr_battery_gauge4
heinrichsweikamp
parents:
diff changeset
684 movlw LOW current_speed_normal
heinrichsweikamp
parents:
diff changeset
685 addwf isr1_temp,F
heinrichsweikamp
parents:
diff changeset
686 movlw HIGH current_speed_normal
heinrichsweikamp
parents:
diff changeset
687 addwfc isr2_temp,F
heinrichsweikamp
parents:
diff changeset
688 bra isr_battery_gauge5
heinrichsweikamp
parents:
diff changeset
689 isr_battery_gauge4:
heinrichsweikamp
parents:
diff changeset
690 movlw LOW current_speed_fastest
heinrichsweikamp
parents:
diff changeset
691 addwf isr1_temp,F
heinrichsweikamp
parents:
diff changeset
692 movlw HIGH current_speed_fastest
heinrichsweikamp
parents:
diff changeset
693 addwfc isr2_temp,F
heinrichsweikamp
parents:
diff changeset
694 isr_battery_gauge5:
heinrichsweikamp
parents:
diff changeset
695 ; Add current if IR reciever is on
heinrichsweikamp
parents:
diff changeset
696 btfss ir_power ; IR enabled?
heinrichsweikamp
parents:
diff changeset
697 bra isr_battery_gauge6 ; no
heinrichsweikamp
parents:
diff changeset
698 movlw LOW current_ir_reciever
heinrichsweikamp
parents:
diff changeset
699 addwf isr1_temp,F
heinrichsweikamp
parents:
diff changeset
700 movlw HIGH current_ir_reciever
heinrichsweikamp
parents:
diff changeset
701 addwfc isr2_temp,F
heinrichsweikamp
parents:
diff changeset
702 isr_battery_gauge6:
heinrichsweikamp
parents:
diff changeset
703 ; Add current for compass/accelerometer
heinrichsweikamp
parents:
diff changeset
704 btfss compass_enabled ; compass active?
heinrichsweikamp
parents:
diff changeset
705 bra isr_battery_gauge7 ; no
heinrichsweikamp
parents:
diff changeset
706 movlw LOW current_compass
heinrichsweikamp
parents:
diff changeset
707 addwf isr1_temp,F
heinrichsweikamp
parents:
diff changeset
708 movlw HIGH current_compass
heinrichsweikamp
parents:
diff changeset
709 addwfc isr2_temp,F
heinrichsweikamp
parents:
diff changeset
710 isr_battery_gauge7:
heinrichsweikamp
parents:
diff changeset
711 return
heinrichsweikamp
parents:
diff changeset
712
heinrichsweikamp
parents:
diff changeset
713 isr_divemode_1sec:
heinrichsweikamp
parents:
diff changeset
714 incf samplesecs,F ; "samplingrate" diving seconds done
heinrichsweikamp
parents:
diff changeset
715 decf samplesecs_value,W ; holds "samplingrate" value (minus 1 into WREG)
heinrichsweikamp
parents:
diff changeset
716 cpfsgt samplesecs ; Done?
heinrichsweikamp
parents:
diff changeset
717 bra isr_divemode_1sec2 ; no
heinrichsweikamp
parents:
diff changeset
718
heinrichsweikamp
parents:
diff changeset
719 clrf samplesecs ; clear counter...
heinrichsweikamp
parents:
diff changeset
720 bsf store_sample ; ...and set bit for profile storage
heinrichsweikamp
parents:
diff changeset
721 isr_divemode_1sec2:
heinrichsweikamp
parents:
diff changeset
722 ; Increase re-setable average depth divetime counter
176
3fdafedc24af surface pressure copy in simulator
heinrichsweikamp
parents: 172
diff changeset
723 infsnz average_divesecs+0,F ; increase stopwatch registers
0
heinrichsweikamp
parents:
diff changeset
724 incf average_divesecs+1,F ; increase stopwatch registers
heinrichsweikamp
parents:
diff changeset
725 ; Increase total divetime (Regardless of start_dive_threshold)
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
726 infsnz total_divetime_seconds+0,F
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
727 incf total_divetime_seconds+1,F ; Total dive time (Regardless of start_dive_threshold)
0
heinrichsweikamp
parents:
diff changeset
728
heinrichsweikamp
parents:
diff changeset
729 btfss divemode2 ; displayed divetime is running?
heinrichsweikamp
parents:
diff changeset
730 return ; No (e.g. too shallow)
heinrichsweikamp
parents:
diff changeset
731
heinrichsweikamp
parents:
diff changeset
732 ; increase divetime registers (Displayed dive time)
heinrichsweikamp
parents:
diff changeset
733 incf divesecs,F
heinrichsweikamp
parents:
diff changeset
734 movlw d'59'
heinrichsweikamp
parents:
diff changeset
735 cpfsgt divesecs
heinrichsweikamp
parents:
diff changeset
736 bra isr_divemode_1sec2a
heinrichsweikamp
parents:
diff changeset
737
heinrichsweikamp
parents:
diff changeset
738 clrf divesecs
heinrichsweikamp
parents:
diff changeset
739 bsf realdive ; this bit is always set (again) if the dive is longer then one minute
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
740 infsnz divemins+0,F
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
741 incf divemins+1,F ; increase divemins
0
heinrichsweikamp
parents:
diff changeset
742
heinrichsweikamp
parents:
diff changeset
743 isr_divemode_1sec2a:
heinrichsweikamp
parents:
diff changeset
744 btfss FLAG_apnoe_mode ; Are we in Apnoe mode?
heinrichsweikamp
parents:
diff changeset
745 return ; No
heinrichsweikamp
parents:
diff changeset
746
heinrichsweikamp
parents:
diff changeset
747 incf apnoe_secs,F ; increase descent registers
heinrichsweikamp
parents:
diff changeset
748 movlw d'59'
heinrichsweikamp
parents:
diff changeset
749 cpfsgt apnoe_secs ; full minute?
heinrichsweikamp
parents:
diff changeset
750 return ; No
heinrichsweikamp
parents:
diff changeset
751 clrf apnoe_secs
heinrichsweikamp
parents:
diff changeset
752 incf apnoe_mins,F ; increase descent mins
heinrichsweikamp
parents:
diff changeset
753 return
heinrichsweikamp
parents:
diff changeset
754
heinrichsweikamp
parents:
diff changeset
755 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
756 ; BCD to Binary convertion.
heinrichsweikamp
parents:
diff changeset
757 ; Input: isr1_temp = Value in BCD
heinrichsweikamp
parents:
diff changeset
758 ; Output WREG = value in binary.
heinrichsweikamp
parents:
diff changeset
759 isr_rtcc_convert:
heinrichsweikamp
parents:
diff changeset
760 swapf isr1_temp, W
heinrichsweikamp
parents:
diff changeset
761 andlw 0x0F ; W= tens
heinrichsweikamp
parents:
diff changeset
762 rlncf WREG, W ; W= 2*tens
heinrichsweikamp
parents:
diff changeset
763 subwf isr1_temp, F ; 16*tens + ones - 2*tens
heinrichsweikamp
parents:
diff changeset
764 subwf isr1_temp, F ; 14*tens + ones - 2*tens
heinrichsweikamp
parents:
diff changeset
765 subwf isr1_temp, W ; 12*tens + ones - 2*tens
heinrichsweikamp
parents:
diff changeset
766 return
heinrichsweikamp
parents:
diff changeset
767
heinrichsweikamp
parents:
diff changeset
768 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
769
heinrichsweikamp
parents:
diff changeset
770 isr_switch_right: ;
heinrichsweikamp
parents:
diff changeset
771 bcf INTCON,INT0IE ; Disable INT0
heinrichsweikamp
parents:
diff changeset
772 banksel common ; flag1 is in Bank1
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
773 btfss flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
774 bsf switch_right ; Set flag
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
775 btfsc flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
776 bsf switch_left ; Set flag
0
heinrichsweikamp
parents:
diff changeset
777 bra isr_switch_common ; Continue...
heinrichsweikamp
parents:
diff changeset
778
heinrichsweikamp
parents:
diff changeset
779 isr_switch_left: ;
heinrichsweikamp
parents:
diff changeset
780 bcf INTCON3,INT1IE ; Disable INT1
heinrichsweikamp
parents:
diff changeset
781 banksel common ; flag1 is in Bank1
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
782 btfss flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
783 bsf switch_left ; Set flag
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
784 btfsc flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
785 bsf switch_right ; Set flag
0
heinrichsweikamp
parents:
diff changeset
786 isr_switch_common:
heinrichsweikamp
parents:
diff changeset
787 ; load timer1 for first press
heinrichsweikamp
parents:
diff changeset
788 clrf TMR1L
heinrichsweikamp
parents:
diff changeset
789 movlw TMR1H_VALUE_FIRST ; in steps of 7,8125ms
heinrichsweikamp
parents:
diff changeset
790 movwf TMR1H
heinrichsweikamp
parents:
diff changeset
791 bsf T1CON,TMR1ON ; Start Timer 1
heinrichsweikamp
parents:
diff changeset
792 banksel isr_backup ; Select Bank0 for ISR data.
heinrichsweikamp
parents:
diff changeset
793 bcf INTCON3,INT1IF ; Clear flag
heinrichsweikamp
parents:
diff changeset
794 bcf INTCON,INT0IF ; Clear flag
heinrichsweikamp
parents:
diff changeset
795 return
heinrichsweikamp
parents:
diff changeset
796
heinrichsweikamp
parents:
diff changeset
797 timer1int:
451
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
798 bcf PIR1,TMR1IF ; Clear flag
0
heinrichsweikamp
parents:
diff changeset
799 banksel common ; flag1 is in Bank1
451
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
800 bcf INTCON,INT0IF ; Clear flag
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
801 bcf INTCON3,INT1IF ; Clear flag
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
802 ; digital
0
heinrichsweikamp
parents:
diff changeset
803 btfss switch_left1 ; Left button hold-down?
heinrichsweikamp
parents:
diff changeset
804 bra timer1int_left ; Yes
heinrichsweikamp
parents:
diff changeset
805 btfss switch_right2 ; Right button hold-down?
heinrichsweikamp
parents:
diff changeset
806 bra timer1int_right ; Yes
451
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
807
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
808 ; Analog
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
809 btfsc analog_sw2_pressed ; Left button hold-down?
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
810 bra timer1int_left ; Yes
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
811 btfsc analog_sw1_pressed ; Right button hold-down?
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
812 bra timer1int_right ; Yes
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
813
0
heinrichsweikamp
parents:
diff changeset
814 ; No button hold-down, stop Timer 1
heinrichsweikamp
parents:
diff changeset
815 bcf T1CON,TMR1ON ; Stop Timer 1
heinrichsweikamp
parents:
diff changeset
816 bsf INTCON,INT0IE ; Enable INT0
heinrichsweikamp
parents:
diff changeset
817 bsf INTCON3,INT1IE ; Enable INT1
451
66049b6f2c0b speedup analog presses
heinrichsweikamp
parents: 448
diff changeset
818 return
0
heinrichsweikamp
parents:
diff changeset
819
heinrichsweikamp
parents:
diff changeset
820 timer1int_left:
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
821 btfss flip_screen ; 180° flipped?
0
heinrichsweikamp
parents:
diff changeset
822 bsf switch_left ; (Re-)Set flag
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
823 btfsc flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
824 bsf switch_right ; (Re-)Set flag
0
heinrichsweikamp
parents:
diff changeset
825 bra timer1int_common ; Continue
heinrichsweikamp
parents:
diff changeset
826 timer1int_right:
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
827 btfss flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
828 bsf switch_right ; Set flag
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
829 btfsc flip_screen ; 180° flipped?
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 148
diff changeset
830 bsf switch_left ; Set flag
0
heinrichsweikamp
parents:
diff changeset
831 timer1int_common:
heinrichsweikamp
parents:
diff changeset
832 ; load timer1 for next press
heinrichsweikamp
parents:
diff changeset
833 clrf TMR1L
heinrichsweikamp
parents:
diff changeset
834 movlw TMR1H_VALUE_CONT ; Surface mode
heinrichsweikamp
parents:
diff changeset
835 btfsc divemode
heinrichsweikamp
parents:
diff changeset
836 movlw TMR1H_VALUE_CONT_DIVE ; Dive mode
heinrichsweikamp
parents:
diff changeset
837 movwf TMR1H
heinrichsweikamp
parents:
diff changeset
838 return ; Return from timer1int with timer1 kept running
heinrichsweikamp
parents:
diff changeset
839
heinrichsweikamp
parents:
diff changeset
840 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
841
heinrichsweikamp
parents:
diff changeset
842 check_nofly_desat_time:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
843
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
844 ; DELETE - no-fly time is now re-computed every second ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
845 ; ; REPLACE ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
846 ; ; movf nofly_time+0,W ; Is nofly null ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
847 ; ; iorwf nofly_time+1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
848 ; ; BY
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
849 ; banksel int_O_nofly_time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
850 ; movf int_O_nofly_time+0,W ; Is nofly null ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
851 ; iorwf int_O_nofly_time+1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
852
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
853 ; bz check_nofly_desat_time2 ; yes...
0
heinrichsweikamp
parents:
diff changeset
854
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
855 ; movlw d'1'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
856 ; ; REPLACE ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
857 ; ; subwf nofly_time+0,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
858 ; ; BY
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
859 ; subwf int_O_nofly_time+0,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
860
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
861 ; movlw d'0'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
862
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
863 ; ; REPLACE ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
864 ; ; subwfb nofly_time+1,F ; reduce by one
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
865 ; ; BY
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
866 ; subwfb int_O_nofly_time+1,F ; reduce by one
0
heinrichsweikamp
parents:
diff changeset
867
heinrichsweikamp
parents:
diff changeset
868 check_nofly_desat_time2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
869 ; REPLACE
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
870 ; movf desaturation_time+0,W ; Is Desat null ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
871 ; iorwf desaturation_time+1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
872 ; BY
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
873 banksel int_O_desaturation_time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
874 movf int_O_desaturation_time+0,W ; Is Desat null ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
875 iorwf int_O_desaturation_time+1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
876
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
877 bz check_nofly_desat_time3 ; yes...
0
heinrichsweikamp
parents:
diff changeset
878
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
879 ; DELETE - desat-time is now re-computed every second ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
880 ; movlw d'1'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
881 ; ; REPLACE ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
882 ; ; subwf desaturation_time+0,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
883 ; ; BY
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
884 ; subwf int_O_desaturation_time+0,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
885
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
886 ; movlw d'0'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
887
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
888 ; ; REPLACE ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
889 ; ; subwfb desaturation_time+1,F ; reduce by one...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
890 ; ; by
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
891 ; subwfb int_O_desaturation_time+1,F ; reduce by one...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
892 banksel common
0
heinrichsweikamp
parents:
diff changeset
893
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 145
diff changeset
894 ; Increase surface interval timer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 145
diff changeset
895 infsnz surface_interval+0,F
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 145
diff changeset
896 incf surface_interval+1,F
0
heinrichsweikamp
parents:
diff changeset
897 return ; Done
heinrichsweikamp
parents:
diff changeset
898
heinrichsweikamp
parents:
diff changeset
899 check_nofly_desat_time3:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
900 ; NEW ## no fly
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
901 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 490
diff changeset
902
0
heinrichsweikamp
parents:
diff changeset
903 clrf surface_interval+0
heinrichsweikamp
parents:
diff changeset
904 clrf surface_interval+1 ; Clear surface interval timer
heinrichsweikamp
parents:
diff changeset
905 return ; Done.
heinrichsweikamp
parents:
diff changeset
906
heinrichsweikamp
parents:
diff changeset
907 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
908
heinrichsweikamp
parents:
diff changeset
909 isr_restore_clock:
heinrichsweikamp
parents:
diff changeset
910 banksel isr_backup
heinrichsweikamp
parents:
diff changeset
911 movlw d'1'
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 275
diff changeset
912 cpfseq speed_setting
0
heinrichsweikamp
parents:
diff changeset
913 bra isr_restore_speed2
heinrichsweikamp
parents:
diff changeset
914 ; Reset to eco
heinrichsweikamp
parents:
diff changeset
915 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
916 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
heinrichsweikamp
parents:
diff changeset
917 movlw b'00110010'
heinrichsweikamp
parents:
diff changeset
918 movwf OSCCON ; 1MHz INTOSC
heinrichsweikamp
parents:
diff changeset
919 movlw T2CON_ECO
heinrichsweikamp
parents:
diff changeset
920 movwf T2CON
heinrichsweikamp
parents:
diff changeset
921 bra isr_restore_exit
heinrichsweikamp
parents:
diff changeset
922 isr_restore_speed2:
heinrichsweikamp
parents:
diff changeset
923 movlw d'2'
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 275
diff changeset
924 cpfseq speed_setting
0
heinrichsweikamp
parents:
diff changeset
925 bra isr_restore_speed3
heinrichsweikamp
parents:
diff changeset
926 ; Reset to normal
heinrichsweikamp
parents:
diff changeset
927 movlw b'01110010'
heinrichsweikamp
parents:
diff changeset
928 movwf OSCCON ; 16MHz INTOSC
heinrichsweikamp
parents:
diff changeset
929 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
930 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
heinrichsweikamp
parents:
diff changeset
931 movlw T2CON_NORMAL
heinrichsweikamp
parents:
diff changeset
932 movwf T2CON
heinrichsweikamp
parents:
diff changeset
933 bra isr_restore_exit
heinrichsweikamp
parents:
diff changeset
934
heinrichsweikamp
parents:
diff changeset
935 isr_restore_speed3:
heinrichsweikamp
parents:
diff changeset
936 ; Reset to fastest
heinrichsweikamp
parents:
diff changeset
937 movlw b'01110010' ; 16MHz INTOSC
heinrichsweikamp
parents:
diff changeset
938 movwf OSCCON
heinrichsweikamp
parents:
diff changeset
939 movlw b'01000000'
heinrichsweikamp
parents:
diff changeset
940 movwf OSCTUNE ; 4x PLL Enable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz)
heinrichsweikamp
parents:
diff changeset
941 movlw T2CON_FASTEST
heinrichsweikamp
parents:
diff changeset
942 movwf T2CON
heinrichsweikamp
parents:
diff changeset
943 ; bra isr_restore_exit
heinrichsweikamp
parents:
diff changeset
944 isr_restore_exit:
heinrichsweikamp
parents:
diff changeset
945 btfss OSCCON,HFIOFS
heinrichsweikamp
parents:
diff changeset
946 bra isr_restore_exit ; loop until PLL is stable
heinrichsweikamp
parents:
diff changeset
947 return
heinrichsweikamp
parents:
diff changeset
948
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
949
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
950 restore_flash: ; Restore first flash page from eeprom
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
951 banksel common
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
952 ; Start address in internal flash
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
953 movlw 0x00
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
954 movwf TBLPTRL
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
955 movwf TBLPTRH
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
956 movwf TBLPTRU
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
957
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
958 movlw b'10010100' ; Setup erase
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
959 rcall Write ; Write!
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
960
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
961 movlw .128
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
962 movwf lo ; Byte counter
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
963 clrf EEADR
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
964 movlw .3
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
965 movwf EEADRH ; Setup backup address
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
966
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
967 TBLRD*- ; Dummy read to be in 128 byte block
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
968 restore_flash_loop:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
969 call read_eeprom
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
970 incf EEADR,F
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
971 movff EEDATA,TABLAT ; put 1 byte
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
972 tblwt+* ; Table Write with Pre-Increment
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
973 decfsz lo,F ; 128byte done?
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
974 bra restore_flash_loop ; No
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
975
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
976 movlw b'10000100' ; Setup writes
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
977 rcall Write ; Write!
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
978
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
979 reset ; Done, reset CPU
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
980
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
981 Write:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
982 movwf EECON1 ; Type of memory to write in
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
983 movlw 0x55
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
984 movwf EECON2
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
985 movlw 0xAA
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
986 movwf EECON2
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
987 bsf EECON1,WR ; Write
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
988 nop
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
989 nop
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
990 return
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
991
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
992
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 378
diff changeset
993 END