annotate code_part1/OSTC_code_asm_part1/isr.asm @ 636:8ab4b7804dbb 250_spanish

Spanish update
author heinrichsweikamp
date Tue, 18 Sep 2012 09:06:52 +0200
parents fbd5e2b75a63
children de413161f00c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
402
e565392e0fcc Add a trailing space for nofly and desat
heinrichsweikamp
parents: 398
diff changeset
1
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 ; OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
5 ; This program is free software: you can redistribute it and/or modify
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
6 ; it under the terms of the GNU General Public License as published by
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
7 ; the Free Software Foundation, either version 3 of the License, or
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
8 ; (at your option) any later version.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
9
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
10 ; This program is distributed in the hope that it will be useful,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
13 ; GNU General Public License for more details.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
14
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
15 ; You should have received a copy of the GNU General Public License
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
17
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
18
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 ; written: 10/30/05
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; last updated: 05/16/08
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; ToDo:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25 ; the timer1 module interrupts every 62.5ms (16x/second)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26 ; temperature and pressure is averaged over 4 measurements
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27 ; flag pressure_refresh is set every 500ms
398
ab962c4b19d6 Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents: 392
diff changeset
28 ; and provides accurate pressure (+/-1mbar stable) and temperature (0.1C stable)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
30 ;=============================================================================
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
31 ; Copy a 16bit value from ISR modified registers to main registers.
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
32 ;
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
33 ; Because the ISR can happend at any time, the read should be redone if bytes
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
34 ; changed inbetween.
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
35 ;
343
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
36 ; Trashes: WREG and TABLAT
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
37 ; NOTE: Destination might be in any bank, so be BANK SAFE.
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
38 ;
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
39 SAFE_2BYTE_COPY MACRO from, to
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
40 local retry
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
41 retry:
343
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
42 movff from+1,WREG ; High byte in W.
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
43 movff WREG,to+1 ; and destination.
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
44 movff from+0,to+0 ; Copy low byte.
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
45 movff from+1,TABLAT ; another bank-safe read.
d5240792be51 BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents: 341
diff changeset
46 xorwf TABLAT,W ; High byte changed ?
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
47 bnz retry
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
48 ENDM
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
49
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
50 ;=============================================================================
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 uartint:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 btfsc simulatormode_active ; are we in simulatormode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 bra simulator_int ; Yes, reading is depth in m!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 movff RCREG,uart1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 movlw d'96'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 subwf uart1_temp,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 dcfsnz uart1_temp,F ; "a"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 bsf dump_external_eeprom ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 dcfsnz uart1_temp,F ; "b"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 bsf uart_settime ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 dcfsnz uart1_temp,F ; "c"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 bsf simulatormode_active ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 dcfsnz uart1_temp,F ; "d"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 bsf internal_eeprom_write ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 dcfsnz uart1_temp,F ; "e"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 bsf uart_send_hash ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 dcfsnz uart1_temp,F ; "f"
297
ceedf078b2d8 Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents: 283
diff changeset
69 bsf uart_reset_battery_stats ; set flag
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 dcfsnz uart1_temp,F ; "g"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 bsf uart_send_int_eeprom ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 dcfsnz uart1_temp,F ; "h"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 bsf uart_reset_decodata ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 dcfsnz uart1_temp,F ; "i"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 bsf internal_eeprom_write2 ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 dcfsnz uart1_temp,F ; "j"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 bsf uart_send_int_eeprom2 ; set flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 dcfsnz uart1_temp,F ; "k"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 bsf uart_store_tissue_data ; set flag
330
447390289f47 NEW screen_dump serial command (l)
JeanDo
parents: 297
diff changeset
80 dcfsnz uart1_temp,F ; "l"
447390289f47 NEW screen_dump serial command (l)
JeanDo
parents: 297
diff changeset
81 bsf uart_dump_screen ; set flag
578
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 573
diff changeset
82 dcfsnz uart1_temp,F ; "m"
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 573
diff changeset
83 bsf uart_send_int_eeprom3 ; set flag
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 573
diff changeset
84 dcfsnz uart1_temp,F ; "n"
fbd5e2b75a63 adding access to CF64-CF95
heinrichsweikamp
parents: 573
diff changeset
85 bsf internal_eeprom_write3 ; set flag
283
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 266
diff changeset
86 movlw 0xC1
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 266
diff changeset
87 cpfseq RCREG ; 115200Baud Bootloader request?
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 266
diff changeset
88 bra uartint1 ; No
4ec488f046f4 Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents: 266
diff changeset
89 bsf uart_115200_bootloader ; Yes, set Flag
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 uartint1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 movf RCREG,w ; unload RCREG in stand-alone simulator mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 bcf PIR1,RCIF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 bcf RCSTA,CREN ; Clear receiver status
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 bsf RCSTA,CREN
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98 simulator_int:
345
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
99 movlw 'l' ; Received 'l' dump-screen command ?
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
100 xorwf RCREG,W
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
101 bnz simulator_int2 ; NO: skip
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
102 bsf uart_dump_screen ; YES: set flag
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
103 bra uartint1 ; and this is not a depth...
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
104
8bb7c901743d Added screen dumps in simulator mode too.
JeanDo
parents: 344
diff changeset
105 simulator_int2:
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 btfsc standalone_simulator ; ignore in standalone simulator mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107 bra uartint1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 13
diff changeset
109 bsf LED_blue
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 tstfsz RCREG ; =0x00?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111 bra simulator_int1 ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 incf RCREG,F ; Yes, so force RCREG=1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 simulator_int1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 movf RCREG,w ; depth in m
347
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
116 movwf PRODL ; Copy
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
117
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
118 movlw d'140' ; Limit to 130m
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
119 cpfslt PRODL ; compare with value in UART
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
120 movwf PRODL ; Overwrite reading
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
121
ba0f30f3d560 Ignore depths>130m in PC simulation
heinrichsweikamp
parents: 345
diff changeset
122 movf PRODL,w ; depth in m
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123 mullw d'100' ; result will be mbar
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 movff PRODL,sim_pressure+0 ; stored for pressure overwrite
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 movff PRODH,sim_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 bra uartint1 ; exit uart int
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
128 ;=============================================================================
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
129
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
130 switch_left_int:
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 bcf INTCON,INT0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 btfsc T0CON,TMR0ON ; Timer0 running?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 bra timer0_restart ; Yes, restart
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135
266
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
136 ; OSTC 2N has flipped screen and exchanged switches...
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
137 movff win_flags,WREG ; Get into Bank0
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
138 btfss WREG,0
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139 bsf switch_left ; Set flag, button press is OK
266
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
140 btfsc WREG,0
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
141 bsf switch_right ; Set flag, button press is OK
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 bsf T0CON,TMR0ON ; Start Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
147 switch_right_int:
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 bcf INTCON3,INT1IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 btfsc T0CON,TMR0ON ; Timer0 running?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 bra timer0_restart ; Yes, restart
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152
266
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
153 ; OSTC 2N has flipped screen and exchanged switches...
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
154 movff win_flags,WREG ; Get into Bank0
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
155 btfsc WREG,0
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
156 bsf switch_left ; Set flag, button press is OK
ba109a7948df OSTC 2N uses exchanged switches...
heinrichsweikamp
parents: 245
diff changeset
157 btfss WREG,0
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158 bsf switch_right ; Set flag, button press is OK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 bsf T0CON,TMR0ON ; Start Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 timer0_restart:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 bcf INTCON,TMR0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165 clrf T0CON ; Timer0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 clrf TMR0H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167 clrf TMR0L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 bsf T0CON,TMR0ON ; Start Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 timer0int:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 bcf INTCON,TMR0IF ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 bcf T0CON,TMR0ON ; Stop Timer 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 clrf TMR0H
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 clrf TMR0L
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 return
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
177
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
178 ;=============================================================================
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
179 ;
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
180
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 timer1int:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 timer1int_debug:
21
73014f788032 1.60 stable rc1
heinrichsweikamp
parents: 13
diff changeset
183 bcf LED_red ; LEDr off (For charge indicator)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184
390
a847f416e67e Debugging timer1
heinrichsweikamp
parents: 379
diff changeset
185 btfsc TMR1L,0 ; Wait for low clock cycle
a847f416e67e Debugging timer1
heinrichsweikamp
parents: 379
diff changeset
186 bra $-2
391
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
187 btfss TMR1L,0 ; Still high?
390
a847f416e67e Debugging timer1
heinrichsweikamp
parents: 379
diff changeset
188 bra $-2 ; max. loop time: 61µs
378
51baf8777b73 testing, removing unused stuff
heinrichsweikamp
parents: 377
diff changeset
189
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 movlw 0x08 ; Timer1 int after 62.5ms (=16/second)
391
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
191 cpfslt TMR1H ; Did we miss a 1/16 second?
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
192 incf timer1int_counter1,F ; Yes, add extra 1/16 second
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
193
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
194 movlw 0x08 ; Timer1 int after 62.5ms (=16/second)
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 subwf TMR1H,F
391
ee5e1c65657c Debugging the TMR1...
heinrichsweikamp
parents: 390
diff changeset
196 bcf PIR1,TMR1IF ; Clear flag
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
198 incf timer1int_counter1,F ; Increase timer1 counter
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
199
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 movlw d'15' ; One second 16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 cpfsgt timer1int_counter1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 bra sensor_int_pre ; only pressure sensor
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
203 rcall RTCisr ; adjust time, then query pressure sensor
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 sensor_int_pre:
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
206 btfsc sleepmode ; In sleepmode?
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
207 return ; Yes
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
209 ; Sensor interput do poll the presure/temperature sensor, download results,
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
210 ; compute compensations, and store results in various shared variables.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
211 ;
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
212 ; Input: interupt (every 62.5msec == 16Hz), sensor,
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
213 ; last_surfpressure:2.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
214 ;
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
215 ; Output: amb_pressure:2,
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
216 ; temperature:2,
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
217 ; rel_pressure:2,
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
218 ; and the pressure_refresh flag.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
219 ;
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
220 ; NOTE: averaging (4 successive value, as recommended in the MS5535 datasheet)
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
221 ; is done on private variables, to avoid trashing data while reading it
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
222 ; from the main code.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
223 ;
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
224 ; NOTE: Because there is no atomic 16bits load/stores, we need to check twice
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
225 ; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get
344
797e2ac42d24 MERGE with 1.91 main trunk.
JeanDo
parents: 330 343
diff changeset
226 ; amb_pressure, temperature or rel_pressure
341
2144f19fa1eb BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents: 340
diff changeset
227 ;
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228 sensor_int:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
232 incf timer1int_counter2,F ; counts to eight for state maschine
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
234 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
235 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
236 ; State 3: Get temperature (51us) and start pressure integration (73,5us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
237 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
238 ; State 5: Get temperature (51us) and start pressure integration (73,5us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
239 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
240 ; State 7: Get temperature (51us) and start pressure integration (73,5us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
241 ; 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
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
242
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
243 movff timer1int_counter2,isr_divB ; isr_divB used as temp here...
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
244 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
245 bra sensor_int_state1_plus_restart ; Do State 1
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
246 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
247 bra sensor_int_state2 ; Do State 2
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
248 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
249 bra sensor_int_state1 ; Do State 3
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
250 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
251 bra sensor_int_state2 ; Do State 4
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
252 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
253 bra sensor_int_state1 ; Do State 5
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
254 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
255 bra sensor_int_state2 ; Do State 6
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
256 dcfsnz isr_divB,F
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
257 bra sensor_int_state1 ; Do State 7
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
258 ; bra sensor_int2_plus_average ; Do State 8
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
259
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
260 ;sensor_int2_plus_average:
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
261 rcall sensor_int_state2
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
262 sensor_int2_plus_average2:
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
263 bcf STATUS,C ; clear carry bit.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
264 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
265 rrcf amb_pressure_avg+0
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
266 bcf STATUS,C ; clear carry bit, twice.
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
267 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
268 rrcf amb_pressure_avg+0
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
269
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
270 movff amb_pressure_avg+1,amb_pressure+1 ; copy into actual register
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
271 movff amb_pressure_avg+0,amb_pressure+0
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
272
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
273 bcf STATUS,C
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
274 btfsc temperature_avg+1,7 ; Copy sign bit to carry
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
275 bsf STATUS,C
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
276 rrcf temperature_avg+1 ; Signed temperature /2
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
277 rrcf temperature_avg+0
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
278
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
279 bcf STATUS,C
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
280 btfsc temperature_avg+1,7 ; Copy sign bit to carry
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
281 bsf STATUS,C
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
282 rrcf temperature_avg+1 ; Signed temperature /4
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
283 rrcf temperature_avg+0
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
284
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
285 movff temperature_avg+1,temperature+1
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
286 movff temperature_avg+0,temperature+0
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
287
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
288 bsf pressure_refresh ; Set flag! Temp and pressure were updated!
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
289 clrf timer1int_counter2 ; Then reset State counter
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
290
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
291 btfss simulatormode_active ; are we in simulator mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
292 bra comp_air_pressure ; no
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
293
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294 comp_air_pressure0:
398
ab962c4b19d6 Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents: 392
diff changeset
295 movlw LOW d'1000' ; yes, so simulate 1bar surface pressure
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296 movwf last_surfpressure+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
297 movlw HIGH d'1000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
298 movwf last_surfpressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
299
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
300 comp_air_pressure:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
301 movf last_surfpressure+0,W ; compensate airpressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302 subwf amb_pressure+0,W
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
303 movwf rel_pressure+0 ; rel_pressure stores depth!
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
305 movf last_surfpressure+1,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306 subwfb amb_pressure+1,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
307 movwf rel_pressure+1
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
308 btfss STATUS,N ; result is below zero?
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
309 return
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
310 clrf rel_pressure+0 ; Yes, do not display negative depths
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
311 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
312 return
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
313
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
314 sensor_int_state1_plus_restart:
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
315 clrf amb_pressure_avg+0 ; pressure average registers
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
316 clrf amb_pressure_avg+1
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
317 clrf temperature_avg+0
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
318 clrf temperature_avg+1
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
319
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
320 sensor_int_state1:
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
321 call get_temperature_value ; State 1: Get temperature
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
322 call get_pressure_start ; and start pressure integration.
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
323 return ; Done.
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
324
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
325 sensor_int_state2:
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
326 call get_pressure_value ; State2: Get pressure (51us)
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
327 call get_temperature_start ; and start temperature integration (73,5us)
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
328 goto calculate_compensation ; calculate temperature compensated pressure (233us)
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
329
340
ecbbbd423e86 BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents: 297
diff changeset
330 ;=============================================================================
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332 RTCisr:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 clrf timer1int_counter1 ; counts to 16 (one second / 62.5ms)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334 bsf onesecupdate ; we have a new second!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 bcf STATUS,Z ; are we in dive mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 btfss divemode
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
338 bra RTCisr2 ; No, must be surface or sleepmode
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340 incf samplesecs,F ; CF20 diving seconds done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 decf samplesecs_value,W ; holds CF20 value (minus 1 into WREG)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342 cpfsgt samplesecs
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
343 bra RTCisr1 ; no
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
344
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
345 clrf samplesecs ; clear counter...
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
346 bsf store_sample ; ...and set bit for profile storage
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
347
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
348 RTCisr1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 ; Increase re-setable average depth divetime counter
111
ed7826c740a0 1.74beta rc1
heinrichsweikamp
parents: 49
diff changeset
350 incf average_divesecs+0,F ; increase stopwatch registers
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351 btfsc STATUS,Z
357
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
352 incf average_divesecs+1,F ; increase stopwatch registers
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
353 ; Increase total divetime (Regardless of CF01)
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
354 incf total_divetime_seconds+0,F ; increase stopwatch registers
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
355 btfsc STATUS,Z
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
356 incf total_divetime_seconds+1,F ; increase stopwatch registers
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
357
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
358 btfss divemode2 ; displayed divetime is running?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
359 bra RTCisr2 ; No (e.g. too shallow)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
360
357
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
361 ; increase divetime registers (Displayed dive time)
562f1bc79f3c Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents: 347
diff changeset
362 incf divesecs,F
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
363 movlw d'59'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
364 cpfsgt divesecs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
365 bra RTCisr1a
238
9581e48a914f Some cleanup in the ISR
heinrichsweikamp
parents: 111
diff changeset
366
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
367 clrf divesecs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
368 bsf realdive ; this bit is always set (again) if the dive is longer then one minute
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
369
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
370 incf divemins+0,F ; increase divemins
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
371 btfsc STATUS,Z
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
372 incf divemins+1,F ; and now do the realtime clock routine anyway
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
373
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
374 RTCisr1a:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
375 btfss FLAG_apnoe_mode ; Are we in Apnoe mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
376 bra RTCisr2 ; No, skip the following
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
377
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
378 incf apnoe_secs,F ; increase descent registers
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
379 movlw d'59'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
380 cpfsgt apnoe_secs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
381 bra RTCisr2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
382 clrf apnoe_secs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
383
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
384 incf apnoe_mins,F ; increase descent mins
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
385 ; Now, do the RTC routine....
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
386 RTCisr2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
387 incf secs,F ; adjusts seconds, minutes, hours, day, month and year. Checks for a leap year and works until 2099!
356
9ef9b681f38f BUGFIX time_correction_value (CF48) > 60 or < 0.
JeanDo
parents: 347
diff changeset
388 movlw d'60'
359
91352bb698cf Oups... time to sleep !
JeanDo
parents: 356
diff changeset
389 cpfseq secs ; Secs == 60 ?
91352bb698cf Oups... time to sleep !
JeanDo
parents: 356
diff changeset
390 return ; NO : done.
91352bb698cf Oups... time to sleep !
JeanDo
parents: 356
diff changeset
391 clrf secs ; YES: increment minutes instead...
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
392 bsf oneminupdate
497
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
393
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
394 btfss divemode ; In Divemode?
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
395 rcall check_nofly_desat_time ; No, so reduce NoFly and Desat and increase interval
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
396
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
397 incf mins,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 movlw d'59'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399 cpfsgt mins
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 clrf mins
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 incf hours,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403 movlw d'23'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 cpfsgt hours
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
405 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 clrf hours
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 0
diff changeset
407 incf day,F
392
8e272339fb68 1.91beta RC
heinrichsweikamp
parents: 391
diff changeset
408 movff time_correction_value,secs ; Correct too slow clock
13
3b30cd739782 1.53 beta rc2
heinrichsweikamp
parents: 0
diff changeset
409
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 check_date:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 movff month,isr_divB ; new month?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
412 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
414 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415 movlw .28
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
416 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
417 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
418 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
419 movlw .30
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
421 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
422 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
423 movlw .30
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
424 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
425 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
427 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
428 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
429 movlw .30
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
430 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
431 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433 movlw .30
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 dcfsnz isr_divB,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
435 movlw .31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
436 cpfsgt day,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
437 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
438 movlw .1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439 movwf day
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440 incf month,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441 movlw .12
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442 cpfsgt month,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 movlw .1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445 movwf month
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 incf year,F
497
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
447 return
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
448
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
449 check_nofly_desat_time:
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
450 bcf nofly_active ; Clear flag
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
451 movf nofly_time+0,W ; Is nofly null ?
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
452 iorwf nofly_time+1,W
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
453 bz check_nofly_desat_time2 ; yes...
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
454
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
455 bsf nofly_active ; Set flag (again)
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
456 movlw d'1'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
457 subwf nofly_time+0,F
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
458 movlw d'0'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
459 subwfb nofly_time+1,F ; reduce by one
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
460
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
461 check_nofly_desat_time2:
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
462 movff desaturation_time_buffer+0,lo
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
463 movff desaturation_time_buffer+1,hi
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
464
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
465 movf lo,W ; Is Desat null ?
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
466 iorwf hi,W
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
467 bz check_nofly_desat_time3 ; yes...
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
468
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
469 movlw d'1'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
470 subwf lo,F
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
471 movlw d'0'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
472 subwfb hi,F ; reduce by one...
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
473
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
474 movff lo,desaturation_time_buffer+0 ; ...and copy back
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
475 movff hi,desaturation_time_buffer+1
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
476
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
477 check_nofly_desat_time3:
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
478 ; Now increase interval timer
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
479 movff desaturation_time_buffer+0,lo
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
480 movff desaturation_time_buffer+1,hi
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
481 tstfsz lo ;=0?
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
482 bra calc_surface_interval2 ; No
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
483 tstfsz hi ;=0?
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
484 bra calc_surface_interval2 ; No
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
485 clrf surface_interval+0
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
486 clrf surface_interval+1 ; Clear surface interval timer
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
487 return ; Done.
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
488
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
489 calc_surface_interval2: ; Increase surface interval timer
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
490 movlw d'1'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
491 addwf surface_interval+0,F
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
492 movlw d'0'
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
493 addwfc surface_interval+1,F
06db5dd9149f show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents: 402
diff changeset
494 return ; Done