comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 592:cda5b45b953f

NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
author heinrichsweikamp
date Mon, 28 May 2012 17:54:43 +0200
parents e3ffc6d62a63
children 46e9ccd0eca7
comparison
equal deleted inserted replaced
591:2966548fbe70 592:cda5b45b953f
277 ; Calculate CNS 277 ; Calculate CNS
278 rcall set_actual_ppo2 ; Set char_I_actual_ppO2 278 rcall set_actual_ppo2 ; Set char_I_actual_ppO2
279 clrf WREG 279 clrf WREG
280 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode. 280 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode.
281 281
282 read_int_eeprom d'34' ; Read deco data
283 movlw .6
284 cpfseq EEDATA
285 bra calc_deko_divemode1a
286 ; in PSCR mode
287 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2
288 ; tstfsz sub_c+1 ; Is ppO2 > 2.55bar ?
289 ; setf sub_c+0 ; yes: bound to 2.55... better than wrap around.
290 movff sub_c+0,char_I_actual_ppO2 ; copy last ppO2 to buffer register
291
292 calc_deko_divemode1a:
282 call deco_calc_CNS_fraction ; calculate CNS 293 call deco_calc_CNS_fraction ; calculate CNS
283 movlb b'00000001' ; rambank 1 selected 294 movlb b'00000001' ; rambank 1 selected
284 295
285 ; Check if CNS should be displayed 296 ; Check if CNS should be displayed
286 movff char_O_CNS_fraction,lo ; copy into bank1 297 movff char_O_CNS_fraction,lo ; copy into bank1
370 return 381 return
371 382
372 ;----------------------------------------------------------------------------- 383 ;-----------------------------------------------------------------------------
373 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2) 384 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2)
374 set_actual_ppo2: 385 set_actual_ppo2:
375 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in milibar (1000 = 1.000 bar). 386 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in millibar (1000 = 1.00 bar).
376 movlw d'10' 387 movlw d'10'
377 movwf xB+0 388 movwf xB+0
378 clrf xB+1 389 clrf xB+1
379 call div16x16 ; xC=p_amb/10 (100 = 1.00 bar). 390 call div16x16 ; xC=p_amb/10 (100 = 1.00 bar).
380 movff xC+0,xA+0 391 movff xC+0,xA+0
424 435
425 call divemode_prepare_flags_for_deco 436 call divemode_prepare_flags_for_deco
426 clrf WREG 437 clrf WREG
427 movff WREG,char_I_step_is_1min ; Force 2 second deco mode 438 movff WREG,char_I_step_is_1min ; Force 2 second deco mode
428 439
440 movff char_I_O2_ratio,lo_temp ; Backup original value for everything
441 movff char_I_N2_ratio,hi_temp ; Backup original value for everything
442
443 read_int_eeprom d'34' ; Read deco data
444 movlw .6
445 cpfseq EEDATA
446 bra calc_deko_divemode2a
447 ; in PSCR mode, compute fO2 into char_I_O2_ratio
448 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2
449 movff sub_c+0,xA+0
450 movff sub_c+1,xA+1
451 movlw LOW .10
452 movwf xB+0
453 movlw HIGH .10
454 movwf xB+1
455 call mult16x16 ;xA*xB=xC -> xC:4 = ppO2*10
456 SAFE_2BYTE_COPY amb_pressure, xB
457 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
458 ; xC+0 has O2 in percent
459 movff xC+0,char_I_O2_ratio
460
461 movff char_I_He_ratio, wait_temp ; copy into bank1 register
462 bsf STATUS,C ; Borrow bit
463 movlw d'100' ; 100%
464 subfwb wait_temp,W ; minus He
465 bsf STATUS,C ; Borrow bit
466 subfwb xC+0,W ; minus O2
467 movff WREG, char_I_N2_ratio ; = N2!
468
469 calc_deko_divemode2a:
470
429 clrf TMR3L 471 clrf TMR3L
430 nop ; See errata DS80284E-page 2 472 nop ; See errata DS80284E-page 2
431 clrf TMR3H ; Reset Timer3 473 clrf TMR3H ; Reset Timer3
432 474
433 call deco_calc_hauptroutine ; calc_tissue 475 call deco_calc_hauptroutine ; calc_tissue
434 movlb b'00000001' ; rambank 1 selected 476 movlb b'00000001' ; rambank 1 selected
435 ostc_debug 'C' ; Sends debug-information to screen if debugmode active 477 ostc_debug 'C' ; Sends debug-information to screen if debugmode active
478
479 movff lo_temp,char_I_O2_ratio ; Restore original value for everything
480 movff hi_temp,char_I_N2_ratio ; Restore original value for everything
436 481
437 btfss debug_mode ; Are we in debugmode? 482 btfss debug_mode ; Are we in debugmode?
438 bra calc_deko_divemode4 ; No... 483 bra calc_deko_divemode4 ; No...
439 484
440 ; Show timer3 reading converted into ms (Error: +2,3%) in custom area 485 ; Show timer3 reading converted into ms (Error: +2,3%) in custom area
824 check_ppO2: ; check current ppO2 and display warning if required 869 check_ppO2: ; check current ppO2 and display warning if required
825 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode.... 870 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode....
826 return 871 return
827 872
828 check_ppO2_bail: ; In CC mode but bailout active! 873 check_ppO2_bail: ; In CC mode but bailout active!
874 read_int_eeprom d'34' ; Read deco data
875 movlw .6
876 cpfseq EEDATA
877 bra check_ppO2_non_pscr
878 ; in PSCR mode
879 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2
880 movff sub_c+0,xC+0
881 movff sub_c+1,xC+1 ; copy for comptibility
882 clrf xC+2
883 clrf xC+3
884 bra check_ppO2_check
885
886 check_ppO2_non_pscr:
829 SAFE_2BYTE_COPY amb_pressure, xA 887 SAFE_2BYTE_COPY amb_pressure, xA
830 movlw d'10' 888 movlw d'10'
831 movwf xB+0 889 movwf xB+0
832 clrf xB+1 890 clrf xB+1
833 call div16x16 ; xC=p_amb/10 891 call div16x16 ; xC=p_amb/10
834 movff xC+0,xA+0 892 movff xC+0,xA+0
835 movff xC+1,xA+1 893 movff xC+1,xA+1
836 movff char_I_O2_ratio,xB+0 894 movff char_I_O2_ratio,xB+0
837 clrf xB+1 895 clrf xB+1
838 call mult16x16 ; char_I_O2_ratio * p_amb/10 896 call mult16x16 ; char_I_O2_ratio * p_amb/10 -> xC:4
839 897 ; bra check_ppO2_check
898 check_ppO2_check:
840 ; Check very high ppO2 manually 899 ; Check very high ppO2 manually
841 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? 900 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
842 bra check_ppO2_bail2 ; Yes, display Value! 901 bra check_ppO2_bail2 ; Yes, display Value!
843 902
844 ; Check if ppO2 should be displayed 903 ; Check if ppO2 should be displayed