8. Real Time Clock (RTC)

8.1 Introduction

The Real Time Clock (RTC) is a feature that can keep counting the time using external back-up battery when main system power-off. In this design a 32-bits counter is implemented for second counting. The conversion from second to time and date is calculated by software.
This design also provides an alarm feature that can be used to allow main system to 'wake up' after shut down to execute tasks in a certain moment. The alarm setting in seconds, the conversion from time and date to second is calculated by software.
Back-up power source can used a Super Cap or a coin battery (like CR2032), and build-in charging circuit without any external component.
The control registers locate at RGST Table Group116 registers which memory map address are 0x9C003A00~0x9C003A7F. The SP7021 RTC function include below features.

  • Sustain more than one year with 250ma-H battery.
  • RTC with alarm timer module has its own interrupt signal internally . 
  • Backup power failure flag (Group116.16 bit9 bat_pg_o & bit8 supply_PG_o) to indicate the RTC information is not reliable when V-battery is lower than safe voltage. User can read the flag to monitor battery status.


8.2 Function Diagram

A generalized function diagram of RTC is shown in Figure 8-1.

Figure 8-1 RTC Functional Blocks
RTC operates in two modes that are normal and back-up mode.
In the normal mode, when system power on, the power supply is come from VDD33. System can get current time from REG-bus and can set alarm time by REG-bus.
In the back-up mode, when system power off, the backup domain power supply by supper CAP or battery. The main system can be wake up when alarm alert.

8.3 Battery Charge Control

The bat_charge_en bit set 1 can enable battery charger, this function default is disable. There have charge resistor and protect diode circuits in this block. The bat_charge_rsel bits can choose charge resistor value and bat_charge_dsel bit can choose the path with or without diode.
The control register is Group 116.23 rtc_batt_charge_ctrl.

8.4 RTC Alarm Operation

Set alarm_en_overdue bit to 1 can enable alarm function. System can get current time from Group 116.17 rtc_timer_out register. Set alarm_en bit to 1 can enable alarm for system function. System can set alarm time from Group 116.19 rtc_timer_set register. The timer count value output at 1Hz to digital. The control register is Group 116.16 rtc_ctrl.



8.5 Registers Map

8.5.1 Registers Memory Map

Address

Group No.

Register Name

Description

0x9C003A00

G116.0

Reserved

Reserved

0x9C003A04

G116.1

Reserved

Reserved

0x9C003A08

G116.2

Reserved

Reserved

0x9C003A0C

G116.3

Reserved

Reserved

0x9C003A10

G116.4

Reserved

Reserved

0x9C003A14

G116.5

Reserved

Reserved

0x9C003A18

G116.6

Reserved

Reserved

0x9C003A1C

G116.7

Reserved

Reserved

0x9C003A20

G116.8

Reserved

Reserved

0x9C003A24

G116.9

Reserved

Reserved

0x9C003A28

G116.10

Reserved

Reserved

0x9C003A2C

G116.11

Reserved

Reserved

0x9C003A30

G116.12

Reserved

Reserved

0x9C003A34

G116.13

Reserved

Reserved

0x9C003A38

G116.14

Reserved

Reserved

0x9C003A3C

G116.15

Reserved

Reserved

0x9C003A40

G116.16

rtc ctrl

RTC Control

0x9C003A44

G116.17

rtc timer out

Get Timer

0x9C003A48

G116.18

rtc divider cnt  out

Get Divider Cnt

0x9C003A4C

G116.19

rtc timer set

Set Timer

0x9C003A50

G116.20

rtc alarm  set

Set Alarm

0x9C003A54

G116.21

rtc user  data

User Data Keep

0x9C003A58

G116.22

rtc reset record

Get Reset Records

0x9C003A5C

G116.23

rtc batt charge  ctrl

Battery Charge Control

0x9C003A60

G116.24

Reserved

Reserved

0x9C003A64

G116.25

Reserved

Reserved

0x9C003A68

G116.26

Reserved

Reserved

0x9C003A6C

G116.27

Reserved

Reserved

0x9C003A70

G116.28

Reserved

Reserved

0x9C003A74

G116.29

Reserved

Reserved

0x9C003A78

G116.30

Reserved

Reserved

0x9C003A7C

G116.31

rtc ip version

IP Version

8.5.1 Registers Description

RGST Table Group 116 RTC

116.0 Reserved (Reserved)
Address: 0x9C003A00
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.1 Reserved (Reserved)
Address: 0x9C003A04
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.2 Reserved (Reserved)
Address: 0x9C003A08
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.3 Reserved (Reserved)
Address: 0x9C003A0C
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.4 Reserved (Reserved)
Address: 0x9C003A10
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.5 Reserved (Reserved)
Address: 0x9C003A14
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.6 Reserved (Reserved)
Address: 0x9C003A18
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.7 Reserved (Reserved)
Address: 0x9C003A1C
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.8 Reserved (Reserved)
Address: 0x9C003A20
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.9 Reserved (Reserved)
Address: 0x9C003A24
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.10 Reserved (Reserved)
Address: 0x9C003A28
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.11 Reserved (Reserved)
Address: 0x9C003A2C
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.12 Reserved (Reserved)
Address: 0x9C003A30
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.13 Reserved (Reserved)
Address: 0x9C003A34
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.14 Reserved (Reserved)
Address: 0x9C003A38
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.15 Reserved (Reserved)
Address: 0x9C003A3C
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.16 RTC Control (rtc ctrl)
Address: 0x9C003A40
Reset: 0x0000 000b

Field NameBitAccess

Description

Bit Write Mask31:16RW
Reserved15:14RO
bat cmp hyt13:12RW

The hysteresis window select of comparator which is used to detect VBAT is greater than 1.9V

2'b00: 11mV (default)
2'b01: 19mV
2'b10: 29mV
2'b11: 39mV

supply cmp hyt11:10RW

The hysteresis window select of comparator which is used to detect AVDD33  is greater than 2.2V

2'b00: 11mV (default)
2'b01: 19mV
2'b10: 29mV
2'b11: 39mV

bat_pg_o9RO

Detect VBAT is greater than 1.9V

0: VBAT <1.9V
1: VBAT > 1.9V

supply_pg_o8RO

Detect AVDD33 is greater than 2.2V

0: AVDD33<2.2V
1: AVDD33 > 2.2V

Reserved7:6RO
timer_freeze5RW

Timer Freeze

0: none (default)
1: freeze

DIS_SYS_RST_RTC4RW

Disable System Reset RTC

0: enable (default)
1: disable

rtc32k_mode_reset3RW

Reset rtc32k (analog)

0: The counter of RTC32K will go on (default)

1: Reset the counter of RTC32K

After reset,read G116.17(rtc timer out) value, check reset or not

alarm_en_overdue2RW

Enable Alarm (current time > alarm time)

0: disable (default)
1: enable

alarm_en_pmc


1RWEnable Alarm for PMC
0: disable (default)
1: enable
alarm_en0RWEnable Alarm for system
0: disable (default)
1: enable



116.17 Get Timer (rtc timer out)
Address: 0x9C003A44
Reset: 0x0000 0000


Field NameBitAccessDescription
timer_out31RO32bit timer count value output at 1Hz to digital



116.18Get Divider Cnt (rtc divider cnt out)
Address: 0x9C003A48
Reset: 0x0000 0000


Field NameBitAccessDescription
Reserved31:16RO
Reserved15RO
divider_cnt_out14:0RODivider count value output at 32768Hz to digital 0˜32767



116.19 Set Timer (rtc timer set)
Address: 0x9C003A4C
Reset: 0x0000 0000



Field NameBitAccessDescription
timer_set31:0RW



116.20 Set Alarm (rtc alarm set)
Address: 0x9C003A50
Reset: 0x0000 0000


Field NameBitAccessDescription
alarm_set31:0RWSet alarm



116.21 User Data Keep (rtc user data)
Address: 0x9C003A54
Reset: 0x0000 0000


Field NameBitAccessDescription
Bit_Write_Mask31:16RW
user_data15:0RWUser data



116.22 Get Reset Records (rtc reset record)
Address: 0x9C003A58
Reset: 0x0000 0000

HW will update "reset_record" bits before reset , so user can check this item to know the reset reason.

Field NameBitAccessDescription
Reserved31:16RO
Reserved15:12RO
reset_record

11:0

RW

Reset record

bit0 : EXT RST B POR

External Power on Reset

bit1 : MO SYSTEM RST B

System Software Reset

bit2 : IOP SYS RST B

bit3 : RI WATCHDOG SYS RST B

bit4 : STC WATCHDOG SYS RST B

bit5 : STC WATCHDOG2 SYS RST B

bit6 : IOP WATCHDOG SYS RST B

bit7 : LVD RSTB

bit8 : POR RST B POR

bit9˜11 : N/A



116.23 Battery Charge Control (rtc batt charge ctrl)
Address: 0x9C003A5C
Reset: 0x0000 0000



Field NameBitAccessDescription
Bit Write Mask31:16RW
Reserved15:4RO
bat_charge_rsel3:2RW

Choose charge resistor path

2'b00: 200 Ohm resistor path (default)
2'b01: 2K Ohm resistor path
2'b10: 4K Ohm resistor path
2'b11: No connect (floating)

bat_charge_dsel1RW

Choose the path with / without diode

0: with diode (default)
1: without diode

bat_charge_en0RWBattery charger
0: disable (default)
1: enable



116.24 Reserved (Reserved)

Address: 0x9C003A60
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.25 Reserved (Reserved) 
Address: 0x9C003A64
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO



116.26 Reserved (Reserved)
Address: 0x9C003A68
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.27 Reserved (Reserved)
Address: 0x9C003A6C
Reset: 0x0000 0000


Field Name

Bit

Access

Description

Reserved

31:0

RO




116.28 Reserved (Reserved)
Address: 0x9C003A70
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.29 Reserved (Reserved)
Address: 0x9C003A74
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.30 Reserved (Reserved)
Address: 0x9C003A78
Reset: 0x0000 0000

Field Name

Bit

Access

Description

Reserved

31:0

RO




116.31 IP Version (rtc ip version)
Address: 0x9C003A7C
Reset: 0x0000 0000



Field Name

Bit

Access

Description

ip_version

31:0

RO

0xyyymcdee

yyy : year (eg 0X018)

m : month (0x1˜0XC)

c : Main classification (BCD : 1˜9)

d : classification (BCD : 0˜9)

ee: Least classification (BCD : 00˜99)