I'm reading time from DS1307 in 24Hours mode.I have a trim value ranging from 1---59 Seconds.
What I want is to subtract the Trim value from current time variables & save it to S_Hours,S_Minutes,S_Seconds registers.
Ex: Time is = 13.59.00
Trim Val = 5
Output = 13.58.55
I did a code but it seems that my code is too long.I need to compact my code little abit.
What I want is to subtract the Trim value from current time variables & save it to S_Hours,S_Minutes,S_Seconds registers.
Ex: Time is = 13.59.00
Trim Val = 5
Output = 13.58.55
I did a code but it seems that my code is too long.I need to compact my code little abit.
Code:
Current Time = Hours,Minutes,Seconds
Trim_Val = 0,1...59 (seconds)
must return the following
S_Hours,S_Minutes,S_Seconds = Current Time - Trim_Val
Save_Sec_uP call I2C_Read_Time ;read DS1307
movf Minutes,W
btfss STATUS,Z
goto Save_Trim_H_M
call Dec_Hours
call B2_BCD
movwf S_Hours
movlw .59
call B2_BCD
movwf S_Minutes
goto Save_Trim_Secs
;
Save_Trim_H_M movf Hours,W
movwf S_Hours
movf Minutes,W
call BCD_To_Binary
movwf S_Minutes
decf S_Minutes,W
call B2_BCD
movwf S_Minutes
;
Save_Trim_Secs movf Trim_Val,W
andlw b'00111111'
sublw .60
call B2_BCD
movwf S_Seconds
call I2C_Write_Trim ; save check time
return
Dec_Hours movf Hours,W
btfss STATUS,Z
goto $+3
movlw .23 ;23.00
return
movf Hours,W
andlw b'00111111'
call BCD_To_Binary
movwf S_Hours
decf S_Hours,W
return