diff src/rtc.asm @ 582:b455b31ce022

work on 2.97 stable
author heinrichsweikamp
date Mon, 26 Feb 2018 16:40:28 +0100
parents b7eb98dbd800
children e1f0f5e3d4e4
line wrap: on
line diff
--- a/src/rtc.asm	Sun Feb 25 18:25:38 2018 +0100
+++ b/src/rtc.asm	Mon Feb 26 16:40:28 2018 +0100
@@ -1,6 +1,6 @@
 ;=============================================================================
 ;
-;   File rtc.asm
+;   File rtc.asm													## V2.98
 ;
 ;
 ;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
@@ -11,7 +11,9 @@
 #include "hwos.inc"
 #include "math.inc"
 
-sensors     CODE
+sensors		CODE
+
+;=============================================================================
 
 	global	rtc_init
 rtc_init:
@@ -21,71 +23,70 @@
 	movwf	mins
 	movlw	.12
 	movwf	hours
-	movlw	.2
+	movlw	.1
 	movwf	day
-	movlw	.12
+	movlw	.3
 	movwf	month
-	movlw	.17
+	movlw	.18
 	movwf	year
 ;	rcall	rtc_set_rtc			; writes mins,sec,hours,day,month and year to rtc module
 ;	return
-	
+
 	global	rtc_set_rtc
 rtc_set_rtc:
-	banksel 0xF16				; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
-	movlw 	0x55
-	movwf 	EECON2
-	movlw 	0xAA
-	movwf 	EECON2
-	bsf 	RTCCFG,RTCWREN		; Unlock sequence for RTCWREN
-	bsf		RTCCFG,RTCPTR1
-	bsf		RTCCFG,RTCPTR0		; year
+	banksel	0xF16				; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM
+	movlw	0x55
+	movwf	EECON2
+	movlw	0xAA
+	movwf	EECON2
+	bsf	RTCCFG,RTCWREN		; Unlock sequence for RTCWREN
+	bsf	RTCCFG,RTCPTR1
+	bsf	RTCCFG,RTCPTR0		; year
 	movff	year,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
 	movwf	RTCVALL				; year
 	movwf	RTCVALH				; dummy write
 	movff	day,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALL				;day
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALL				; day
 	movff	month,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALH				;month
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALH				; month
 	movff	hours,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALL				;hours
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALL				; hours
 	movlw	d'0'
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALH				;weekday
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALH				; weekday
 	movff	secs,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALL				;secs
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALL				; secs
 	movff	mins,WREG
-	rcall	rtc_dec2bcd			; IN: temp1 in WREG, OUT: WREG in BCD, also sets to bank16h!
-	movwf	RTCVALH				;minutes
-	movlw 	0x55
-	movwf 	EECON2
-	movlw 	0xAA
-	movwf 	EECON2
-	bcf 	RTCCFG,RTCWREN		; Lock sequence for RTCWREN
+	rcall	rtc_dec2bcd			; IN: WREG in decimal, OUT: WREG in BCD, also sets to bank16h!
+	movwf	RTCVALH				; minutes
+	movlw	0x55
+	movwf	EECON2
+	movlw	0xAA
+	movwf	EECON2
+	bcf	RTCCFG,RTCWREN		; Lock sequence for RTCWREN
 	banksel	common
 	return
 
 rtc_dec2bcd:
-	banksel	temp1
-	movwf	temp1				; Input in dec
-	setf	temp2				; 10s
-	
+	banksel	lo
+	movwf	lo					; Input in decimal
+	setf	hi					; 10s
 rtc_dec2bcd2:
-	incf	temp2,F             ; Count 10's
+	incf	hi,F				; Count 10's
 	movlw	d'10'
-	subwf	temp1,F
+	subwf	lo,F
 	btfss	STATUS,N
 	bra		rtc_dec2bcd2
 	movlw	d'10'
-	addwf	temp1,F				; 1s
-    swapf   temp2,W             ; swap to bit 7-4 -> WREG
-	addwf	temp1,W				; Result in BCD
-	banksel 0xF16				; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
+	addwf	lo,F				; 1s
+	swapf	hi,W				; swap to bit 7-4 -> WREG
+	addwf	lo,W				; Result in BCD
+	banksel	0xF16				; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM
 	return
 
 	END
\ No newline at end of file