RTC Overflow Function
This sample code guide is designed to help users easily and comprehensively understand RTC sample. This sample demonstrates RTC count overflow function.
Requirements
For hardware requirements, please refer to the Requirements.
Configurations
The following macros can be configured to modify the RTC prescaler value.
#define RTC_PRESCALER_VALUE 0
The entry function is as follows, call this function in
main()
to run this sample code. For more details, please refer to the Initialization.rtc_overflow_demo();
Building and Downloading
For building and downloading, please refer to the Building and Downloading.
Experimental Verification
Preparation Phase
Press the Reset button on the EVB, when the RTC counts to the maximum value, it will trigger an RTC interrupt:
For RTL87x3D,
rtc_handler
function is executed every 134217.728s.For RTL87x3E and RTL87x3EP,
rtc_handler
function is executed every 524.288s.
Code Overview
This section introduces the code and process description for initialization and corresponding function implementation in the sample.
Source Code Directory
For project directory, please refer to Source Code Directory.
Source code directory:
sdk\src\sample\io_demo\rtc\overflow\rtc_overflow_demo.c
.
Initialization
The initialization flow for peripherals can refer to Initialization Flow.
RTC overflow function initialization flow is shown in the following figure.

RTC Overflow Function Initialization Flow Chart
Call
RTC_DeInit()
to reset the RTC peripheral.Call
RTC_SetPrescaler()
to set the RTC prescaler.Call
RTC_MaskINTConfig()
to unmask the RTC overflow interrupt_RTC_INT::RTC_INT_OVF
.Call
NVIC_Init()
to enable NVIC of RTC.Call
RTC_RunCmd()
to enable the RTC.
Functional Implementation
Interrupt Handle
RTC interrupt handle flow is shown in the following figure.

RTC Interrupt Handle Flow Chart
When the RTC counts to the maximum value, it will trigger an RTC interrupt:
Call
RTC_GetINTStatus()
to check_RTC_INT::RTC_INT_OVF
interrupt status flag.Call
RTC_ClearOverFlowINT()
to clear the RTC overflow interrupt.