⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtc.mac

📁 calculator code ,use toshibaor nec LSI
💻 MAC
📖 第 1 页 / 共 3 页
字号:
rtc_to_temp7:		
		ret
;-------------------------------------------------
ten_to_temp:
		@BBS	(RTC_TIM,to_temp_time)
		@BBS	(RTC_DMY,to_setDMYtemp)
		@BBS	(RTC_YMD,to_setYMDtemp)
		ld	a,(TEN_LSD)
		ld	(T_YEAR),a
		ld	a,(TEN_LSD-1)
		ld	(T_DAY),a
		ld	a,(TEN_LSD-2)
		ld	(T_MON),a
		ret
to_setDMYtemp:
		ld	a,(TEN_LSD)
		ld	(T_YEAR),a
		ld	a,(TEN_LSD-1)
		ld	(T_MON),a
		ld	a,(TEN_LSD-2)
		ld	(T_DAY),a
		ret

to_setYMDtemp:
		ld	a,(TEN_LSD)
		ld	(T_DAY),a
		ld	a,(TEN_LSD-1)
		ld	(T_MON),a
		ld	a,(TEN_LSD-2)
		ld	(T_YEAR),a
		ret
to_temp_time:
		ld	a,(TEN_LSD)
		ld	(T_MIN),a
		ld	a,(TEN_LSD-1)
		ld	(T_HOUR),a
		cmp	a,0x12
		j	ge,to_set_ampm
		ld	(T_AMPM),0
		ret
to_set_ampm:
		ld	(T_AMPM),1
		@BBS	(RTC_24,to_set_ampm_e)	;V1.29
		@BBS	(F_24ON,to_set_ampm_e)
		ld	a,(T_HOUR)	;V1.29
		set	cf		;V1.29
		sub	a,0x12		;V1.29
;V2.13		das	a		;V1.29
		ld	(T_HOUR),a	;V1.29
to_set_ampm_e:
		ret


;.......................................................
backup_to_temp:
		ld	ix,BACKUP
		ld	iy,TEMP
		ld	c,7-1
bk_to_temp0:		
		ld	a,(ix)
		ld	(iy),a
		inc	ix
		inc	iy
		dec	c
		j	f,bk_to_temp0
		ret

;==============================================================================
;		X(AM/PM)key (under RTC - RTC set mode)
;==============================================================================
rtc_key_mul:
		@BBC	(RTC_SET,rtc_kmul9)		;RTC set mode?  no-> ignore
		@BBC	(RTC_TIM,rtc_kmul9)		;time display mode?  no-> ignore
		@BBS	(RTC_24,rtc_kmul9)		;24h clock mode?  yes-> ignore
		xor	(T_AMPM),0y00000001
		j	rtc_kequ31			;-> tempolary register for set RTC edit and transfer to DISP and DBR(no syncro brinking)
rtc_kmul9:
		j	rtc_key_no_operation
;==============================================================================
rtc_key_shd:
		@BBS	(RTC_SET,rtc_key_no_operation)	;V1.44
		@BBC	(SW_TA,rtc_key_shd_1)		;V1.44
		@SEB	(P_RED)				;V1.44
rtc_key_shd_1:	
		call	rtc_print
;		call	rtc_edit_d	;V2.16		;RTC data edit and transfer to DISP
;		call	disp_to_dbr	;V2.16		;DBR update (DISP -> DBR)
		j	rtc_key_no_operation
;==============================================================================
rtc_key_st:
;V2.03		@BBC	(M_HAND,rtc_key_no_operation)
		@BBC	(SW_DTST,rtc_key_no_operation)	;v2.07
		@BBS	(RTC_SET,rtc_key_no_operation)	;V2.07
		call	rtc_print
;		call	rtc_edit_d	;;V2.16		;RTC data edit and transfer to DISP
;		call	disp_to_dbr	;;V2.16		;DBR update (DISP -> DBR)
		j	rtc_key_no_operation

rtc_key_tl:
		@CLB	(RTC_ON)			
		@CLB	(RTC_SET)			
		@CLB	(RTC_CHK)
		jp	acc_total


;==============================================================================
;		TIME key (under normal mode & under RTC mode)
;==============================================================================
time_key:
;V2.13		@SEB	(F_DOFF)	;V2.12
		ld	(KEYIN),K_TIM		;V1.25
		@BBC	(RTC_CHK,time_key_x)	;V1.23
		@BBC	(RTC_SET,time_key_x)	;V1.23
;V2.10		@CLB	(RTC_CHK)		;V1.23
		@BBC	(F_TNKEY,time_key_x)
		@BBC	(RTC_TIM,time_key_y0)	;V1.23
		cmp	(TEN_CT),4		;V1.23
		jp	time_key_y1		;V1.23
time_key_y0:					;V1.23
		cmp	(TEN_CT),6		;V1.23
time_key_y1:					;V1.23
		j	gt,rtc_set_invalid	;V1.23
		@SEB	(F_24ON)		;V2.13
		call	ten_to_temp		;V1.23
		call	chk_temp		;V1.44
;V2.15		@CLB	(F_24ON)		;V2.13
		j	cs,rtc_set_invalid	;V1.44
		call	ten_clear		;V1.31
		call	spc_dt			;V1.31	;clear #/D key buffer
		ld	(DT_CT),0		;V1.31	;clear #/D data entry counter
		ld	(DT_DOT_CNT),0		;V1.31
		ld	(TEN_CT),0		;V1.31
		@CLB	(F_TNKEY)		;V1.31

		call	temp_to_rtc		;V1.23
		@CLB	(RTC_SET)		;V1.23
		@CLB	(RTC_CHK)		;V2.10
		@CLB	(F_24ON)		;V2.15
		di				;V1.23
		call	rtc_edit_d		;V1.23	;RTC data edit and transfer to DISP
		ei				;V1.23
		call	disp_to_dbr		;V1.23;DBR update (DISP -> DBR)
;V2.12		jp	rtc_key_no_operation	;V1.23
		jp	time_key3	;V2.12
rtc_set_invalid:				;V1.23
		call	ten_clear	;V1.31	;V1.23 V1.38
		call	spc_dt		;V1.31	;V1.23	V1.38;clear #/D key buffer
		call	rtc_to_temp		;V1.23
		ld	(DT_CT),0	;V1.31	;V1.23	V1.38;clear #/D data entry counter
		ld	(DT_DOT_CNT),0	;V1.31	;V1.23 V1.38
		ld	(TEN_CT),0	;V1.31	;V1.23 V1.38
V1.38		@CLB	(F_TNKEY)	;V1.31	;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

time_key_x:					;v1.21
		@BBS	(RTC_ON,time_key0)
;under normal mode.......
		@SEB	(RTC_ON)			;set RTC display mode
		@CLB	(F_RATE)	;V1.44
		@CLB	(RATE_PROG)	;V1.44
		@CLB	(EURO_PROG)	;V1.44
		@CLB	(F_ICDSP)	;V1.44
		@CLB	(IC_PROG)	;V1.44
		@CLB	(F_TNKEY)	;V1.30
		@CLB	(F_DPIN)	;V1.30
		ld	(TEN_CT),0	;V1.30
		ld	(DT_CT),0	;V1.30
		call	ten_clear	;V1.30
		
		j	time_key1			;default is clear RTC_TIM 
;under RTC mode.......
time_key0:
		@BBS	(RTC_CHK,rtc_key_no_operation)	;V2.10
		@BBC	(RTC_TIM,time_key2)		;RTC_TIM=1 -> time display, RTC_TIM=0 -> date display
time_key1:
		@CLB	(RTC_TIM)			;date mode
		j	time_key3
time_key2:
		@SEB	(RTC_TIM)			;time mode
time_key3:
;V1.23		@CLB	(RTC_SET)			;clear RTC setting mode(this key also use for exit RTC set mode)
;V1.23		call	rtc_print
time_key4:
		di
		call	rtc_edit_d			;RTC data edit and transfer to DISP
		ei
		call	disp_to_dbr			;DBR update (DISP -> DBR)
;V1.21		@interval_tm_enable
;V2.00		@lcd_enable		;V1.21
;V2.05		call	vft_enable	;V2.01
		jp	rtc_key_equ	;V1.21
;V1.21		j	function_end

rtc_print:
		call	rtc_edit_p			;RTC data edit and transfer to PRN_BUF
;V3.00		call	wait_40c	;V1.20
		nop
		nop
		nop
		nop
;V1.44		call	print_bk			;print with black color
;V2.15		di			;V2.13
;V2.15		call	rtc_edit_d	;V2.13		;RTC data edit and transfer to DISP
;V2.15		ei			;V2.13
;V2.15		call	disp_to_dbr	;V2.13		;DBR update (DISP -> DBR)
		call	print
;V2.16		call	rtc_edit_d	;V2.15		;RTC data edit and transfer to DISP
;V2.16		call	disp_to_dbr	;V2.15		;DBR update (DISP -> DBR)
		ret

;==============================================================================
;		Subroutin for 1/128s interrupt
;==============================================================================
;This routin is called from 1/128s interrupt(use timer interrupt for PF)
rtc_intsub:

		cmp	(DELAY_CT),0
		j	eq,rtc_ints0
		dec	(DELAY_CT)
rtc_ints0:
;V2.05		inc	(BLK_CT)
;V2.05		@BBS	(IC_PROG,rtc_ints1)	;V1.23
;V2.05		@BBC	(RTC_SET,rtc_ints9)
;V2.05rtc_ints1:
;V2.05		ld	a,(BLK_CT)
;v1.25		inc	(BLK_CT)
;V2.05		and	a,0y01111111
;V2.05		cmp	a,0x00
;V2.05		j	ne,rtc_ints2
;1.22		ld	c,(PTR)
;1.22		ld	hl,tbl_blk_d
;1.22		@BBS	(RTC_TIM,rtc_ints1)
;1.22		@BBC	(RTC_YMD,rtc_ints1)
;1.22		ld	hl,tbl_blk_d_ymd	;date mode & ymd format
;V1.22rtc_ints1:
;V1.22		ld	a,(hl+c)
;V1.22		ld	(BLK_D),a
;V2.00		ld	(LCDCTL1),0y10000101	;1/4 duty, REFV V4,=VDD, Booster circuit disable, LCD display enable
;V2.00		ld	(LCDCTL2),0y00000001	;base frequency for frame frequency 8M
;V2.05		j	rtc_ints4
;V2.05rtc_ints2:		
;V2.05		cmp	a,0x40
;V2.05		j	ne,rtc_ints9
;V1.22		ld	(BLK_D),0xff
;V2.00		ld	(LCDCTL1),0y10000100	;1/4 duty, REFV V4,=VDD, Booster circuit disable, LCD display enable

;rtc_ints4:
		@BBC	(RTC_ON,rtc_ints8)	;V1.23
;V1.23		call	temp_edit_d			;tempolary register for set RTC edit and transfer to DISP
		call	disp_to_dbr			;DBR update (DISP -> DBR)
		jp	rtc_ints9	;V1.23
rtc_ints8:
		@BBC	(F_ICDSP,rtc_ints9)	;V2.05
		call	ic_display	;V1.23
rtc_ints9:		
		ret

tbl_blk_d:
		db	4			;
		db	5			;
		db	7			;
		db	8			;
		db	10			;
		db	11			;
		db	12			;
		db	13			;
tbl_blk_d_ymd:
		db	4			;
		db	5			;
		db	6			;
		db	7			;
		db	9			;
		db	10			;
		db	12			;
		db	13			;

;wait routine...................................1.28ms for base counter
wait_1s:
		ld	(DELAY_CT),78		;78.15x1.28ms=1s
		j	wait_xms
wait_500ms:
		ld	(DELAY_CT),39		;39.0625x1.28=0.5s
		j	wait_xms
wait_300ms:
		ld	(DELAY_CT),23		;23.4375x1.28ms -> 300ms
		j	wait_xms
wait_100ms:
		ld	(DELAY_CT),8		;7.8125msx1.28 -> 100ms
		j	wait_xms
wait_50ms:
		ld	(DELAY_CT),4		;3.90625x1.28ms-> 50ms
wait_xms:
		cmp	(DELAY_CT),0
		j	ne,wait_xms
		ret

;==============================================================================
;		Real time clock interrupt
;==============================================================================
init_rtc:
		@BBS	(NO_CLK,init_rtc_end)	;V2.05
		ld	(SYSCR2),0y11000000	;XEN=1,XTEN=1 (high-frequency and low-frequency iscillator
		ld	(TBTCR),0y00010001	;(DV7CK=1 TBTCK=001) -> select 1/4sec interrupt, 
		ld	(TBTCR),0y00011001	;TBTEN=1
		di				;V2.05
		set	(EIRL).EF7		;time base interrupt enable
		ei				;v2.05
		ld	(RTC_CK),0		;RTC sub counter
		@SEB	(RTC_INIT)		;V1.46
init_rtc_end:					;V2.05
		ret

rtc_int:
		
		inc	(RTC_CK)
		cmp	(RTC_CK),4
		j	ge,rtc_int0
		reti
rtc_int0:
		@PUSH_REG
		ld	(RTC_CK),0
		ld	hl,SEC
		ld	a,(hl)
		add	a,1
		daa	a
		cmp	a,0x60
		j	lt,rtc_int_8
		ld	(hl),0			;clear SEC
		ld	hl,MIN
		ld	a,(hl)
		add	a,1
		daa	a
		cmp	a,0x60
		j	lt,rtc_int_8
		ld	(hl),0			;clear MIN
		ld	hl,HOUR
		ld	a,(hl)
		add	a,1
		daa	a
		cmp	a,0x24
		j	lt,rtc_int_8
		ld	(hl),0			;clear HOUR
		ld	hl,DAY
		ld	a,(hl)
		add	a,1
		daa	a
		ld	c,(MON)
		ld	w,(YEAR)
		call	leap_year		;check whether DAY is 29/30/31/32?
		j	le,rtc_int_8
		ld	(hl),1			;clear DAY
		ld	hl,MON
		ld	a,(hl)
		add	a,1
		daa	a
		cmp	a,0x13
		j	lt,rtc_int_8
		ld	(hl),1			;clear MONTH
		ld	hl,YEAR
		ld	a,(hl)
		add	a,1
		daa	a
		cmp	a,0x56			;virtual from year2005-year2056 
		j	lt,rtc_int_8
		ld	a,5			;return first YEAR
rtc_int_8:
		ld	(hl),a			;store increment each clock data
;V2.16		@BBS	(IO_MT,rtc_int_9)	;v1.21
		@BBS	(IO_MT,rtc_int_9)	;v2.23
		@BBC	(RTC_ON,rtc_int_9)	;RTC mode? no -> doesn't refresh
;V1.51		@BBS	(RTC_SET,rtc_int_9)	;RTC set mode? yes -> doesn't refresh
		@BBS	(RTC_CHK,rtc_int_9)	;V1.51
		call	rtc_edit_d		;RTC data edit and transfer to DISP
		call	disp_to_dbr		;DBR update (DISP -> DBR)
rtc_int_9:
		@POP_REG
		reti



;input: reg.a <- day
;	reg.c <- month
;	reg.w <- year
leap_year:
		cmp	c,2			;Feb?
		j	ne,not_leap_y		;no ->
		cmp	w,0x00			;reg.w (year)
		j	eq,leap_y
		cmp	w,0x04
		j	eq,leap_y
		cmp	w,0x08
		j	eq,leap_y
		cmp	w,0x12
		j	eq,leap_y
		cmp	w,0x16
		j	eq,leap_y
		cmp	w,0x20
		j	eq,leap_y
		cmp	w,0x24
		j	eq,leap_y
		cmp	w,0x28
		j	eq,leap_y
		cmp	w,0x32
		j	eq,leap_y

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -