Supported ICs

IC

RTL8721Dx

RTL8726E

RTL8720E

RTL8730E

Supported

Y

N

N

N

Introduction

The RTC_IO module is designed to store RTC time and temporarily log power-off duration during chip power-off periods. After repowering the system, the stored time data and counters from the power-off period can be retrieved through specific procedures.

By reading back the time information, the current time can be calculated and synchronized with the RTC module, ensuring uninterrupted timekeeping even during power interruptions.

Hardware connections

To maintain RTC_IO power supply during chip power-off, implement the following connections using Dupont lines:

  • Connect the power supply pin of VDH_RTC to 3.3V power supply

  • Connect the GND pin of the development board to the common ground of the 3.3V power supply

Application Scenario

There are two sceneries of using the RTC_IO module:

  • First-time power on

  • Repower on

First-time power on

For the first-time power on, follow these steps:

  1. Write 6’d0 (Reset) to register rtc_io_test_din bit field, and shift into RTC_IO.

    RTCIO_SetRValue(RTCIO_RECV_RVAL_RST);
    
  2. Perform 131K calibration to obtain calibration parameter which will be shifted into RTC_IO.

    OSC131K_Calibration(30000);
    
  3. Acquire the RVAL produced by Step 2 and shift into RTC_IO.

    RTCIO_SetRValue(RTCIO_RECV_RVAL_CAL);
    
  4. Prepare time data that will be set to the device through the RTC module.

    RTC_TimeTypeDef RTC_TimeStruct;
    RTC_TimeStructInit(&RTC_TimeStruct);
    RTC_TimeStruct.RTC_Year = 2024;
    RTC_TimeStruct.RTC_Hours = 10;
    RTC_TimeStruct.RTC_Minutes = 20;
    RTC_TimeStruct.RTC_Seconds = 30;
    
  5. Initialize and enable RTC module.

    RCC_PeriphClockCmd(APBPeriph_RTC, APBPeriph_RTC_CLOCK, ENABLE);
    RTC_StructInit(&RTC_InitStruct);
    RTC_Init(&RTC_InitStruct);
    RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
    

Repower on

In case of the chip repower on, but RTC_IO domain keeps powering on during power off period, it is supposed to follow these steps:

  1. Check the BOOT_Reason() return value.

    Continue the next steps when return 0, otherwise do nothing.

  2. Check the RTCIO_IsEnabled() return value.

    Continue the next steps when return TRUE, otherwise perform the procedures as mentioned above for the first time power on.

  3. Shift out the stored time data and counter during power off period.

    RTCIO_TimeInfo RTCIO_TimeStruct;
    RTC_TimeTypeDef RTC_TimeStruct;
    if(BOOT_Reason() == 0)
    {
    if (RTCIO_IsEnabled() == TRUE)
    {
    /* shift out bkup data */
    RTCIO_GetTimeInfo(&RTCIO_TimeStruct);
    /* calculate new Time */
    app_calc_new_time(&RTCIO_TimeStruct, &RTC_TimeStruct);
    }
    }
    
  4. Calculate new time through the struct RTCIO_TimeStruct, and the result store into struct RTC_TimeStruct. The later will be set to the device.

    The function app_calc_new_time() is just an example. It should be achieved according to actual application.

  5. Initialize and enable the RTC module again as the Step 5 in first time power on, and set the above calculated new time to device.