diff code_part1/OSTC_code_asm_part1/surfmode.asm @ 416:3abf9d7dafae

diabling uart module when no USB is attached
author heinrichsweikamp
date Mon, 18 Jul 2011 09:44:25 +0200
parents 6f7965ec5f49
children 38b38b105782
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/surfmode.asm	Sun Jul 17 17:23:25 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/surfmode.asm	Mon Jul 18 09:44:25 2011 +0200
@@ -31,7 +31,6 @@
 	call	PLED_brightness_full			;max. brightness
 	
 	call 	I2CReset
-	call	enable_rs232
 	call	PLED_boot
 	call	PLED_serial						; Show OSTC serial and firmware version
 	call	PLED_clock						; display time
@@ -328,7 +327,12 @@
 
 	bsf		TRISC,1						; CHRG_OUT high impedance
 
-	; Charger inactive or ready
+	; -> Charger inactive or ready
+
+	; Disable when no USB power is attached
+	btfsc	RCSTA,7						; RS232 already disabled
+	call	disable_rs232				; No, disable UART module
+
 	btfss	charge_done					; charge done?
 	bra		test_charger2				; No, add incomplete cycle!
 	
@@ -396,6 +400,9 @@
 	return	
 
 show_cv_active:							; CV mode
+	; Enable only when USB power attached
+	btfss	RCSTA,7						; RS232 already enabled?
+	call	enable_rs232				; No, start UART module
 	bsf		LED_red
 	WAITMS	d'100'
 	bcf		LED_red
@@ -405,6 +412,9 @@
 	return
 
 show_cc_active:							; CC mode
+	; Enable only when USB power attached
+	btfss	RCSTA,7						; RS232 already enabled?
+	call	enable_rs232				; No, start UART module
 	bsf		LED_red
 	bsf		charge_started				; Charger started in CC mode
 	bcf		charge_done					; Charge cycle not finished