📄 ds1687.asm
字号:
; Dallas DS1687 Real Time Clock functions
; Chris Ward, 29/11/1999
_RTC ;remember start address
; I/O addresses
ORG RTC
RTCADDR .ds 1
RTCDATA .ds 1
ORG _RTC
; *** RINIT: RTC initialisation
; X,Y preserved
RINIT LDA #$0A ;Register A
STA RTCADDR
LDA #$38 ;osc on, extended regs, 3.90625ms (256Hz) IRQ rate
STA RTCDATA
LDA #$0B ;Register B
STA RTCADDR
LDA #$43 ;periodic IRQ, BCD, 24h, DSE
STA RTCDATA
LDA #$4B ;Extended register 4B
STA RTCADDR
LDA RTCDATA
AND #$3C ;clear ABE, E32K, WIE, KSE
STA RTCDATA
JSR GETTIME
LDA #0
STA TI_TICK
RTS
; *** GETTIME: Get the time and date from the RTC.
; A,X,Y preserved
GETTIME PHA
LDA #$00 ;Seconds register
STA RTCADDR ;Set RTC address
LDA RTCDATA
STA TI_SEC ;Store Seconds
LDA #$02 ;Minutes
STA RTCADDR
LDA RTCDATA
STA TI_MIN
LDA #$04 ;Hours
STA RTCADDR
LDA RTCDATA
STA TI_HOUR
LDA #$06 ;Day of week
STA RTCADDR
LDA RTCDATA
STA TI_DAY
LDA #$07 ;Date
STA RTCADDR
LDA RTCDATA
STA TI_DATE
LDA #$08 ;Month
STA RTCADDR
LDA RTCDATA
STA TI_MON
LDA #$09 ;Year
STA RTCADDR
LDA RTCDATA
STA TI_YEAR
LDA #$48 ;Century
STA RTCADDR
LDA RTCDATA
STA TI_CENT
PLA
RTS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -