Mercurial > public > hwos_code
annotate src/start.asm @ 589:8a7d2d8bcd33
limit string length to 4 digits/chars in average depth
author | heinrichsweikamp |
---|---|
date | Sat, 10 Mar 2018 15:44:58 +0100 |
parents | b455b31ce022 |
children | 05053910d668 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
582 | 3 ; File start.asm REFACTORED VERSION V2.98 |
0 | 4 ; |
5 ; Startup subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-06 : [mH] moving from OSTC code | |
11 | |
582 | 12 #include "hwos.inc" ; Mandatory header |
13 #include "ms5541.inc" | |
14 #include "isr.inc" | |
15 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
16 #include "eeprom_rs232.inc" | |
17 #include "math.inc" | |
18 #include "tft.inc" | |
19 #include "surfmode.inc" | |
20 #include "wait.inc" | |
21 #include "rtc.inc" | |
22 #include "external_flash.inc" | |
23 #include "convert.inc" | |
24 #include "strings.inc" | |
25 #include "tft_outputs.inc" | |
26 #include "adc_lightsensor.inc" | |
27 #include "i2c.inc" | |
0 | 28 |
582 | 29 extern init_ostc |
30 extern option_restore_all | |
31 extern deco_setup | |
32 extern restore_decodata_from_eeprom | |
33 extern color_image | |
34 extern oPressureAdjust | |
35 extern option_reset | |
36 extern option_save | |
37 extern option_save_all | |
38 extern option_check_all | |
39 extern do_new_battery_select | |
40 extern use_old_batteries | |
41 extern use_old_prior_209 | |
0 | 42 |
43 ;============================================================================= | |
44 ; Reset vector: What to do on device wake-up and hard reset. | |
45 ; | |
582 | 46 reset_v code 0x00000 |
0 | 47 |
582 | 48 ; goto start |
49 goto 0x1FF00 ; Bootloader | |
50 | |
51 ORG 0x00004 ; Needed for second-level bootloader | |
0 | 52 goto start |
582 | 53 |
0 | 54 ;============================================================================= |
582 | 55 |
56 boot CODE | |
0 | 57 |
582 | 58 global start |
0 | 59 start: |
582 | 60 lfsr FSR0,0x000 ; Clear rambank 0-14 |
0 | 61 clear_rambank: |
62 clrf POSTINC0 | |
63 movlw 0x0F | |
582 | 64 cpfseq FSR0H ; Bank 14 done? |
65 bra clear_rambank ; clear... | |
0 | 66 |
582 | 67 call init_ostc |
0 | 68 |
582 | 69 ; Get button type from Bootloader-Info |
70 movlw .16 | |
71 movff WREG,analog_counter ; init averaging | |
72 bsf analog_switches | |
73 movlw 0x7C | |
74 movwf TBLPTRL | |
75 movlw 0xF7 | |
76 movwf TBLPTRH | |
77 movlw 0x01 | |
78 movwf TBLPTRU | |
79 TBLRD*+ ; Reads 0x07 for analog buttons | |
449 | 80 movlw 0x07 |
81 cpfseq TABLAT | |
582 | 82 bcf analog_switches |
475 | 83 |
84 ; read button polarity | |
582 | 85 movlw LOW .897 |
475 | 86 movwf EEADR |
582 | 87 movlw HIGH .897 |
475 | 88 movwf EEADRH |
582 | 89 call read_eeprom ; EEDATA into EEPROM@EEADR |
90 clrf EEADRH ; Reset EEADRH | |
91 movff EEDATA,button_polarity ; 0xFF (Both normal), 0x00 (Both inverted), 0x01 (Left inverted only), 0x02 (Right inverted only) | |
475 | 92 |
582 | 93 ; Air pressure compensation after reset |
94 call get_calibration_data ; get calibration data from pressure sensor | |
95 banksel common ; get_calibration_data uses isr_backup | |
0 | 96 |
582 | 97 call TFT_DisplayOff ; turn off display |
98 bsf LEDr ; turn on red LED | |
99 bcf pressure_refresh | |
100 ; First pass will not have valid temperature! | |
101 btfss pressure_refresh ; Air pressure compensation | |
0 | 102 bra $-2 |
582 | 103 ; Second pass |
0 | 104 bcf pressure_refresh |
582 | 105 btfss pressure_refresh ; Air pressure compensation |
0 | 106 bra $-2 |
582 | 107 bcf LEDr |
108 | |
0 | 109 clrf rel_pressure+0 |
110 clrf rel_pressure+1 | |
111 clrf surface_interval+0 | |
112 clrf surface_interval+1 | |
113 | |
582 | 114 SAFE_2BYTE_COPY amb_pressure, last_surfpressure |
0 | 115 |
582 | 116 movlw LOW max_surfpressure |
117 movff WREG,sub_a+0 ; max. "allowed" air pressure in mbar | |
118 movlw HIGH max_surfpressure | |
119 movff WREG,sub_a+1 ; max. "allowed" air pressure in mbar | |
0 | 120 movff last_surfpressure+0,sub_b+0 |
121 movff last_surfpressure+1,sub_b+1 | |
582 | 122 call subU16 ; sub_c = sub_a - sub_b |
123 btfss neg_flag ; Is 1080mbar < amb_pressure ? | |
124 bra start_copy_pressure ; NO: current air pressure is lower then "allowed" air pressure, ok! | |
0 | 125 |
582 | 126 ; not ok! Overwrite with max. "allowed" air pressure |
127 movlw LOW max_surfpressure | |
128 movff WREG,last_surfpressure+0 ; max. "allowed" air pressure in mbar | |
129 movlw HIGH max_surfpressure | |
130 movff WREG,last_surfpressure+1 ; max. "allowed" air pressure in mbar | |
0 | 131 |
132 start_copy_pressure: | |
133 movff last_surfpressure+0,last_surfpressure_15min+0 | |
134 movff last_surfpressure+1,last_surfpressure_15min+1 | |
135 movff last_surfpressure+0,last_surfpressure_30min+0 | |
582 | 136 movff last_surfpressure+1,last_surfpressure_30min+1 ; resets all air pressure registers |
560 | 137 |
138 ; initialize GF high (needed by deco engine for color-coding the GF value) | |
139 movff opt_GF_high,char_I_GF_High_percentage | |
140 | |
582 | 141 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; breathing at surface |
142 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; surface pressure | |
143 movff int_I_pres_respiration+1,int_I_pres_surface+1 | |
0 | 144 |
582 | 145 call deco_setup ; set up all model parameters (code located in simulator.asm) |
146 | |
147 call deco_clear_tissue ; Set all tissues to Pamb * N2_ratio (code located in p2_deco.c) | |
148 banksel common ; back to bank 1, needed after every return from C code | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
149 |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
150 call rtc_init ; init clock |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
151 |
582 | 152 movlw HIGH .512 ; =2 |
153 movwf EEADRH | |
154 read_int_eeprom .0 | |
155 clrf EEADRH | |
156 movlw 0xAA | |
157 cpfseq EEDATA ; =0xAA | |
158 bra no_deco_restore ; No | |
159 call restore_decodata_from_eeprom ; Reload deco data and date/time from eeprom | |
160 no_deco_restore: | |
161 call deco_calc_dive_interval_1min ; calculate deco in surface mode | |
162 call deco_calc_desaturation_time ; calculate desaturation and no-fly time | |
163 banksel common | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
164 |
0 | 165 bcf menubit ; clear menu flag |
215 | 166 |
582 | 167 ; Check for Power-on reset here |
168 | |
169 ; ***************************************************************************** | |
215 | 170 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return" |
582 | 171 ; ***************************************************************************** |
0 | 172 |
582 | 173 ; Try to migrate the old battery status from firmware 2.09 or earlier.. |
174 btfsc RCON,POR ; Was this a power-on reset? | |
175 call use_old_prior_209 ; No | |
464
0491a84fd0b8
CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents:
463
diff
changeset
|
176 |
582 | 177 bcf use_old_batt_flag |
178 btfsc RCON,POR ; Was this a power-on reset? | |
179 bsf use_old_batt_flag ; No | |
180 | |
181 call lt2942_get_status ; Check for gauge IC | |
182 btfss battery_gauge_available ; cR or 2 hardware? | |
183 bra power_on_return2 ; no | |
215 | 184 |
582 | 185 movlw .30 |
186 movff WREG,opt_cR_button_right | |
187 movff WREG,opt_cR_button_left ; Reset on power-on reset | |
188 call piezo_config ; Yes, configure buttons | |
189 call piezo_config ; Yes, configure buttons (2 times) | |
0 | 190 |
416
4389fe9673b2
NEW: Support for new logbook memory chip (minor hardware change)
heinrichsweikamp
parents:
410
diff
changeset
|
191 power_on_return2: |
0 | 192 ; check firmware and reset Custom Functions after an update |
193 movlw d'1' | |
582 | 194 movwf EEADR ; =1 |
195 movwf EEADRH ; =1 | |
196 call read_eeprom ; read current version x | |
197 movff EEDATA,lo | |
198 incf EEADR,F ; set to 0x102 | |
199 call read_eeprom ; read current version y | |
200 movff EEDATA,hi | |
201 clrf EEADRH ; Reset EEADRH | |
0 | 202 |
443 | 203 movlw softwareversion_x |
582 | 204 cpfseq lo ; compare version x |
205 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM | |
0 | 206 |
207 movlw softwareversion_y | |
582 | 208 cpfseq hi ; compare version y |
209 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM | |
210 bra restart ; x and y are equal -> do not reset cf | |
211 | |
0 | 212 check_firmware_new: |
582 | 213 call TFT_boot ; Initialize TFT (includes clear screen) |
214 clrf CCPR1L ; Backlight off | |
215 WIN_TOP .50 | |
216 WIN_LEFT .10 | |
217 movlw LOW 0x1E000 | |
218 movwf TBLPTRL | |
219 movlw HIGH 0x1E000 | |
220 movwf TBLPTRH | |
221 movlw UPPER 0x1E000 | |
222 movwf TBLPTRU | |
223 call color_image ; Show logo | |
0 | 224 call TFT_standard_color |
582 | 225 WIN_SMALL .10,.100 |
226 STRCPY_PRINT "Update successful!" ; Hard coded since language switch does not work here | |
227 WIN_SMALL .10,.140 | |
228 STRCPY "New Firmware: " | |
0 | 229 movlw softwareversion_x |
230 movwf lo | |
231 bsf leftbind | |
232 output_8 | |
233 PUTC "." | |
234 movlw softwareversion_y | |
235 movwf lo | |
45 | 236 output_99x |
0 | 237 bcf leftbind |
582 | 238 STRCAT_PRINT "" ; Print second row |
239 call TFT_Display_FadeIn ; Display resulting surface screen. | |
0 | 240 |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
52
diff
changeset
|
241 |
582 | 242 ; place "after-update reset" here... |
243 lfsr FSR0,oPressureAdjust | |
244 call option_reset ; Reset FSR0 option to factory default. | |
245 lfsr FSR0,oPressureAdjust | |
246 call option_save ; Save in EEPROM | |
247 | |
248 rcall backup_flash_page ; backup the first 128 bytes from flash to EEPROM | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
52
diff
changeset
|
249 |
582 | 250 movlw d'1' ; store current version in EEPROM |
251 movwf EEADR ; =1 | |
252 movwf EEADRH ; =1 | |
0 | 253 movlw softwareversion_x |
582 | 254 movwf EEDATA |
255 call write_eeprom ; write version x | |
256 incf EEADR,F ; set to 0x102 | |
0 | 257 movlw softwareversion_y |
582 | 258 movwf EEDATA |
259 call write_eeprom ; write version y | |
260 clrf EEADRH ; Reset EEADRH | |
0 | 261 |
262 movlw .7 | |
263 movwf lo | |
264 check_firmware_new2: | |
265 ; Wait 1 second | |
266 bcf onesecupdate | |
267 btfss onesecupdate | |
268 bra $-2 | |
582 | 269 decfsz lo,F ; Wait 10 seconds... |
0 | 270 bra check_firmware_new2 |
271 | |
582 | 272 global restart |
0 | 273 restart: |
582 | 274 clrf STKPTR ; Never return from here |
275 clrf CCP1CON ; stop PWM | |
276 bcf PORTC,2 ; Pull PWM out to GND | |
276
e4cb495aed3d
Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents:
275
diff
changeset
|
277 |
582 | 278 btfsc menubit ; Return from Menu/COMM mode or timeout? |
279 call option_save_all ; Yes, save all settings into EEPROM | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
16
diff
changeset
|
280 |
582 | 281 call option_restore_all ; Restore everything from EEPROM into RAM |
282 call option_check_all ; Check all options (and reset if not within their min/max boundaries) | |
283 call option_save_all ; Save all settings into EEPROM after they have been checked | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
21
diff
changeset
|
284 |
582 | 285 clrf flag1 ; clear all flags |
286 clrf flag2 | |
287 clrf flag3 | |
288 clrf flag4 | |
289 clrf flag5 | |
290 clrf flag6 | |
291 clrf flag7 | |
292 clrf flag8 | |
293 clrf flag9 | |
294 clrf flag10 | |
295 ; Do not clear flag11 (Sensor calibration and charger status) | |
296 clrf flag12 | |
297 ; Do not clear flag13 (Important hardware flags) | |
298 clrf flag14 | |
299 clrf hardware_flag ; hardware descriptor flag | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
21
diff
changeset
|
300 |
582 | 301 bsf tft_is_dimming ; TFT is dimming up (soon), ignore ambient sensor! |
236 | 302 |
582 | 303 ; configure hardware_flag byte |
304 bsf ambient_sensor ; Set flag | |
305 bsf optical_input ; Set flag | |
306 | |
307 call lt2942_get_status ; Check for gauge IC | |
308 btfss battery_gauge_available ; cR/2 hardware? | |
309 bra restart2 ; No | |
236 | 310 |
582 | 311 call lt2942_init ; Yes, init battery gauge IC |
312 bcf optical_input ; Clear flag | |
236 | 313 |
582 | 314 banksel 0xF16 |
315 bcf ANCON0,7 ; AN7 Digital input | |
316 banksel common | |
317 bcf lightsen_power ; Power-down ambient light sensor | |
318 bcf ambient_sensor ; Clear flag | |
319 nop | |
320 btfss PORTF,2 ; Light sensor available? | |
321 bsf ambient_sensor ; Yes. | |
322 banksel 0xF16 | |
323 bsf ANCON0,7 ; AN7 Analog again | |
324 banksel common | |
325 bsf lightsen_power ; Power-up ambient light sensor again | |
326 | |
243 | 327 restart2: |
582 | 328 btfsc vusb_in |
329 bra restart3 ; USB (and powered on) | |
330 bcf PORTE,0 ; Start comms | |
331 WAITMS d'1' | |
332 btfss vusb_in | |
333 bra restart3 ; USB (and powered off) | |
334 bsf ble_available ; ble available | |
335 | |
336 restart3: | |
337 bsf PORTE,0 ; Stop comms | |
338 btfsc ble_available ; ble available? | |
339 bra restart4 ; Yes, can't be a cR | |
340 btfss battery_gauge_available ; Rechargeable | |
341 bra restart4 ; No, can't be a cR | |
342 bsf analog_o2_input ; Set flag for analog | |
343 | |
344 ; The hardware_flag is now: | |
345 ; 0x11: 2 with BLE | |
346 ; 0x13: 2 with BLE & ambient | |
347 ; 0x05: cR | |
348 ; 0x0A: 3 | |
349 ; 0x1A: 3 with BLE | |
350 | |
249 | 351 restart4: |
0 | 352 ; Select high altitude (Fly) mode? |
353 movff last_surfpressure_30min+0,sub_b+0 | |
354 movff last_surfpressure_30min+1,sub_b+1 | |
582 | 355 movlw HIGH high_altitude_threshold |
0 | 356 movwf sub_a+1 |
582 | 357 movlw LOW high_altitude_threshold ; hard-wired 880mbar |
0 | 358 movwf sub_a+0 |
582 | 359 call subU16 ; sub_c = sub_a - sub_b |
360 btfss neg_flag ; result negative (ambient > 880mbar)? | |
361 bsf high_altitude_mode ; NO - set flag! | |
0 | 362 |
582 | 363 btfss analog_o2_input |
364 bsf TRISB,3 | |
365 btfss battery_gauge_available | |
366 bsf TRISG,0 | |
367 call ext_flash_disable_protection ; disable write protection for external flash | |
464
0491a84fd0b8
CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents:
463
diff
changeset
|
368 |
582 | 369 bsf flip_screen ; flip 180° |
370 TSTOSS opt_flip_screen ; =1: Flip the screen | |
371 bcf flip_screen ; normal orientation | |
372 | |
373 btfsc use_old_batt_flag ; =1: load old battery information after power-on reset | |
374 goto use_old_batteries ; returns to "surfloop"! | |
375 | |
376 btfsc RCON,POR ; was this a power-on reset? | |
377 goto surfloop ; jump to surface loop! | |
378 bsf RCON,POR ; set bit for next detection | |
379 ; Things to do after a power-on reset | |
380 goto do_new_battery_select ; returns to "surfloop"! | |
0 | 381 |
382 ;============================================================================= | |
383 ; Setup all flags and parameters for divemode and simulator computations. | |
384 ; | |
385 global restart_set_modes_and_flags | |
582 | 386 restart_set_modes_and_flags: ; "Call"ed from divemode, as well! |
387 call option_restore_all ; Restore everything from EEPROM | |
24 | 388 |
582 | 389 ; Setup sampling rate |
390 movlw .2 | |
391 movwf samplingrate | |
392 TSTOSS opt_sampling_rate ; =1: 10s, =0: 2s | |
393 bra restart_set_modes_and_flags1 | |
394 movlw .10 | |
395 movwf samplingrate | |
396 | |
24 | 397 restart_set_modes_and_flags1: |
582 | 398 bcf twosecupdate ; to have divemode routines in sync |
399 bcf FLAG_apnoe_mode | |
400 bcf FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | |
401 bcf FLAG_gauge_mode ; =1: In Gauge mode | |
402 bcf FLAG_pscr_mode | |
403 call disable_ir_s8 ; IR off | |
0 | 404 |
582 | 405 ; Setup char_I_saturation_multiplier and char_I_desaturation_multiplier |
406 movff opt_sat_multiplier_gf,char_I_saturation_multiplier | |
407 movff opt_desat_multiplier_gf,char_I_desaturation_multiplier | |
408 movff char_I_deco_model,lo ; 0 = ZH-L16, 1 = ZH-L16-GF | |
409 tstfsz lo | |
410 bra restart_set_modes_and_flags1b | |
411 movff opt_sat_multiplier_non_gf,char_I_saturation_multiplier | |
412 movff opt_desat_multiplier_non_gf,char_I_desaturation_multiplier | |
413 | |
414 restart_set_modes_and_flags1b: | |
415 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | |
416 tstfsz lo | |
417 bra restart_set_modes_and_flags2 | |
418 | |
419 ; OC Mode | |
420 return | |
0 | 421 |
422 restart_set_modes_and_flags2: | |
582 | 423 decfsz lo,F |
424 bra restart_set_modes_and_flags3 | |
425 | |
426 ; CC Mode | |
427 btfsc analog_o2_input ; cR? | |
428 bra restart_set_modes_and_flags2b ; Yes, skip mode check | |
429 btfsc optical_input ; 3 | |
430 bra restart_set_modes_and_flags2b ; Yes, skip mode check | |
431 | |
432 ; Make sure Sensor is not selected | |
433 ; opt_ccr_mode must be <> 1 (=0: Fixed SP, =1: Sensor, =2: Auto SP (CCR only)) | |
434 banksel opt_ccr_mode | |
435 movlw .1 | |
436 cpfseq opt_ccr_mode ; = Sensor? | |
437 bra restart_set_modes_and_flags2b ; No | |
438 clrf opt_ccr_mode ; Yes, reset to Fixed SP | |
439 | |
359 | 440 restart_set_modes_and_flags2b: |
582 | 441 banksel common |
442 bsf FLAG_ccr_mode ; =1: CCR mode (Fixed SP, Auto SP or Sensor) active | |
443 call enable_ir_s8 ; Enable IR/S8-Port | |
444 return | |
0 | 445 |
446 restart_set_modes_and_flags3: | |
582 | 447 decfsz lo,F |
448 bra restart_set_modes_and_flags4 | |
449 | |
450 ; Gauge Mode | |
451 bsf FLAG_gauge_mode ; =1: In Gauge mode | |
452 return | |
0 | 453 |
454 restart_set_modes_and_flags4: | |
582 | 455 decfsz lo,F |
456 bra restart_set_modes_and_flags5 | |
457 ; Apnea Mode | |
458 bsf FLAG_apnoe_mode | |
459 return ; start in Surfacemode | |
0 | 460 |
480
ad8acade5567
NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents:
475
diff
changeset
|
461 restart_set_modes_and_flags5: |
560 | 462 ; PSCR Mode |
463 btfsc analog_o2_input ; cR? | |
464 bra restart_set_modes_and_flags5b ; Yes, skip mode check | |
465 btfsc optical_input ; 3 | |
466 bra restart_set_modes_and_flags5b ; Yes, skip mode check | |
467 | |
468 ; Make sure Sensor is not selected | |
469 ; opt_ccr_mode must be <> 1 (=0: calculated ppO2, =1: Sensor, =2: Auto SP - not valid in pSCR, too) | |
470 banksel opt_ccr_mode | |
471 movlw .1 | |
472 cpfseq opt_ccr_mode ; = Sensor? | |
473 bra restart_set_modes_and_flags5b ; No | |
474 clrf opt_ccr_mode ; Yes, reset to calculated ppO2 | |
475 | |
476 restart_set_modes_and_flags5b: | |
477 banksel opt_ccr_mode | |
478 bcf opt_ccr_mode,1 ; in pSCR mode only calculated or Sensor, not 2 = Auto SP allowed | |
479 banksel common | |
480 bsf FLAG_pscr_mode | |
481 return ; start in Surfacemode | |
482 | |
582 | 483 |
484 ; backup the first 128bytes from flash to EEPROM | |
485 backup_flash_page: | |
486 ; Start address in internal flash | |
487 movlw 0x00 | |
488 movwf TBLPTRL | |
489 movwf TBLPTRH | |
490 movwf TBLPTRU | |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
491 |
582 | 492 movlw .128 |
493 movwf lo ; Byte counter | |
494 clrf EEADR | |
495 movlw .3 | |
496 movwf EEADRH ; Setup backup address | |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
497 |
582 | 498 TBLRD*- ; Dummy read to be in 128 byte block |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
499 backup_flash_loop: |
582 | 500 tblrd+* ; Table Read with Pre-Increment |
501 movff TABLAT,EEDATA ; put 1 byte | |
502 call write_eeprom ; save it in EEPROM | |
503 incf EEADR,F | |
504 decfsz lo,F ; 128byte done? | |
505 bra backup_flash_loop ; No | |
506 clrf EEADRH ; Reset EEADRH | |
507 return ; Done. | |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
508 |
0 | 509 END |