# HG changeset patch # User JeanDo # Date 1305845310 -7200 # Node ID 2144f19fa1eb806588b6634239c959c46572daba # Parent ecbbbd423e867f1be2bf840cd6654f0c5f6b6c37 BUGFIX protect against ISR changing pressure/temperature while reading it. diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/MAIN.ASM --- a/code_part1/OSTC_code_asm_part1/MAIN.ASM Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/MAIN.ASM Fri May 20 00:48:30 2011 +0200 @@ -82,6 +82,7 @@ osct_asm code #include strings.inc +#include isr.asm ; Interrupt service routine (RTC&Sensor) #include displaytext.asm ; sends texts to wordprocessor #include math.asm ; mathematical functions #include wait.asm ; waitroutines @@ -102,7 +103,6 @@ #include menu_ppO2.asm ; Constant ppO2 setup menu #include menu_battery.asm ; Submenu "Battery Info" #include menu_gassetup.asm ; Menu "Gas Setup" -#include isr.asm ; Interrupt service routine (RTC&Sensor) #include surfmode.asm ; Mainroutines for Surfacemode #include divemode.asm ; Mainroutines for Divemode #include divemode_menu.asm ; Underwater menu diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/adc_rtc.asm --- a/code_part1/OSTC_code_asm_part1/adc_rtc.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/adc_rtc.asm Fri May 20 00:48:30 2011 +0200 @@ -72,9 +72,9 @@ movwf fatal_error_code ; Battery very low! bsf enter_error_sleep ; enter error routine -get_battery_voltage3: - movff amb_pressure+0,sub_b+0 - movff amb_pressure+1,sub_b+1 +get_battery_voltage3: + SAFE_2BYTE_COPY amb_pressure, sub_b + movlw LOW d'15001' ; must be lower then 15001mBar movwf sub_a+0 movlw HIGH d'15001' @@ -136,9 +136,10 @@ write_int_eeprom d'43' movff year,EEDATA write_int_eeprom d'44' - movff temperature+0,EEDATA + SAFE_2BYTE_COPY temperature,lo + movff lo,EEDATA write_int_eeprom d'45' - movff temperature+1,EEDATA + movff hi,EEDATA write_int_eeprom d'46' ; Reset charge statistics clrf EEDATA @@ -150,9 +151,10 @@ write_int_eeprom d'52' ; total complete cycles write_int_eeprom d'53' ; total complete cycles ; Reset temperature extremas - movff temperature+0,EEDATA ; Reset mimimum extrema + SAFE_2BYTE_COPY temperature,lo + movff lo,EEDATA ; Reset mimimum extrema write_int_eeprom d'54' - movff temperature+1,EEDATA + movff hi,EEDATA write_int_eeprom d'55' movff month,EEDATA write_int_eeprom d'56' @@ -160,9 +162,9 @@ write_int_eeprom d'57' movff year,EEDATA write_int_eeprom d'58' - movff temperature+0,EEDATA ; Reset maximum extrema + movff lo,EEDATA ; Reset maximum extrema write_int_eeprom d'59' - movff temperature+1,EEDATA + movff hi,EEDATA write_int_eeprom d'60' movff month,EEDATA write_int_eeprom d'61' @@ -192,9 +194,10 @@ write_int_eeprom d'43' movff year,EEDATA write_int_eeprom d'44' - movff temperature+0,EEDATA + SAFE_2BYTE_COPY temperature,lo + movff lo,EEDATA write_int_eeprom d'45' - movff temperature+1,EEDATA + movff hi,EEDATA write_int_eeprom d'46' return diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/altimeter.asm --- a/code_part1/OSTC_code_asm_part1/altimeter.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/altimeter.asm Fri May 20 00:48:30 2011 +0200 @@ -55,8 +55,7 @@ clrf pressureSum+1 clrf pressureCount - movff amb_pressure+0,pressureAvg+0 ; And init first average. - movff amb_pressure+1,pressureAvg+1 + SAFE_2BYTE_COPY amb_pressure, pressureAvg ; And init first average. movlw 4 ; And multiply AVG by 16 to be coherent. altimeter_reset_1: @@ -73,9 +72,11 @@ altimeter_1: ;---- Do a bank-safe 16bit summing ----------------------------------- - movff amb_pressure+0,WREG + SAFE_2BYTE_COPY amb_pressure, lo ; And init first average. + + movff lo,WREG addwf pressureSum+0,F - movff amb_pressure+1,WREG + movff hi,WREG addwfc pressureSum+1,F incf pressureCount ; Increment count too. diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/divemode.asm --- a/code_part1/OSTC_code_asm_part1/divemode.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/divemode.asm Fri May 20 00:48:30 2011 +0200 @@ -410,8 +410,7 @@ ;----------------------------------------------------------------------------- ; calculate ppO2 in 0.01Bar (e.g. 150 = 1.50 Bar ppO2) set_actual_ppo2: - movff amb_pressure+0,xA+0 ; P_amb in milibar (1000 = 1.000 bar). - movff amb_pressure+1,xA+1 + SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in milibar (1000 = 1.000 bar). movlw d'10' movwf xB+0 clrf xB+1 @@ -550,8 +549,8 @@ ;----------------------------------------------------------------------------- divemode_prepare_flags_for_deco: - movff amb_pressure+0,int_I_pres_respiration+0 ; lo and copy result to deco routine - movff amb_pressure+1,int_I_pres_respiration+1 ; hi + SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy result to deco routine + GETCUSTOM8 d'11' ; Saturation multiplier % movff WREG,char_I_saturation_multiplier GETCUSTOM8 d'12' ; Desaturation multiplier % @@ -587,9 +586,10 @@ incf_eeprom_address d'47' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 store_dive_data2: - movf rel_pressure+0,W ; store depth with every sample + SAFE_2BYTE_COPY rel_pressure, lo + movf lo,W ; store depth with every sample call write_external_eeprom - movf rel_pressure+1,W + movf hi,W call write_external_eeprom ;First, find out how many bytes will append to this sample.... @@ -804,9 +804,10 @@ return store_dive_temperature: - movf temperature+0,W ; append temperature to current sample! + SAFE_2BYTE_COPY temperature,lo + movf lo,W ; append temperature to current sample! call write_external_eeprom - movf temperature+1,W + movf hi,W call write_external_eeprom GETCUSTOM8 d'21' movwf divisor_temperature ; Reload divisor from CF @@ -817,12 +818,11 @@ bra do_not_display_velocity ; display velocity only in divemode calc_velocity2: - movff amb_pressure+0,sub_a+0 - movff amb_pressure+1,sub_a+1 + SAFE_2BYTE_COPY amb_pressure, sub_a movff last_pressure+0,sub_b+0 movff last_pressure+1,sub_b+1 - movff amb_pressure+0,last_pressure+0 ; store old value for velocity - movff amb_pressure+1,last_pressure+1 + movff sub_a+0,last_pressure+0 ; store old value for velocity + movff sub_a+1,last_pressure+1 call sub16 ; sub_c = amb_pressure - last_pressure @@ -869,8 +869,7 @@ return check_ppO2_bail: ; In CC mode but bailout active! - movff amb_pressure+0,xA+0 - movff amb_pressure+1,xA+1 + SAFE_2BYTE_COPY amb_pressure, xA movlw d'10' movwf xB+0 clrf xB+1 @@ -958,9 +957,8 @@ ; check_gas_change: ; Checks if a better gas should be selected (by user) bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode - - movff rel_pressure+0,xA+0 - movff rel_pressure+1,xA+1 + + SAFE_2BYTE_COPY rel_pressure,xA movlw d'100' movwf xB+0 clrf xB+1 @@ -1439,20 +1437,22 @@ call set_min_temp ; store min. temp if required bcf temp_changed ; Display temperature? - movf temperature+0,W + SAFE_2BYTE_COPY temperature,lo + movf lo,W cpfseq last_temperature+0 bsf temp_changed ; Yes - movf temperature+1,W + movf hi,W cpfseq last_temperature+1 bsf temp_changed ; Yes btfsc temp_changed call PLED_temp_divemode ; Displays temperature bcf pres_changed ; Display new depth? - movf amb_pressure+0,W + SAFE_2BYTE_COPY amb_pressure, lo + movf lo,W cpfseq last_pressure+0 bsf pres_changed ; Yes - movf amb_pressure+1,W + movf hi,W cpfseq last_pressure+1 bsf pres_changed ; Yes @@ -1475,32 +1475,30 @@ set_max_depth: movff max_pressure+0,sub_a+0 movff max_pressure+1,sub_a+1 - movff rel_pressure+0,sub_b+0 - movff rel_pressure+1,sub_b+1 - call sub16 ; sub_c = sub_a - sub_b + SAFE_2BYTE_COPY rel_pressure, sub_b + call sub16 ; sub_c = sub_a - sub_b ; max_pressure neg_flag=1 ; rel_pressure<=max_pressure -> neg_flag=0 btfss neg_flag return ;max_pressure neg_flag=1 ; T<=mintemp -> neg_flag=0 btfsc neg_flag return ;mintemp>=T - movff temperature+0,mintemp+0 - movff temperature+1,mintemp+1 + movff sub_b+0,mintemp+0 + movff sub_b+1,mintemp+1 return set_dive_modes: @@ -1512,8 +1510,7 @@ GETCUSTOM8 .0 ; loads dive_threshold in WREG movwf sub_a+0 ; dive_treshold is in cm clrf sub_a+1 - movff rel_pressure+0,sub_b+0 - movff rel_pressure+1,sub_b+1 + SAFE_2BYTE_COPY rel_pressure, sub_b call sub16 ; sub_c = sub_a - sub_b btfss neg_flag @@ -1536,8 +1533,7 @@ movwf sub_a+1 movlw LOW d'1075' ; hard-wired 1075mBar threshold movwf sub_a+0 - movff rel_pressure+0,sub_b+0 - movff rel_pressure+1,sub_b+1 + SAFE_2BYTE_COPY rel_pressure, sub_b call sub16 ; sub_c = sub_a - sub_b btfss neg_flag @@ -1575,8 +1571,7 @@ rcall reset_average1 ; Reset the resettable average depth ; 1. Add new 2xdepth to the Sum of depths registers - movff rel_pressure+0,b0_lo - movff rel_pressure+1,b0_hi ; Buffer... + SAFE_2BYTE_COPY rel_pressure, b0_lo ; Buffer... movf b0_lo,w addwf average_depth_hold+0,F @@ -1731,8 +1726,7 @@ movff WREG,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine diveloop_boot_2: - movff temperature+0,mintemp+0 ; Reset Min-Temp registers - movff temperature+1,mintemp+1 ; Reset Min-Temp registers + SAFE_2BYTE_COPY temperature,mintemp ; Reset Min-Temp registers ; Init profile recording parameters GETCUSTOM8 d'20' ; sample rate diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/isr.asm --- a/code_part1/OSTC_code_asm_part1/isr.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/isr.asm Fri May 20 00:48:30 2011 +0200 @@ -28,7 +28,24 @@ ; and provides accurate pressure (+/-1mBar stable) and temperature (0.1C stable) ;============================================================================= +; Copy a 16bit value from ISR modified registers to main registers. +; +; Because the ISR can happend at any time, the read should be redone if bytes +; changed inbetween. +; +; NOTE: Destination might be in any bank, so be BANK SAFE on b +SAFE_2BYTE_COPY MACRO a, b + local retry +retry: + movf a+1,W ; High byte in W, (CURRENT BANK ONLY) + movff WREG,b+1 ; and destination. + movff a,b ; Copy low byte. + xorwf a+1,W ; High byte changed ??? (CURRENT BANK ONLY) + bnz retry + ENDM + +;============================================================================= uartint: btfsc simulatormode_active ; are we in simulatormode? bra simulator_int ; Yes, reading is depth in m! @@ -179,6 +196,10 @@ ; is done on private variables, to avoid trashing data while reading it ; from the main code. ; +; NOTE: Because there is no atomic 16bits load/stores, we need to check twice +; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get +; amb_pressure, temperaturen or rel_pressure +; sensor_int: btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep) return diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/menu_reset.asm --- a/code_part1/OSTC_code_asm_part1/menu_reset.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm Fri May 20 00:48:30 2011 +0200 @@ -284,8 +284,7 @@ ; reset deco data call PLED_ClearScreen DISPLAYTEXT .25 ; "Reset..." - movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine - movff amb_pressure+1,int_I_pres_respiration+1 + SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine call deco_clear_tissue movlb b'00000001' ; RAM Bank1 selected goto restart ; done. quit to surfmode @@ -303,8 +302,7 @@ reset_start: ; reset deco data - movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine - movff amb_pressure+1,int_I_pres_respiration+1 + SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine call deco_clear_tissue movlb b'00000001' ; RAM Bank1 selected diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/ms5535.asm --- a/code_part1/OSTC_code_asm_part1/ms5535.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/ms5535.asm Fri May 20 00:48:30 2011 +0200 @@ -20,6 +20,9 @@ ; 2005-09-26: Written by Matthias Heinrichs, info@heinrichsweikamp.com ; 2008-08-21: MH last updated, with second order compensation. ; 2011-01-19: jDG Clean up using true signed arithmetics. +; 2011-05-19: jDG Avegaring temperature and amb_pressure in private variable, +; Use signed 16bit value for temperature (compat with avg !). +; ; known bugs: ; ToDo: diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/pled_outputs.asm --- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm Fri May 20 00:48:30 2011 +0200 @@ -105,8 +105,7 @@ PLED_color_code_gaslist: ; %O2 in "EEDATA" ; Check very high ppO2 manually - movff amb_pressure+0,xA+0 - movff amb_pressure+1,xA+1 + SAFE_2BYTE_COPY amb_pressure,xA movlw d'10' movwf xB+0 clrf xB+1 @@ -143,8 +142,7 @@ cpfseq lo ; =1? bra PLED_color_code_ceiling1 ; No, Set to default color - movff rel_pressure+1,hi - movff rel_pressure+0,lo + SAFE_2BYTE_COPY rel_pressure, lo call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] movff hi,xA+1 movff lo,xA+0 @@ -168,8 +166,7 @@ PLED_color_code_depth: movff hi,hi_temp movff lo,lo_temp - movff rel_pressure+1,hi - movff rel_pressure+0,lo + SAFE_2BYTE_COPY rel_pressure, lo call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] movff lo,sub_a+0 movff hi,sub_a+1 @@ -839,15 +836,13 @@ WIN_LEFT .0 WIN_TOP .177 STRCPY "amb:" - movff amb_pressure+0,lo - movff amb_pressure+1,hi + SAFE_2BYTE_COPY amb_pressure, lo output_16 call word_processor WIN_LEFT .80 WIN_TOP .177 STRCPY "temp:" - movff temperature+0,lo - movff temperature+1,hi + SAFE_2BYTE_COPY temperature, lo output_16 call word_processor @@ -948,16 +943,15 @@ PLED_temp_surfmode: ostc_debug 'e' - movff temperature+0,last_temperature+0 - movff temperature+1,last_temperature+1 + SAFE_2BYTE_COPY temperature, last_temperature WIN_TOP .100 WIN_LEFT .1 WIN_FONT FT_SMALL WIN_INVERT .0 ; Init new Wordprocessor call PLED_standard_color - movff temperature+1,hi - movff temperature+0,lo + movff last_temperature+1,hi + movff last_temperature+0,lo lfsr FSR2,letter btfss hi,7 ; Negative temperature ? @@ -983,8 +977,7 @@ ostc_debug 'u' ; Sends debug-information to screen if debugmode active ; temperature - movff temperature+0,last_temperature+0 - movff temperature+1,last_temperature+1 + SAFE_2BYTE_COPY temperature, last_temperature WIN_TOP .216 WIN_LEFT .50 @@ -992,8 +985,9 @@ WIN_INVERT .0 ; Init new Wordprocessor call PLED_standard_color - movff temperature+1,hi - movff temperature+0,lo + movff last_temperature+1,hi + movff last_temperature+0,lo + lfsr FSR2,letter btfss hi,7 ; Negative temperature ? @@ -1564,8 +1558,7 @@ PLED_depth: ostc_debug 'r' ; Sends debug-information to screen if debugmode active - movff rel_pressure+1,hi - movff rel_pressure+0,lo + SAFE_2BYTE_COPY rel_pressure, lo call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] movlw .039 @@ -1625,8 +1618,7 @@ WIN_LEFT .40 PLED_color_code warn_depth ; Color-code the output - movff rel_pressure+1,hi - movff rel_pressure+0,lo + SAFE_2BYTE_COPY rel_pressure, lo call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] STRCPY "." @@ -1777,8 +1769,7 @@ call PLED_warnings_color ; Yes, display ambient pressure in red lfsr FSR2,letter - movff amb_pressure+0,lo - movff amb_pressure+1,hi + SAFE_2BYTE_COPY amb_pressure, lo bsf leftbind output_16 bcf leftbind @@ -2998,8 +2989,8 @@ PLED_const_ppO2_value2: ; Display SetPoint ;Show fixed SP value - movff amb_pressure+0,xA+0 - movff amb_pressure+1,xA+1 + SAFE_2BYTE_COPY amb_pressure, xA + movlw d'10' movwf xB+0 clrf xB+1 @@ -3019,8 +3010,7 @@ PLED_const_ppO2_value1: ; char_I_const_ppO2 < ppO2[Diluent] -> Not physically possible! -> Display actual value! - movff amb_pressure+0,xA+0 - movff amb_pressure+1,xA+1 + SAFE_2BYTE_COPY amb_pressure, xA movlw d'10' movwf xB+0 clrf xB+1 diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/simulator.asm --- a/code_part1/OSTC_code_asm_part1/simulator.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/simulator.asm Fri May 20 00:48:30 2011 +0200 @@ -132,8 +132,9 @@ movff xC+0,sim_pressure+0 movff xC+1,sim_pressure+1 - - movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values + + ; This override is done in ISR too, but do it right now also: + movff sim_pressure+0,amb_pressure+0 movff sim_pressure+1,amb_pressure+1 bcf menubit2 @@ -345,7 +346,8 @@ DISPLAYTEXT .12 ; "Wait..." WIN_INVERT .0 - movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values + ; This override is done in ISR too, but do it right now also: + movff sim_pressure+0,amb_pressure+0 movff sim_pressure+1,amb_pressure+1 call divemode_check_decogases ; Checks for decogases and sets the gases diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/sleepmode.asm --- a/code_part1/OSTC_code_asm_part1/sleepmode.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/sleepmode.asm Fri May 20 00:48:30 2011 +0200 @@ -78,8 +78,7 @@ movlb b'00000001' movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure - movff amb_pressure+0,last_surfpressure_15min+0 ; save new airpressure - movff amb_pressure+1,last_surfpressure_15min+1 ; save new airpressure + SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure clrf divemins+1 ; reset counter GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi @@ -98,8 +97,7 @@ onemin_sleep2: ;calc_deko_sleepmode: - movff amb_pressure+0,int_I_pres_respiration+0 ; LOW copy pressure to deco routine - movff amb_pressure+1,int_I_pres_respiration+1 ; HIGH + SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine GETCUSTOM8 d'11' ; Saturation multiplier % movff WREG,char_I_saturation_multiplier GETCUSTOM8 d'12' ; Desaturation multiplier % @@ -134,8 +132,7 @@ GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi movff lo,sub_a+0 ; power on if ambient pressure is greater threshold movff hi,sub_a+1 - movff amb_pressure+0,sub_b+0 - movff amb_pressure+1,sub_b+1 + SAFE_2BYTE_COPY amb_pressure, sub_b call sub16 ; sub_c = sub_a - sub_b bsf sleepmode btfsc neg_flag ; Wake up from Sleep? diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/start.asm --- a/code_part1/OSTC_code_asm_part1/start.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/start.asm Fri May 20 00:48:30 2011 +0200 @@ -67,12 +67,11 @@ call pressuretest_sleep_fast ; Gets pressure without averaging (faster!) bcf sleepmode ; Normal mode again - movff amb_pressure+0,last_surfpressure+0 - movff amb_pressure+1,last_surfpressure+1 - movff amb_pressure+0,last_surfpressure_15min+0 - movff amb_pressure+1,last_surfpressure_15min+1 - movff amb_pressure+0,last_surfpressure_30min+0 - movff amb_pressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers + SAFE_2BYTE_COPY amb_pressure, last_surfpressure + movff last_surfpressure+0,last_surfpressure_15min+0 + movff last_surfpressure+1,last_surfpressure_15min+1 + movff last_surfpressure+0,last_surfpressure_30min+0 + movff last_surfpressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers ; Extra power-up reset (JeanDo) ifdef TESTING @@ -91,10 +90,9 @@ movff WREG,char_I_saturation_multiplier GETCUSTOM8 d'12' ; Desaturation multiplier % movff WREG,char_I_desaturation_multiplier - movff amb_pressure+0,int_I_pres_respiration+0 ; copy for deco routine - movff amb_pressure+1,int_I_pres_respiration+1 - movff amb_pressure+0,int_I_pres_surface+0 ; copy for desat routine - movff amb_pressure+1,int_I_pres_surface+1 + SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy for deco routine + movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine + movff int_I_pres_respiration+1,int_I_pres_surface+1 call deco_clear_tissue ; call deco_calc_desaturation_time ; calculate desaturation time diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/surfmode.asm --- a/code_part1/OSTC_code_asm_part1/surfmode.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/surfmode.asm Fri May 20 00:48:30 2011 +0200 @@ -281,8 +281,7 @@ movwf wait_temp ; Use as buffer movff wait_temp,char_I_N2_ratio ; No He at the Surface - movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine - movff amb_pressure+1,int_I_pres_respiration+1 + SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine GETCUSTOM8 d'11' ; Saturation multiplier % movff WREG,char_I_saturation_multiplier GETCUSTOM8 d'12' ; Desaturation multiplier % diff -r ecbbbd423e86 -r 2144f19fa1eb code_part1/OSTC_code_asm_part1/temp_extrema.asm --- a/code_part1/OSTC_code_asm_part1/temp_extrema.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/temp_extrema.asm Fri May 20 00:48:30 2011 +0200 @@ -28,15 +28,14 @@ movff EEDATA,sub_b+0 read_int_eeprom d'55' movff EEDATA,sub_b+1 - movff temperature+0,sub_a+0 - movff temperature+1,sub_a+1 + SAFE_2BYTE_COPY temperature,sub_a call sub16 ; sub_c = sub_a - sub_b btfss neg_flag ; new lowest temperature ? bra check_temp_extrema_high ; Yes, store new value together with the date - movff temperature+0,EEDATA + movff sub_a+0,EEDATA write_int_eeprom d'54' - movff temperature+1,EEDATA + movff sub_a+1,EEDATA write_int_eeprom d'55' movff month,EEDATA write_int_eeprom d'56' @@ -44,21 +43,22 @@ write_int_eeprom d'57' movff year,EEDATA write_int_eeprom d'58' + ; Now check high extrema check_temp_extrema_high: read_int_eeprom d'59' ; get highest temperature so far movff EEDATA,sub_b+0 read_int_eeprom d'60' movff EEDATA,sub_b+1 - movff temperature+0,sub_a+0 - movff temperature+1,sub_a+1 + SAFE_2BYTE_COPY temperature,sub_a call sub16 ; sub_c = sub_a - sub_b btfsc neg_flag ; new highest temperature ? return ; no, quit! + ; Yes, store new value together with the date - movff temperature+0,EEDATA + movff sub_a+0,EEDATA write_int_eeprom d'59' - movff temperature+1,EEDATA + movff sub_a+1,EEDATA write_int_eeprom d'60' movff month,EEDATA write_int_eeprom d'61'