changeset 81:31fa973a70fd

Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
author JeanDo
date Mon, 06 Dec 2010 18:05:39 +0100
parents d2d7cb96100d
children bc3092c41335
files code_part1/OSTC_code_asm_part1/adc_rtc.asm code_part1/OSTC_code_asm_part1/i2c_eeprom.asm code_part1/OSTC_code_asm_part1/ms5535.asm code_part1/OSTC_code_asm_part1/oled_samsung.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm
diffstat 5 files changed, 61 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/adc_rtc.asm	Tue Dec 07 21:29:46 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/adc_rtc.asm	Mon Dec 06 18:05:39 2010 +0100
@@ -23,12 +23,19 @@
 ; ToDo: 
 
 get_battery_voltage:			; starts ADC and waits until fnished
+  ; In MPLAB Sim mode (hardware emulation), use a DMCI slider to
+  ; directly set a 16 bit value in the range 0..1023
+  ; In normal mode, jut wait for the value to be ready:
+
+  ifndef TESTING
 	bsf		ADCON0,0			; power on ADC
 	nop
 	bsf		ADCON0,1			; start ADC
+	
 get_battery_voltage2:
 	btfsc	ADCON0,1			; Wait...
 	bra		get_battery_voltage2
+  endif
 
 ; 3.3V/1024=3,2227mV Input/Bit=9,6680mV Battery/Bit. 
 ; Example: 434*9,6680mV=4195,9mV Battery. 
--- a/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Tue Dec 07 21:29:46 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Mon Dec 06 18:05:39 2010 +0100
@@ -70,6 +70,11 @@
 write_external_eeprom:				; data in WREG
 								; increase address eeprom_address+0:eeprom_address+1 after write
 								; with banking after 7FFF
+#ifdef TESTING
+	; When Simulating with MPLabSIM, there is no way to emulate external EEPROM...
+	return
+#endif
+
 	rcall		I2CWRITE			; writes WREG into EEPROM@eeprom_address
 	movlw		d'1'				; increase address
 	addwf		eeprom_address+0,F
@@ -84,6 +89,11 @@
 	bsf			eeprom_overflow			; and set overflow bit
 	return
 write_external_eeprom_block:			; Writes a block of 64Byte (one page in external EEPROM without stop condition
+#ifdef TESTING
+	; When Simulating with MPLabSIM, there is no way to emulate external EEPROM...
+	return
+#endif
+
 	btfsc		eeprom_blockwrite		; Blockwrite continue?
 	rcall		I2CWRITE_BLOCK2
 	btfss		eeprom_blockwrite		; Blockwrite start?
@@ -124,6 +134,15 @@
 
 
 get_free_EEPROM_location:			; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE
+
+#ifdef TESTING
+	; In testing mode, find 0x100 (internal EEPROM) as the first free location...
+	clrf 		eeprom_address+0		; Not found in entire EEPROM, set to address 0
+	movlw		0x1
+	movwf 		eeprom_address+1
+	return
+#endif
+
 	clrf		ext_ee_temp1		; low address counter
 	clrf		ext_ee_temp2		; high address counter
 	bcf			second_FD			; clear flags
--- a/code_part1/OSTC_code_asm_part1/ms5535.asm	Tue Dec 07 21:29:46 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/ms5535.asm	Mon Dec 06 18:05:39 2010 +0100
@@ -261,9 +261,12 @@
 	return
 
 get_pressure_value:
+#ifndef TESTING
+	; Use register injection instead when in MPLab Sim emulation...
 	rcall	get_2bytes_MS5535A
 	movff	dMSB,D1+1	
 	movff	dLSB,D1+0
+#endif
 	return
 
 get_temperature_start:
@@ -272,9 +275,12 @@
 	bra		get_pressure_start2	; continue in "get_pressure"
 
 get_temperature_value:
+#ifndef TESTING
+	; Use register injection instead...
 	rcall	get_2bytes_MS5535A
 	movff	dMSB,D2+1
 	movff	dLSB,D2+0
+#endif
 	return
 
 get_calibration_data:
@@ -291,6 +297,28 @@
 ;	cpfsgt	EEDATA						; EEDATA>200?
 ;	movff	EEDATA, temperature_correction	; No, Store for compensation
 ;	
+  ifdef TESTING
+    ; Get example calibration values (Intersema 5535B datasheet, p12).
+    movlw   LOW  .18556
+    movwf   W1+0
+    movlw   HIGH .18556
+    movwf   W1+1
+    
+    movlw   LOW  .49183
+    movwf   W1+0
+    movlw   HIGH .49183
+    movwf   W1+1
+    
+    movlw   LOW  .22354
+    movwf   W1+0
+    movlw   HIGH .22354
+    movwf   W1+1
+
+    movlw   LOW  .28083
+    movwf   W1+0
+    movlw   HIGH .28083
+    movwf   W1+1
+  else
 	rcall	reset_MS5535A
 	movlw	d'13'
 	movwf	clock_count
@@ -327,6 +355,7 @@
 	rcall	get_2bytes_MS5535A
 	movff	dMSB,W4+1	
 	movff	dLSB,W4+0
+  endif
 
 ; calculate C1 (16Bit)
 	movff	W1+1, C1+1
--- a/code_part1/OSTC_code_asm_part1/oled_samsung.asm	Tue Dec 07 21:29:46 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/oled_samsung.asm	Mon Dec 06 18:05:39 2010 +0100
@@ -396,8 +396,6 @@
 
 	bsf		oled_rs					; Data!
 
-	clrf	PORTD					; See Page 101 of OLED Driver IC Datasheet
-	
 	movlw	d'10'
 	movwf	draw_box_temp3
 PLED_ClearScreen2:
@@ -407,8 +405,11 @@
 	clrf	draw_box_temp1				; 30*10*256=76800 Pixels -> Clear complete 240*320
 PLED_ClearScreen4:
 
+	clrf	PORTD					; Need to generate trace here too.
 	bcf		oled_rw
 	bsf		oled_rw					; Upper
+
+    clrf	PORTD					; Need to generate trace here too.
 	bcf		oled_rw
 	bsf		oled_rw					; Lower
 
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Tue Dec 07 21:29:46 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Mon Dec 06 18:05:39 2010 +0100
@@ -1500,11 +1500,11 @@
 PLED_active_gas_surfmode4:
 	lfsr	FSR2,letter
 	bsf		leftbind			; left orientated output
-	output_8					; O2 ratio is still in "lo"
+	output_99					; O2 ratio is still in "lo"
 	movlw	'/'
 	movwf	POSTINC2
 	movff	char_I_He_ratio,lo		; copy He ratio into lo
-	output_8
+	output_99
 	bcf		leftbind
 	call	word_processor
 	bra		PLED_active_gas_surfmode_exit
@@ -2660,7 +2660,7 @@
 	lfsr	FSR1,0x0E1						; Gf_decolist_copy
 	movf	temp5,W							; number of entry
 	movff	PLUSW1,lo						; Stop length
-incf	lo,F							; add one dummy minute
+	incf	lo,F							; add one dummy minute
 	lfsr	FSR2,letter	
 	output_99x								; outputs into Postinc2!
 	movlw	d'39'							;"'"