📄 rtc.mac
字号:
$nolist
;*******************************************************************************
;*******************************************************************************
;* *
;* (C)Copyright, CLOVER China Electronics Co.,LTD. *
;* (Company No:190077-X) *
;* All Rigits Reserved *
;* add:No.58-F Yang Dong Road, LuoFeng Demonstrative Zone Suzhou, China *
;* Tel: 0512-67261886 Fax:0512-67261882 *
;* http://www.clover.co.jp *
;* *
;*******************************************************************************
;*******************************************************************************
;
; OBS CPD3212T source program
; CPU: TOSHIBA TLC-870/C series TMP86CM74AF
; RAM: 2Kbytes(0040h - 083Fh)
; ROM: 32Kbytes(8000h - FFFFh)
;
;
;Sub routines
?trigger(@)
@include "symdef_ram.inc"
@include "symdef_sub.inc"
@include "macro.inc"
@include "define.inc"
$list
public init_rtc,rtc_int,clock_test,rtc_key_equ,rtc_key_mul,rtc_key_div,rtc_edit_d
public time_key,rtc_key,rtc_intsub,wait_300ms,wait_xms,wait_1s,wait_500ms,wait_100ms,wait_50ms
extern disp_to_dbr,ic_display
extern function_end,no_operation,cec_key,ce_key,tenkey,acc_total;init_pf,
extern back_space,wk_print9
ROM section code
T_RTCS equ 150 ;7813us x 100 = 781.3ms (the value for enter time set mode)
;==============================================================================
; Check entry key code and junp to each function(under RTC mode only)
;==============================================================================
rtc_key:
;V1.39b @interval_tm_disable ;V1.21
ld a,(KEYIN)
cmp a,K_NUM ;0-9 key?
j le,rtc_key_ten ;yes ->
;V1.23 cmp a,K_DP ;V1.23
;V1.23 j eq,rtc_key_dp ;V1.23
cmp a,K_BS ;V1.23 V1.44
j eq,rtc_key_bs ;V1.23 V1.44
cmp a,K_TIM
j eq,time_key
cmp a,K_CEC
j eq,rtc_key_clr
cmp a,K_CE ;V1.23
j eq,rtc_key_ce ;V1.23
cmp a,K_SHD ;V1.23
j eq,rtc_key_shd ;V1.23
cmp a,K_ST ;V1.23
j eq,rtc_key_st ;V1.23
;V1.44 cmp a,K_TL ;V1.23
;V1.44 j eq,rtc_key_tl ;V1.23
;V1.21 cmp a,K_PER ;%(format) key?
;V1.21 j eq,rtc_key_per
;V1.21 cmp a,K_DIV ;%(12/24) key?
;V1.21 j eq,rtc_key_div
;V1.23 cmp a,K_EQU ;=(time set) key?
;V1.23 j eq,rtc_key_equ
;V1.21 cmp a,K_MUL ;X(AM/PM) key?
;V1.21 j eq,rtc_key_mul
rtc_key_no_operation: ;V1.21
;1.39b @interval_tm_enable ;V1.21
ld a,(KEYIN) ;V1.30
ld (PRE_KEY),a ;V1.30
j no_operation
;==============================================================================
; tenkey (under RTC - RTC set mode)
;==============================================================================
rtc_key_ten:
@BBC (RTC_SET,rtc_kten9) ;RTC set mode? no-> ignore]
@SEB (RTC_CHK) ;V1.23
;V2.12 @interval_tm_enable ;V1.21
jp tenkey ;V1.23
;V1.24 ld b,(PTR)
;V1.24 inc (PTR)
;V1.24 @BBS (RTC_TIM,rtc_kten4) ;time mode? yes->
;V1.24 cmp (PTR),8
;V1.24 j lt,rtc_kten02
;V1.24 ld (PTR),0
;V1.24rtc_kten02:
;V1.24 @BBS (RTC_DMY,rtc_kten2)
;V1.24 @BBS (RTC_YMD,rtc_kten3)
;V1.24;mm-dd-20yy format......................
;V1.24 ld c,0y0000000
;V1.24 j rtc_kten5
;V1.24;dd-mm-20yy format......................
rtc_kten2:
;V1.24 ld c,0y0001000
;V1.24 j rtc_kten5
;V1.24;20yy-mm-dd format.......................
;V1.24rtc_kten3:
;V1.24 ld c,0y0010000
;V1.24 j rtc_kten5
;under date setting mode....
;V1.24rtc_kten4:
;V1.24 cmp (PTR),4
;V1.24 j lt,rtc_kten42
;V1.24 ld (PTR),0
;V1.24rtc_kten42:
;V1.24 ld c,0y0011000
;V1.24rtc_kten5:
;V1.24 cmp (KEYIN),K_NUM
;V1.24 j gt,rtc_kten59 ;if not numeric key? yes -> exit (just move current pointer)
;V1.24 or c,b
;V1.24 ld hl,tbl_temp_ptr
;V1.24 ld a,(hl+c)
;V1.24 shrc a ;shift->
;V1.24 ld c,a
;V1.24 ld hl,TEMP
;V1.24 j cs,rtc_kten52
;even...
;V1.24 ld a,(hl+c)
;V1.24 and a,0x0f
;V1.24 swap a
;V1.24 or a,(KEYIN)
;V1.24 swap a
;V1.24 ld (hl+c),a
;V1.24 j rtc_kten54
;odd...
;V1.24rtc_kten52:
;V1.24 ld a,(hl+c)
;V1.24 and a,0xf0
;V1.24 or a,(KEYIN)
;V1.24rtc_kten54:
;V1.24 ld (hl+c),a
;V1.24rtc_kten59:
;V1.24 ld (BLK_CT),0 ;V1.23 ;syncronize brinking
;V1.24 call temp_edit_d ;V1.23 ;tempolary register for set RTC edit and transfer to DISP
;V1.23 j rtc_kequ3 ;-> tempolary register for set RTC edit and transfer to DISP and DBR
rtc_kten9:
;V2.12 @interval_tm_enable ;V1.21
;V1.24 jp tenkey ;V1.23
;V1.24rtc_kten99: ;V1.23
j rtc_key_no_operation
tbl_temp_ptr:
db 4,5,6,7,0,1,2,3 ;mm-dd-20yy
db 6,7,4,5,0,1,2,3 ;dd-mm-20yy
db 0,1,2,3,4,5,6,7 ;20yy-mm-dd
db 8,9,10,11,0,0,0,0 ;hh-mm
;==============================================================================
rtc_key_dp: ;----------------------------V1.23
j rtc_key_no_operation
;==============================================================================
;-----------------------------------------V1.44
rtc_key_bs:
@BBC (RTC_SET,rtc_key_no_operation)
@BBS (F_TNKEY,back_space)
jp rtc_key_no_operation
;------------------------------------------V1.44
;==============================================================================
rtc_key_ce: ;------------V1.23
@BBC (RTC_CHK,rtc_key_no_operation) ;V1.23
call ten_clear ;V1.23
call spc_dt ;V1.23 ;clear #/D key buffer
ld (DT_CT),0 ;V1.23 ;clear #/D data entry counter
ld (DT_DOT_CNT),0 ;V1.23
ld (TEN_CT),0 ;V1.23
@CLB (F_TNKEY) ;V1.23
ld hl,TENKEY ;V1.23
call edit_disp ;V1.23
call disp_to_dbr ;V1.23 ;DBR update (DISP -> DBR)
j rtc_key_no_operation ;V1.23
;==============================================================================
; CE/C key (under RTC mode)
;==============================================================================
rtc_key_clr:
@BBS (SW_AC,rtc_key_clr1)
CMP (PRE_KEY),K_CEC ;V1.30
j eq,rtc_key_clr1 ;V1.30
;V1.44 @BBS (RTC_SET,rtc_key_ce) ;RTC set mode? yes->
@BBC (RTC_SET,rtc_key_clr1) ;V1.44
@BBS (F_TNKEY,rtc_key_ce) ;V1.44
rtc_key_clr1:
@CLB (RTC_ON)
@CLB (RTC_CHK)
@CLB (RTC_SET)
;V2.06 @interval_tm_enable ;V1.30
;V2.06 j cec_key
j function_end ;V2.06
;rtc_kclr9:
; call backup_to_temp ;resume previouse RTC data BACKUP -> TEMP
; ld (PTR),0 ;reset pointer
; j rtc_kequ31 ;-> tempolary register for set RTC edit and transfer to DISP and DBR(no syncro brinking)
;==============================================================================
; %(format)key (under RTC - DATE mode)
;==============================================================================
rtc_key_per:
@BBS (RTC_SET,rtc_kper9) ;RTC set mode? yes-> ignore
@BBS (RTC_TIM,rtc_kper9) ;time mode? yes-> ignore
@BBS (RTC_DMY,rtc_kper2) ;dd-mm-yy format? yes->
@BBS (RTC_YMD,rtc_kper4) ;yy-mm-dd format? yes->
;under mm-dd-yy(default) format.....
@SEB (RTC_DMY) ;set dd-mm-yy format
j time_key4 ; -> update display
;under dd-mm-yy format.....
rtc_kper2:
@CLB (RTC_DMY) ;
@SEB (RTC_YMD) ;set yy-mm-dd format
j time_key4 ; -> update display
;under yy-mm-dd format.....
rtc_kper4:
@CLB (RTC_YMD) ;set mm-dd-yy format
j time_key4 ; -> update display
rtc_kper9:
j rtc_key_no_operation
;==============================================================================
; Divide(12/24)key (under RTC - TIME mode)
;==============================================================================
rtc_key_div:
@BBS (RTC_SET,rtc_kdiv9) ;RTC set mode? yes-> ignore
@BBC (RTC_TIM,rtc_kdiv9) ;time mode? no-> ignore
@BBS (RTC_24,rtc_kdiv2) ;24h format? yes->
;under 12h mode............
@SEB (RTC_24) ;set 24h format
j time_key4 ; -> update display
rtc_kdiv2:
@CLB (RTC_24) ;set 12h format
j time_key4 ; -> update display
rtc_kdiv9:
j rtc_key_no_operation
;==============================================================================
; =(time set)key (under RTC mode)
;==============================================================================
rtc_key_equ:
;V1.23 @BBS (RTC_SET,rtc_kequ4) ;RTC set mode? yes->
;; @BBC (RTC_SET,rtc_kequx) ;V1.23
;; @CLB (RTC_SET) ;V1.23
;; jp rtc_kequ4 ;V1.23
@BBS (RTC_SET,rtc_kequ3) ;V1.23
rtc_kequx: ;V1.23
ld (DW_CT),T_RTCS ;set timer for enter time set mode
rtc_kequ0:
;V2.23 @BBS (IO_MT,rtc_kequ2) ;V2.18
@BBS (IO_MT,rtc_kequ3) ;V2.23
ld (DELAY_CT),12 ;V1.39b
call wait_xms ;V1.39b
;V1.39b cmp (DW_CT),T_RTCS-5
;V1.39b j ge,rtc_kequ0 ;wait a morment(bcos,F_HLD_SET is bit delayed)
rtc_kequ2:
@BBC (F_HLD_SET,rtc_kequ9)
cmp (DW_CT),0
j ne,rtc_kequ2
ld (PTR),0
@SEB (RTC_SET) ;enter to RTC set mode
;V1.23 call rtc_to_temp
rtc_kequ3:
ld (BLK_CT),0 ;syncronize brinking
rtc_kequ31:
;V1.23 call temp_edit_d ;tempolary register for set RTC edit and transfer to DISP
call rtc_edit_d ;V1.23
call disp_to_dbr ;DBR update (DISP -> DBR)
j rtc_key_no_operation
j rtc_kequ9 ;V1.21
;exit set mode.....................................
rtc_kequ4:
call chk_temp ;check entry data
j cs,rtc_kequ9
call temp_to_rtc
@BBS (RTC_SET,rtc_kequ9) ;V1.23
;V1.23 @CLB (RTC_SET) ;exit from RTC set mode
;V1.23 call feed_1
;V1.23 call rtc_print
;V1.23 call feed_1
j time_key4 ; -> update display
rtc_kequ9:
;V3.00 @interval_tm_enable ;V1.21
;V1.21 j rtc_key_no_operation
j function_end ;V1.21
;.......................................................
chk_temp:
@BBS (RTC_TIM,chk_temp5)
cmp (T_Y20),0x20
j ne,chk_temp8
ld a,(T_YEAR)
cmp a,0x05
j lt,chk_temp8
cmp a,0x55
j gt,chk_temp8
ld a,(T_MON)
j z,chk_temp8
cmp a,0x12
j gt,chk_temp8
ld a,(T_DAY)
j z,chk_temp8
ld c,(T_MON)
ld w,(T_YEAR)
call leap_year
j gt,chk_temp8
j chk_temp9
chk_temp5:
@BBS (RTC_SET,chk_temp51) ;V1.23
@BBS (F_24ON,chk_temp51) ;V2.14
@BBC (RTC_24,chk_temp7)
chk_temp51: ;V1.23
cmp (T_HOUR),0x23 ;0:00-23:59
;V2.12 cmp (T_HOUR),0x11 ;V2.12
j gt,chk_temp8
j chk_temp71
chk_temp7:
ld a,(T_HOUR)
j z,chk_temp8
cmp a,0x12 ;12:00-01:00-11:59
j gt,chk_temp8
chk_temp71:
cmp (T_MIN),0x59
j gt,chk_temp8
j chk_temp9
chk_temp8:
set cf ;error
ret
chk_temp9:
clr cf
ret
temp_to_rtc:
di
@BBS (RTC_TIM,temp_to_rtc5)
;under date set mode.....
ld a,(T_YEAR)
ld (YEAR),a
ld a,(T_MON)
ld (MON),a
ld a,(T_DAY)
ld (DAY),a
j temp_to_rtc9
;under time set mode.....
temp_to_rtc5:
@BBS (RTC_24,temp_to_rtc7)
@BBS (F_24ON,temp_to_rtc7) ;V2.15
ld a,(T_HOUR)
cmp a,0x12
j ne,temp_to_rtc52
ld a,0
temp_to_rtc52:
cmp (T_AMPM),0
j eq,temp_to_rtc54
add a,0x12
daa a
temp_to_rtc54:
j temp_to_rtc72
temp_to_rtc7:
ld a,(T_HOUR)
temp_to_rtc72:
ld (HOUR),a
ld a,(T_MIN)
ld (MIN),a
ld (SEC),0
ld (RTC_CK),0
temp_to_rtc9:
ei
ret
rtc_to_temp:
di
ld ix,YEAR
ld iy,T_YEAR
ld c,5-1
rtc_to_temp0:
ld a,(ix)
ld (iy),a
ld (iy+7),a ;copy TEMP -> BACKUP
inc ix
inc iy
dec c
j f,rtc_to_temp0
ei
ld (T_Y20),0x20
ld (BK_Y20),0x20
ld (T_AMPM),0y00000000 ;bit0=0 <-indicate AM
ld (BK_AMPM),0y00000000 ;
@BBS (RTC_24,rtc_to_temp7)
ld a,(T_HOUR)
cmp a,0x12 ;am?
j lt,rtc_to_temp5 ; yes->
ld (T_AMPM),0y00000001 ;bit0=1 <-indicate PM
ld (BK_AMPM),0y00000001 ;
sub a,0x12
das a
rtc_to_temp5:
cmp a,0
j ne,rtc_to_temp6
ld a,0x12
rtc_to_temp6:
ld (T_HOUR),a
ld (BK_HOUR),a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -