;**********************************
; 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
Previous article:TV remote control microcontroller decoding program
Next article:MCS51 three-byte unsigned division routine (ASM)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Programming example: CPU card response data command
- How to use multiple devices to study radiation signals - Part 1
- Tianjin - Recruiting embedded software and hardware engineers - fresh graduates preferred
- Flash memory failure characteristics
- [RVB2601 Creative Application Development] User Experience 05 -- TCP Client
- CXA-L10A Tube Lamp Inverter
- Transistor User Manual
- Encoders and Data Acquisition
- Analysis of the working principle of PWM in single chip microcomputer
- Please tell me about a very strange problem caused by while(1) in the main.c file.