diff src/eeprom_rs232.asm @ 650:bc214815deb2

3.19/10.75 release
author heinrichsweikamp
date Sun, 28 Aug 2022 13:13:38 +0200
parents aeca5717d9eb
children 75e90cd0c2c3
line wrap: on
line diff
--- a/src/eeprom_rs232.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/eeprom_rs232.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -69,10 +69,24 @@
 write_eeprom_loop:
 	btfsc	EECON1,WR						; write completed?
 	bra		write_eeprom_loop				; NO  - loop waiting
+	btfsc	EECON1,WRERR						; All ok?
+	rcall	write_eeprom_error					; NO, something failed.
 	bcf		EECON1,WREN						; YES - disable writing
 	bsf		INTCON,GIE						;     - re-enable interrupts 
 	return									;     - done
-
+write_eeprom_error:
+	bsf	eeprom_write_error_flag					; Set error flag
+	; Try again (once)
+	movlw	0x55							; unlock sequence
+	movwf	EECON2							; ...
+	movlw	0xAA							; ...
+	movwf	EECON2							; ...
+	bsf		EECON1,WR						; start write operation
+write_eeprom_loop2:
+	btfsc	EECON1,WR						; write completed?
+	bra		write_eeprom_loop2				; NO  - loop waiting
+	return
+	
 
 ;-----------------------------------------------------------------------------
 ; EEPROM read and write Functions to be used via Macros
@@ -500,7 +514,10 @@
     bcf         NCTS            ; Clear to send
     call	wait_1s
     call	wait_1s
+    call	wait_1s
+    call	wait_1s
     bcf	PORTB,6
+    nop
     bsf	PORTB,6			; rising edge -> Command mode
     
     ; point to config table
@@ -545,7 +562,7 @@
     ; 0xFE: 20ms delay
     ; 0xFD: 1s delay
     ; .13: cr character
-    db	0xFD,0xFD						; Wait 2 seconds
+    db	0xFD,0xFD,0xFD,0xFD					; Wait 4 seconds
     db	"AT+UDSC=0,0",.13,0xFE,0xFE				; Disable SPP Server on ID0 (and wait 40ms)
     db	"AT+UDSC=0,3",.13,0xFE,0xFE				; SPP Server on ID0 (and wait 40ms)
     db	"AT+UDSC=1,0",.13,0xFE,0xFE				; Disable SPS Server on ID1 (and wait 40ms)