Overview
The Real-Time Clock (RTC) is an independent binary-coded decimal (BCD) timer/counter. It provides accurate date and time information with units of year, month, day, hour, minute, and second. The RTC uses internal OSC as clock source and continues operating as long as the supply voltage remains within working range, regardless of whether the device is in run mode or low-power mode.
Features
Manages time in seconds, minutes, hours (12/24-hour format), days, and years
Supports daylight saving time compensation
Provides digital calibration to compensate for fixed-direction deviations
Programmable alarm with interrupt capability, triggerable by any combination of time fields
Maskable interrupt/event types include:
Alarm
Day threshold
Wakeup timer
Register write protection mechanism
Supports low-power wakeup
Accuracy better than 2 seconds per day
Low-Power Operation
During sleep and deepsleep modes, the system periodically wakes the XTAL module (without system wakeup) to calibrate RTC clock source, ensuring RTC accuracy in low-power states.
RTC can wake the system through alarm interrupts and wakeup timer interrupts during sleep and deepsleep modes.
Power Supply
Implement a simple RTC_IO that continues timing based on original RTC time information after RTC circuit power loss. When RTC is repowered, software must reload the RTC_IO content into the RTC circuit.
The RTC_IO can be independently powered by VDH_RTC.
The RTC_IO cannot achieve the same accuracy level as the RTC circuit due to its uncalibrated clock source.
VDH_RTC is not brought out to a pin on all chips. Refer to the specific chip’s datasheet for availability.
It is powered by the system and has no independent power supply.
It is powered by the system and has no independent power supply.
It is powered by the system and has no independent power supply.
It is powered by the system and has no independent power supply.
RTC circuit and its clock source are powered by VDH_RTC. The RTC can continue counting when the system is powered off or reset.
VDH_RTC is not available on all chip pins. Refer to the chip datasheet for specific implementation details.
Year Register Handling
The RTC registers store the following time information:
Year (starting from 1900)
Day (day of year)
Hour
Minute
Second
The real-time clock has no internal leap year detection and cannot perform automatic carry-over from day to year. This requires software handling. Software can set day thresholds based on leap year information, triggering an interrupt when the day count reaches the threshold.
Application Examples
The SDK provides two types of functional examples to help developers understand and use RTC features:
mbed Examples
Path:
{SDK}\component\example\peripheral\mbed\RTC\{demo}
Demonstrates RTC control in mbed environment
Raw Examples
Path:
{SDK}\component\example\peripheral\raw\RTC\{demo}
Demonstrates direct RTC control without abstraction layer
Brief description of raw examples:
raw_rtc demonstrates RTC time setting and retrieval;
raw_rtc_alarm demonstrates RTC alarm interrupt usage.
Note
Check the README.md
file in each example directory for supported chips.
API Reference
For detailed API usage, refer to {SDK}\component\soc\amebaxxxx\fwlib\include\ameba_rtc.h
.