All About Circuits

Industry White Paper

Tracking Time and Date: Implementing a Real-Time Clock on the FPB-RA8E1

Learn how to configure the real-time clock on the Renesas FPB-RA8E1 using e² studio and FSP to set the date and time and watch the calendar roll over to a new year in real time.


October 09, 2026 by Renesas Electronics

When your embedded device needs to log data or trigger events at specific intervals, relying on simple software delays is not enough. You need a dedicated hardware mechanism that tracks the actual calendar date and time.

This walkthrough demonstrates how to configure the real-time clock (RTC) using the r_rtc module on the Renesas FPB-RA8E1 Fast Prototyping Board. Using the e² studio IDE and the Flexible Software Package (FSP), you will configure the RTC to use the low-speed on-chip oscillator (LOCO), write a C function to accept user time inputs, and continuously stream the updated calendar values to a terminal.

 

Project Specs

Target Board FPB-RA8E1
MCU Family Renesas RA8 Series
Peripheral Covered Realtime Clock (r_rtc)
IDE/Toolchain e² studio + FSP v6.2.0
Interface Used SEGGER J-Link RTT Viewer
Baud Rate N/A
Skill Level Intermediate
Build Time 25 minutes
Prerequisites e² studio installed, SEGGER RTT Viewer installed

 

Why Tracking Hardware Time Matters

A hardware real-time clock ensures your microcontroller can maintain accurate timestamps. The r_rtc module tracks everything from individual seconds up to years and automatically handles calendar transitions.

Without this dedicated peripheral, generating accurate chronological logs becomes incredibly difficult. Once you know how to configure the real-time clock and pass values into its standard data structures, you ensure your hardware can accurately map its operations to the real world.

 

What You'll Need

Hardware

 

Software

 

The Concept in 60 Seconds

The r_rtc module functions primarily as a real-time clock, providing accurate time data to the program. It uses a standard C structure called tm to manage individual fields like hours, days, and years. You supply a baseline starting time through the software, and the hardware peripheral takes over, counting forward automatically. You then use FSP commands to extract the current values from the peripheral and present them to the user.

 

Step-by-Step: Building the Project

Step 1: Create a Minimal Bare Metal Project

  1. Navigate to File > New > Renesas C/C++ Project > Renesas RA C/C++ Project > Renesas RA Project in your e² studio IDE.
  2. Name the project FPB_RA8E1_RTC and target the FPB-RA8E1 board using FSP version 6.2.0.
  3. Select a Flat Non-TrustZone project structure, select Executable and No RTOS, and choose the Bare Metal - Minimal template.

 

Figure 1. Selecting the FPB-RA8E1 board in the e² studio project setup. Image used courtesy of Renesas

 

Starting with a minimal, flat project ensures that no unnecessary RTOS overhead or TrustZone complexity interferes with your real-time clock configuration.

 

Step 2: Add the Realtime Clock Peripheral Stack

  1. Open the FSP Configuration perspective and navigate to the Stacks tab. Click on New Stack, hover over the Timers category, and select the Realtime Clock (r_rtc) stack. Keep the default module name as g_rtc0.

Adding this module pulls the required hardware abstraction layer (HAL) drivers into your source code, allowing you to interface with the RTC registers without writing low-level bit-manipulation code.

 

Step 3: Configure the RTC Clock Source

  1. Click on the Realtime Clock stack to open its properties and locate the Clock Source property.
  2. Keep the selection as LOCO and click Generate Project Content.

 

Figure 2. The Realtime Clock stack properties with LOCO selected as the clock source. Image used courtesy of Renesas

 

While the sub-clock offers higher accuracy, the LOCO is a low-power option that doesn't require an external oscillator, making it an ideal clock source for this specific prototyping evaluation.

 

Step 4: Import RTT Logging and Utility Headers

  1. Download the required SEGGER RTT source files from the SEGGER website under the J-Link/J-Trace section. Copy the files into your project's source directory, alongside the rtc_ep.h and common_utils.h files. Include hal_data.h, common_utils.h, and rtc_ep.h at the top of your hal_entry.c file. The common_utils.h file contains the specific macros related to SEGGER RTT.
  2. Build the project to ensure everything is configured correctly.

These files provide the logging macros and terminal integration required to capture user input and print the calendar data.

 

Step 5: Write the RTC Initialization Function

  1. Declare an initialize_rtc function that calls R_RTC_Open, prompts the user to enter the date and time, and stores those inputs in a tm structure named set_time.
  2. Pass the address of this structure to the R_RTC_CalendarTimeSet function to configure the RTC using the provided values.

 

Figure 3. The fields of the standard C tm structure. Image used courtesy of Renesas

 

The peripheral must be explicitly opened with your FSP configurations before it can accept the baseline tm structure values required to begin tracking time.

 

Step 6: Retrieve and Log the Time Continuously

  1. Inside hal_entry, call initialize_rtc(), then call R_RTC_CalendarTimeGet and use an assert check to retrieve the initial time.
  2. Next, create a while(1) loop where you print the formatted values using APP_PRINT, execute a 3-second software delay using R_BSP_SoftwareDelay, and call R_RTC_CalendarTimeGet a second time to retrieve the updated time.

 

Figure 4. The initialize_rtc function passes the set_time structure to R_RTC_CalendarTimeSet. Image used courtesy of Renesas

 

Figure 5. The while loop prints the calendar time, waits three seconds, and retrieves the updated time. Image used courtesy of Renesas

 

Polling the RTC hardware continuously proves that the module is autonomously counting forward independently of the main CPU execution.

 

Step 7: Locate the Memory Address for the Terminal

  1. Click on your project name and click the hammer icon to build the project, then right-click your project name and launch a Renesas GDB Hardware Debugging session. When the "Confirm Perspective Switch" dialog appears, click Switch to open the Debug perspective.
  2. Open the generated .map file in your Debug folder, search for .bss._SEGGER_RTT, and copy the exact memory address listed next to this symbol because we need the RTT control block address to connect to the SEGGER RTT terminal.

 

Figure 6. Locating the SEGGER RTT memory address in the .map file. Image used courtesy of Renesas

 

The standalone SEGGER RTT Viewer requires this specific memory address to intercept the print statements over the debug interface.

 

Step 8: Connect the Viewer and Input the Time

  1. Open the SEGGER J-Link RTT Viewer, select the Address option, and paste the memory address into the RTT Control Block field.
  2. Connect to the board, click resume twice in e² studio, and navigate to Input > Sending... > Send on Enter in the RTT Viewer menu before entering your date and time values.

 

Code Snippet

// Print the calendar time
APP_PRINT("\r\n RTC calendar set to Date : %d/%d/%d Time : %d:%d:%d \r\n",
          get_time.tm_mday, get_time.tm_mon + MON_ADJUST_VALUE, get_time.tm_year + YEAR_ADJUST_VALUE,
          get_time.tm_hour, get_time.tm_min, get_time.tm_sec);
 
// Delay for 3 seconds
R_BSP_SoftwareDelay(3, BSP_DELAY_UNITS_SECONDS);
 
// Get updated time after every 3 seconds
err = R_RTC_CalendarTimeGet(&g_rtc0_ctrl, &get_time);
assert(FSP_SUCCESS == err);

 

What You Should See

After connecting the RTT Viewer and ensuring the "Send on Enter" option is enabled in the Input menu, the terminal will prompt you to enter the starting date and time. To observe a calendar transition, enter the year as 2025, the month as 12, the day as 31, the hour as 23, the minute as 59, and the second as 55.

The terminal will begin printing the updated time every three seconds. Because you set the time just a few seconds before midnight, you will observe how the RTC transitions into the new year (1/1/2026) in real time.

 

Figure 7. RTT Viewer output showing the RTC rolling over from 31/12/2025 to 1/1/2026. Image used courtesy of Renesas

 

Troubleshooting

The RTT Viewer Cannot Connect to the Board

When configuring the RTT Viewer connection, verify you have selected the correct target device part number. If the viewer software cannot find the specific R7FA8E1A72CFB device, try removing some characters from the end of the part name in the search field.

 

The Terminal Prompts Appear, but I Cannot Enter Any Values

Open the Input menu at the top of the SEGGER RTT Viewer window and make sure the "Send on Enter" option is actively checked. If this is disabled, your keystrokes will not transmit to the microcontroller.

 

The Printed Year and Month Values Are Completely Wrong

The tm_year field stores the number of years since 1900, and the tm_mon field stores months as a range from 0 to 11. Ensure you are applying the correct offset values (adding 1900 to the year and 1 to the month) when printing the data to the terminal.

 

Where to Take It Next

Now that you can successfully track and retrieve the current time, try configuring the r_rtc module to utilize its alarm and periodic notification features. You can set the hardware to trigger a custom interrupt callback function when the clock reaches a specific user-defined time. To explore the detailed capabilities of the RA8 family, review the documentation on the Renesas RA Family page.

 

Frequently Asked Questions

What Is the Difference Between LOCO and the Sub-Clock for the RTC?

The low-speed on-chip oscillator (LOCO) is a low-power option but offers lower accuracy. On the other hand, the sub-clock provides higher accuracy but requires an external oscillator and consumes more power.

 

What Is the tm Structure Used in the Code?

The tm structure is a standard C data structure used to store date and time values. It contains individual integer fields for seconds (tm_sec), minutes (tm_min), hours (tm_hour), day of the month (tm_mday), month (tm_mon), and year (tm_year).

 

Why Do We Have to Add Offsets to the Year and Month When Printing?

In the standard tm structure, the tm_year field only stores the number of years that have passed since the year 1900. Similarly, the tm_mon field represents months as an index ranging from 0 to 11. You must add offsets to display these values in a standard calendar format.

 

Related Resources