Friday, December 23, 2011

Program for Setting time in RTC DS12887

; TURNING ON RTC
MOV R0, #10    ; REGISTER A ADDRESS IN R0
MOV A, #20H    ; 010 TO TURN ON RTC
MOVX @RO,A    ; SEND IT TO REGISTER A OF RTC


; SETTING TIME MODE
; AS DECIDED WE SET BCD, 24 HRS, DAYLIGHT SAVING
; MEANING SENDING 83H TO REGISTER B OF RTC
MOV R0, #11    ; REGISTER B ADDRESS IN R0
MOV A, #83H    ; FOR REASONS SITED ABOVE
MOVX @R0, A    ; SEND IT TO REGISTER B OF RTC


; SETTING THE TIME
; LET GET ONE THING CLEAR
; 0 - SECONDS
; 2 - MINUTES
; 4 - HOURS
; FOR INFO RELATED ABOVE SEE THE POST...


; SETTING SECONDS
MOV R0, #0    ; POINT TO SECONDS ADDRESS
MOV A, #SSH    ; SECONDS = SS MEANS PUT ANY VALUE
; CAREFULL SECONDS 0 - 60 AND IN BCD
; SO SS = 00H,02H......09H,10H,11H,.......29H,30H,...,59H
; H IS MUST FOR BCD
MOVX @R0, A    ; SET SECONDS


; SETTING MINUTES
MOV R0, #02    ; POINT TO MINUTES ADDRESS
MOV A, #MM    ; MINUTES = MM MEANS PUT ANY VALUE
; CAREFULL MINUTES 0 - 60 AND IN BCD
; SO MM = 00H,02H......09H,10H,11H,.......29H,30H,...,59H
; H IS MUST FOR BCD
MOVX @R0, A    ; SET MINUTES


; SETTING HOURS
MOV R0, #04    ; POINT TO HOURS ADDRESS
MOV A, #HH    ; HOURS = HH
; CAREFULL HOURS HERE IS IN 24 HOURS FORMAT
; SO HH CAN BE 1,2,...., 14,15......,23 NOT OUTSIDE THIS
; H IS MUST FOR BCD
MOVX @R0, A    ; SET HOURS


; REGISTER B
MOV R0, #11    ; POINT TO REGISTER B ADDRESS
MOV A, #03    ; D7 = 0 TO ALLOW UPDATE
MOVX @R0, A    ; SEND IT TO REGISTER B OF RTC

END

No comments:

Post a Comment