SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 73
Version 1.7
8.2.5
RTC OPERATION SEQUENCE (High_Clk =
“IHRC_RTC” and “T0TB = 1”)
T0 timer with RTC operation sequence
(High_Clk code option = “IHRC_RTC” and “T0TB = 1”
) of setup T0 timer is
as following.
Declare buffer.
.DATA
OLDT0C
DS
1
NEWT0C
DS
1
T0FLAG
DS
1
T0IRQFLAG
EQU
T0FLAG.0
Stop T0 timer counting, disable T0 interrupt function and clear T0 interrupt request flag.
B0BCLR
FT0ENB
; T0 timer.
B0BCLR
FT0IEN
; T0 interrupt function is disabled.
B0BCLR
FT0IRQ
; T0 interrupt request flag is cleared.
Set T0M register.
MOV
A, #00000000b
B0MOV
T0M,A
Set T0 clock source from RTC.
B0BSET
FT0TB
; Select T0 RTC clock source.
Set T0 interrupt interval time.
CLR
T0C
; Clear T0C value.
CLR
OLDT0C
; Clear OLDT0C value.
CLR
NEWT0C
; Clear NEWT0C value.
CLR
T0FLAG
; Clear T0FLAG before execute Main routing.
Disable T0 timer function mode.
B0BCLR
FT0IEN
; Disable T0 interrupt function.
Enable T0 timer with RTC function.
B0BSET
FT0ENB
; Enable T0 timer.
Execute MAIN routing polling T0 timer.(Execute MAIN routing interval time is not more than 200ms).
B0BCLR
FT0IRQ
; Clear FT0IRQ.
MAIN:
CALL
CKT_T0CVAL
; Check T0C value overflow
CALL
CKT_T0FLAG
; Check T0C overflow Flag and update time.
.
.
JMP
MAIN
; Jmp MAIN.
CKT_T0CVAL sub-routing (Check T0C value status).
CKT_T0CVAL:
MOV
A, T0C
; Read T0C value
MOV
NEWT0C, A
; Save to NEWT0C
SUB
A, OLDT0C
; A sub OLDT0C value.
B0BTS0
FC
; If FC = 0, borrow