changeset 595:16f4eafc197e

CNS for pSCR-GF fixed.
author heinrichsweikamp
date Thu, 21 Jun 2012 07:16:11 +0200
parents 6520bcda1a00
children d7eeaffd8fc1
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/i2c_eeprom.asm code_part1/OSTC_code_asm_part1/start.asm
diffstat 4 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Thu May 31 09:09:47 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Thu Jun 21 07:16:11 2012 +0200
@@ -1,3 +1,7 @@
+New in 2.24:
+BETA Version - Do NOT use for diving!
+BUGFIX: CNS for pSCR-GF
+
 New in 2.23:
 BETA Version - Do NOT use for diving!
 NEW: CF64: Configures color for inactive gases
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Thu May 31 09:09:47 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Thu Jun 21 07:16:11 2012 +0200
@@ -275,19 +275,13 @@
 	call	calc_velocity		; calculate vertical velocity and display if > threshold (every two seconds)
 	
 ; Calculate CNS	
-    rcall   set_actual_ppo2             ; Set char_I_actual_ppO2
     clrf    WREG
     movff   WREG,char_I_step_is_1min    ; Make sure to be in 2sec mode.
 
 	read_int_eeprom d'34'				; Read deco data
-	movlw		.6	
-	cpfseq		EEDATA
-	bra			calc_deko_divemode1a
-	; in PSCR mode
-	call		compute_pscr_ppo2		; pSCR ppO2 into sub_c:2
-;    tstfsz      sub_c+1                 ; Is ppO2 > 2.55bar ? mH
-;    setf        sub_c+0                 ; yes: bound to 2.55... better than wrap around.
-    movff		sub_c+0,char_I_actual_ppO2	; copy last ppO2 to buffer register
+	movlw	.6	
+	cpfseq	EEDATA						; in pscr-mode?
+    rcall   set_actual_ppo2             ; No, set char_I_actual_ppO2
 
 calc_deko_divemode1a:
 	call	deco_calc_CNS_fraction		; calculate CNS
@@ -877,10 +871,19 @@
 	bra			check_ppO2_non_pscr
 	; in PSCR mode
 	call		compute_pscr_ppo2		; pSCR ppO2 into sub_c:2
+    movff		sub_c+0,xA+0
+    movff		sub_c+1,xA+1
+	movlw		d'100'
+	movwf		xB+0
+	clrf		xB+1
+	call		div16x16				; /100
+    tstfsz      xC+1                    ; Is ppO2 > 2.55bar ?
+    setf        xC+0                    ; yes: bound to 2.55... better than wrap around.
+    movff		xC+0,char_I_actual_ppO2	; copy last ppO2 to buffer register (for pSCR CNS)
+	clrf		xC+2
+	clrf		xC+3
 	movff		sub_c+0,xC+0
 	movff		sub_c+1,xC+1			; copy for comptibility
-	clrf		xC+2
-	clrf		xC+3
 	bra			check_ppO2_check
 
 check_ppO2_non_pscr:
--- a/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Thu May 31 09:09:47 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Thu Jun 21 07:16:11 2012 +0200
@@ -322,9 +322,10 @@
 	bra			I2CFail			; timeout occured
 WaitMSSP2:
 	btfss		PIR1,SSPIF
-	bra		WaitMSSP
+	bra			WaitMSSP
 	clrf		i2c_temp
 	bcf			PIR1,SSPIF
+	nop
 	return
 
 I2CReset:						; Something went wrong (Slave holds SDA low?)
--- a/code_part1/OSTC_code_asm_part1/start.asm	Thu May 31 09:09:47 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Thu Jun 21 07:16:11 2012 +0200
@@ -352,7 +352,6 @@
 	GETCUSTOM8	d'33'                   ; GF high
 	movff		EEDATA,char_I_GF_High_percentage
 	return							    ; start in Surfacemode
-
 restart_5_test_pSCR_mode:
 	movlw	d'6'					    ; pSCR-GF
 	cpfseq	EEDATA