Mercurial > public > mk2
changeset 350:7250ca7c8d24 64kByte Logbook
64kByte logbook (Still incompatible to existing PC software)
author | heinrichsweikamp |
---|---|
date | Tue, 31 May 2011 19:43:29 +0200 |
parents | ed137d66ac65 |
children | 5c186a72cb5d |
files | code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/i2c_eeprom.asm code_part1/OSTC_code_asm_part1/interface.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm code_part1/OSTC_code_asm_part1/menu_reset.asm |
diffstat | 5 files changed, 138 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm Mon May 30 19:28:59 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/definitions.asm Tue May 31 19:43:29 2011 +0200 @@ -425,7 +425,7 @@ #DEFINE second_FD flag4,7 ; 2nd 0xFD in EEPROM found #DEFINE second_FA flag4,7 ; 2nd 0xFA in EEPROM found -#DEfINE eeprom_overflow flag5,0 ; EEPROM overflowed (>32KB) +;#DEfINE unused flag5,0 ; unused #DEFINE eeprom_blockwrite flag5,1 ; EEPROM blockwrite active #DEFINE Flag_4 flag5,2 ; unused #DEFINE low_battery_state flag5,3 ;=1 if battery low
--- a/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm Mon May 30 19:28:59 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm Tue May 31 19:43:29 2011 +0200 @@ -18,8 +18,8 @@ ; known bugs: ; ToDo: use 2nd 32KB from external EEPROM for something -incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes - movlw ext_ee_temp1 ; care of bank switching at 0x8000 +incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" + movlw ext_ee_temp1 call incf_eeprom_address0 endm @@ -27,18 +27,18 @@ addwf eeprom_address+0,F ; increase address movlw d'0' addwfc eeprom_address+1,F + return +; btfss eeprom_address+1,7 ; at address 8000? +; return ; No, continue +; +; ; Yes, clear eeprom_address:2 +; clrf eeprom_address+0 ; Clear eeprom address +; clrf eeprom_address+1 +; return ; Done. +; +;============================================================================= +; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1" - btfss eeprom_address+1,7 ; at address 8000? - return ; No, continue - - ; Yes, clear eeprom_address:2 - clrf eeprom_address+0 ; Clear eeprom address - clrf eeprom_address+1 - return ; Done. - -;============================================================================= -; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes -; care of bank switching at 0x8000 decf_eeprom_address macro ext_ee_temp1 movlw ext_ee_temp1 @@ -49,13 +49,14 @@ subwf eeprom_address+0,F ; decrease address: do a 16-8bits substract. movlw d'0' subwfb eeprom_address+1,F - - btfss eeprom_address+1,7 ; at address 8000? - return ; No, done. - - movlw b'01111111' ; yes, reset highbyte - movwf eeprom_address+1 - return ; Done. + return +; +; btfss eeprom_address+1,7 ; at address 8000? +; return ; No, done. +; +; movlw b'01111111' ; yes, reset highbyte +; movwf eeprom_address+1 +; return ; Done. ;============================================================================= @@ -72,15 +73,14 @@ addwf eeprom_address+0,F movlw d'0' addwfc eeprom_address+1,F - bcf eeprom_overflow - btfss eeprom_address+1,7 ; at address 8000? - return ; no, return - - clrf eeprom_address+0 ; Clear eeprom address - clrf eeprom_address+1 - bsf eeprom_overflow ; and set overflow bit return - +; btfss eeprom_address+1,7 ; at address 8000? +; return ; no, return +; +; clrf eeprom_address+0 ; Clear eeprom address +; clrf eeprom_address+1 +; 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... @@ -96,20 +96,21 @@ movlw d'0' ; increase address incf eeprom_address+0,F addwfc eeprom_address+1,F - bcf eeprom_overflow - - btfss eeprom_address+1,7 ; at address 8000 - return ; no, return - - clrf eeprom_address+0 ; Clear eeprom address - clrf eeprom_address+1 - bsf eeprom_overflow ; and set overflow bit return + +; btfss eeprom_address+1,7 ; at address 8000 +; return ; no, return +; +; clrf eeprom_address+0 ; Clear eeprom address +; clrf eeprom_address+1 +; return I2CWRITE_BLOCK: movwf ext_ee_temp1 ; Data byte in WREG bsf SSPCON2,SEN ; Start condition rcall 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 rcall WaitMSSP rcall I2C_WaitforACK @@ -145,7 +146,9 @@ rcall WaitMSSP bsf SSPCON2,SEN ; Start condition rcall WaitMSSP - movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ + movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 + btfss ext_ee_temp2,7 ; Access Block2? + movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 movwf SSPBUF ; control byte rcall WaitMSSP btfsc SSPCON2,ACKSTAT @@ -160,8 +163,10 @@ bsf SSPCON2,RSEN ; Start condition rcall WaitMSSP - movlw b'10100111' ; Bit0=0: WRITE, Bit0=1: READ - movwf SSPBUF ; control byte + movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 + btfss ext_ee_temp2,7 ; Access Block2? + movlw b'10100111' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 + movwf SSPBUF ; control byte rcall WaitMSSP rcall I2C_WaitforACK @@ -200,10 +205,16 @@ addwf ext_ee_temp1,F movlw d'0' addwfc ext_ee_temp2,F - - btfsc ext_ee_temp2,7 ; 0x8000 reached? + + movlw 0xFF + cpfseq ext_ee_temp2 ; =0xFFFF + bra get_free_EEPROM_location2d ; No + cpfseq ext_ee_temp1 ; =0xFFFF + bra get_free_EEPROM_location2d ; No + bra get_free_EEPROM_location3b ; yes - + +get_free_EEPROM_location2d: bsf SSPCON2, ACKEN ; no, send Ack rcall WaitMSSP bra get_free_EEPROM_location2 ; and continue search @@ -232,15 +243,14 @@ addwf eeprom_address+0,F movlw d'0' addwfc eeprom_address+1,F - bcf eeprom_overflow - btfss eeprom_address+1,7 ; at 0x8000? - return ; no, return - - clrf eeprom_address+0 ; Yes, clear address - clrf eeprom_address+1 - bsf eeprom_overflow ; and set overflow bit return - +; btfss eeprom_address+1,7 ; at 0x8000? +; return ; no, return +; +; clrf eeprom_address+0 ; Yes, clear address +; clrf eeprom_address+1 +; return +; I2CREAD3: ; block read start with automatic address increase rcall I2CREAD_COMMON ; no Stop condition here @@ -261,8 +271,11 @@ rcall WaitMSSP bsf SSPCON2,SEN ; Start condition rcall WaitMSSP - movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ - movwf SSPBUF ; control byte + + 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 rcall WaitMSSP btfsc SSPCON2,ACKSTAT bra I2CREAD ; EEPROM NOT acknowledged, retry! @@ -275,8 +288,11 @@ bsf SSPCON2,RSEN ; Start condition rcall WaitMSSP - movlw b'10100111' ; Bit0=0: WRITE, Bit0=1: READ - movwf SSPBUF ; control byte + + 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 rcall WaitMSSP rcall I2C_WaitforACK @@ -290,8 +306,10 @@ movwf ext_ee_temp1 ; Data byte bsf SSPCON2,SEN ; Start condition rcall WaitMSSP - movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ - movwf SSPBUF ; control byte + 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 rcall WaitMSSP rcall I2C_WaitforACK movff eeprom_address+1,SSPBUF ; High Address byte
--- a/code_part1/OSTC_code_asm_part1/interface.asm Mon May 30 19:28:59 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/interface.asm Tue May 31 19:43:29 2011 +0200 @@ -219,7 +219,59 @@ 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 + + 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 + DISPLAYTEXT .20 ; Done. WAITMS d'250'
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm Mon May 30 19:28:59 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm Tue May 31 19:43:29 2011 +0200 @@ -76,9 +76,16 @@ infsnz divemins+0,F ; increase 16Bit value, twice incf divemins+1,F - btfsc divemins+1,7 ; At 0x8000? + movlw 0xFF + cpfseq divemins+0 ; =0xFFFF ? + bra menu_logbook2a ; No + + cpfseq divemins+1 ; =0xFFFF ? + bra menu_logbook2a ; No + bra menu_logbook_reset ; yes, restart (if not empty) +menu_logbook2a: decf_eeprom_address d'2' ; -2 to eeprom address. call I2CREAD ; reads one byte (Slow! Better use Blockread!)
--- a/code_part1/OSTC_code_asm_part1/menu_reset.asm Mon May 30 19:28:59 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm Tue May 31 19:43:29 2011 +0200 @@ -456,7 +456,7 @@ clrf eeprom_address+0 clrf eeprom_address+1 - movlw d'2' + movlw d'4' movwf temp3 reset_eeprom02: clrf temp4 @@ -476,7 +476,7 @@ decfsz temp4,F bra reset_eeprom01 ; do this 256 times decfsz temp3,F - bra reset_eeprom02 ; and this all 2 times -> 512 *64Bytes = 32KB + bra reset_eeprom02 ; and this all 4 times -> 1024 *64Bytes = 64KB bcf eeprom_blockwrite ; clear blockwrite flag