diff code_part1/OSTC_code_asm_part1/interface.asm @ 351:5c186a72cb5d 64kByte Logbook

Debugging the new logbook format, 64kB download routine
author heinrichsweikamp
date Tue, 31 May 2011 22:09:17 +0200
parents 7250ca7c8d24
children ed26990716fe
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/interface.asm	Tue May 31 19:43:29 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/interface.asm	Tue May 31 22:09:17 2011 +0200
@@ -167,14 +167,16 @@
 
 	DISPLAYTEXT .18						; "Header"
 
-	clrf		uart1_temp					; low address counter
-	clrf		uart2_temp					; high address counter
+	setf		uart1_temp					; low address counter
+	setf		uart2_temp					; high address counter
 
 menu_interface3:
 	bsf		SSPCON2,SEN					; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100110'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	btfsc		SSPCON2,ACKSTAT
@@ -189,7 +191,10 @@
 	bsf		SSPCON2,RSEN				; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100111'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101111'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100111'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	call		I2C_WaitforACK
@@ -199,78 +204,20 @@
 menu_interface2:
 	call		rs232_wait_tx				; wait for UART
 
-	bsf			SSPCON2, RCEN				; Enable recieve mode
-	call		WaitMSSP	
-
-	movff		SSPBUF, TXREG
-
 	movlw		d'1'
 	addwf		uart1_temp,F
 	movlw		d'0'
 	addwfc		uart2_temp,F
 
-	btfsc		uart2_temp,7				; 32KB done?
-	bra			menu_interface4				; Yes
-	
-	bsf			SSPCON2, ACKEN				; Ack
-	call		WaitMSSP	
-	bra			menu_interface2				; go on
-
-menu_interface4:
-	bsf			SSPCON2, PEN				; Stop
-	call		WaitMSSP	
-
-
-	clrf		uart1_temp					; low address counter
-	clrf		uart2_temp					; high address counter
-
-menu_interface5:		;Send another 32kB from Block2....
-	bsf		SSPCON2,SEN					; Start condition
-	call		WaitMSSP
-
-	movlw		b'10101110'					; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF					; control byte
-	call		WaitMSSP	
-	btfsc		SSPCON2,ACKSTAT
-	bra		menu_interface5				; No Ack, try again!
-	
-	movff		eeprom_address+1,SSPBUF			; High Address byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-	movff		eeprom_address+0,SSPBUF			; Low Address byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-	bsf		SSPCON2,RSEN				; Start condition
-	call		WaitMSSP
-
-	movlw		b'10101111'					; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF					; control byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-
-menu_interface6:
-	call		rs232_wait_tx				; wait for UART
-
-	bsf			SSPCON2, RCEN				; Enable recieve mode
-	call		WaitMSSP	
-
+; Slow but safe...
+	call		I2CREAD2					; same as I2CREAD but with automatic address increase 
 	movff		SSPBUF, TXREG
 
-	movlw		d'1'
-	addwf		uart1_temp,F
-	movlw		d'0'
-	addwfc		uart2_temp,F
-
-	btfsc		uart2_temp,7				; 32KB done?
-	bra			menu_interface7				; Yes
-	
-	bsf			SSPCON2, ACKEN				; Ack
-	call		WaitMSSP	
-	bra			menu_interface6				; go on
-
-menu_interface7:
-	bsf			SSPCON2, PEN				; Stop
-	call		WaitMSSP	
+	movlw		0xFF
+	cpfseq		uart2_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
+	cpfseq		uart1_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
 
 	DISPLAYTEXT	.20						; Done.