Assembly routine for interfacing DSC12887 with microcontroller

Publisher:BlissfulSpiritLatest update time:2018-01-17 Source: eefocusKeywords:DSC12887 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;**********************************
; Write time subroutine
; write time information back to DS12887, including year, month, day, hour, minute, and second;
;**********************************
WRITE_TIME

MOV DS_ADDR,#0BH
MOV A,#0A2H
LCALL WRITE_DS
; write second information, in 60H, 61H
MOV DS_ADDR,#0
MOV A,61H
ANL A,#0FH
SWAP A
ANL 60H,#0FH
ORL A,60H
LCALL WRITE_DS
; minute information, in 62, 63H
MOV DS_ADDR,#2
ANL 62H,#0FH
ANL 63H,#0FH
MOV A,63H
SWAP A 
ORL A,62H
LCALL WRITE_DS
; hour information, in 64, 65H
MOV DS_ADDR,#4
ANL 64H,#0FH
ANL 65H,#0FH
MOV A,65H
SWAP A
ORL A,64H
LCALL WRITE_DS
;Week information, in 66H
MOV DS_ADDR,#6 
MOV A,66H
LCALL WRITE_DS
;Day information, in 67,68H
MOV DS_ADDR,#7
ANL 67H,#0FH
ANL 68H,#0FH
MOV A,68H
SWAP A
ORL A,67H
LCALL WRITE_DS
;Month information, in 69,6AH
MOV DS_ADDR,#8
ANL 69H,#0FH
ANL 6AH,#0FH
MOV A,6AH
SWAP A
ORL A,69H
LCALL WRITE_DS
;Year information, in 6B,6CH
MOV DS_ADDR,#9
ANL 6BH,#0FH
ANL 6CH,#0FH
MOV A,6CH
SWAP A
ORL A,6BH
LCALL WRITE_DS
; Century information, in 6D, 6EH
MOV DS_ADDR, #0EH
ANL 6DH, #0FH
ANL 6EH, #0FH
MOV A, 6EH
SWAP A
ORL A, 6DH
LCALL WRITE_DS
;********The following reinitializes the clock
MOV DS_ADDR, #0AH
MOV A, #2FH
LCALL WRITE_DS
MOV DS_ADDR, #0BH
MOV A, #42H
LCALL WRITE_DS
MOV DS_ADDR, #0CH
LCALL READ_DS
MOV DS_ADDR, #0DH
LCALL READ_DS
RET
;************************************
; Read time information routine, including year, month, day, hour, minute, and second
; Put them into the memory bytes of 60H-6DH respectively, one by one
; Only one digit is stored in a byte, and the low digit is in front
;************************************
READ_TIME:
MOV DS_ADDR,#0AH
LCALL READ_DS
JBC A CC .7,READ_TIME Update flag
; second information sends 60H,61HNDEFINED SYMBOL (PASS-2)
MOV DPTR,#0 Countdown information
MOVX A,@DPTR 
MOV 60H,A
SWAP A
MOV 61H,A
ANL 60H,#0FH
ANL 61H,#0FH
; minute information sends 62,63H
MOV DPTR,#2
MOVX A,@DPTR
MOV 62H,A
SWAP A
MOV 63H,A
ANL 62H,#0FH
ANL 63H,#0FH
SWAP A
CLR BZ_M00 Clear hour flag
CJNE A,#00,RT_H10
SETB BZ_M00 Hour flag
; hour information sends 64,65H
RT_H10:
MOV DPTR,#4
MOVX A,@DPTR
MOV 64H,A
SWAP A
MOV 65H,A
; weekly information will send 66H
H_14:
MOV DS_ADDR,#6
LCALL READ_DS
MOV 66H,A
ANL 66H,#0FH
;Send month and date to 67,68H
MOV DS_ADDR,#7 
LCALL READ_DS
MOV 67H,A
SWAP A
MOV 68H,A
;Send month count to 69,6AH
D_01:
MOV DS_ADDR,#8 
LCALL READ_DS 
MOV 69H,A
SWAP A
MOV 6AH,A
SWAP A
;Send year information to 6B,6C
MOV DS_ADDR,#9 
LCALL READ_DS
MOV 6BH,A
SWAP A
MOV 6CH,A
;Send century information to 6D,6E
CJNE A,#98H,RT_1 
RT_1: JC RT_2
MOV A,#19H Determine century, if greater than 98 it is 19, if less
than 20 it is
AJMP RT_3
RT_2: MOV A,#20H
RT_3: MOV 6DH,A
SWAP A
MOV 6EH,A
;*****The following program accumulates the number of safety days, 64H=hour
JNB BZ_M00,RT_10 is not an hour
MOV A,64H
CJNE A,#00H,RT_END 0 o'clock accumulates the number of safety days
JB BZ_ADD,RT_END has been added
SETB BZ_ADD
LCALL ADD_DAY accumulates the number of safety days
RT_6:
AJMP RT_END
;*****The above program accumulates the output *******
RT_10:
CLR BZ_ADD
; CLR BZ_ADM
; CLR BZ_ADN
RT_END:
​​; MOV DS_ADDR,#0CH
; LCALL READ_DS
RET


;***************************************
;Read and write data from DS12887, the address is in DS_ADDR
;***************************************
READ_DS:
; CLR P3.3
MOV DPH,#0H
MOV DPL,DS_ADDR
MOVX A,@DPTR
RET
WRITE_DS:
MOV DPH,#0H
MOV DPL,DS_ADDR
MOVX @DPTR,A
RET


Keywords:DSC12887 Reference address:Assembly routine for interfacing DSC12887 with microcontroller

Previous article:TV remote control microcontroller decoding program
Next article:MCS51 three-byte unsigned division routine (ASM)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号