RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
I2C Real-Time Clock Demo

This demo (rtcDemo directory) shows how to use the on-board PCF8523 RTC module on the Ti375C529 FPGA. The demo allows the user to change various configurations such as real-time data with a convertible 12/24hr time system, alarm, and battery settings of the PCF8523 module when the main menu feature is enabled, otherwise it will print the real-time data every few seconds.

For more details on the driver API, refer to Real Time Clock (RTC) Driver.

Newlib

By default, newlib-nano is used for this demo.

See also
User Debug Configuration - To learn more about User Debug Configuration.

Switching RTC Driver

In userDef.h, the available RTC drivers are defined as follows:

/* -------------------------------------------------------------------------*/
/* SENSOR Selection
/* -------------------------------------------------------------------------*/
// --- RTC Selection ---
#define RTC_TYPE_PCF8523 1
#define RTC_TYPE_DS3231 2
#define RTC_TYPE_CUSTOM 3 // User's custom RTC
/* --- Add custom driver here or in main.c --- */
// #include "rtc/device/customRTC.h"
// #define RTC_CTRL RTC_customRTC_ADDR
// #define RTC_DRIVER customRTC_driver
// User Selects Here:
#define ACTIVE_RTC_TYPE RTC_TYPE_PCF8523

To switch the RTC driver, modify ACTIVE_RTC_TYPE to the desired type.

Each selection automatically maps to the corresponding RTC_CTRL(I2C address) and RTC_DRIVER(Driver implementation).

ACTIVE_RTC_TYPE Driver Description
RTC_TYPE_PCF8523 PCF8523 Default on-board RTC (Ti375C529)
RTC_TYPE_DS3231 DS3231 External high-accuracy RTC module
RTC_TYPE_CUSTOM User-defined Bring user's own RTC driver

Integrating a Custom RTC Driver

To integrate a custom RTC driver into the framework, follow these steps:

Step 1 — Align custom driver to the RTC framework

Ensure custom driver implements the rtc_api_t interface for seamless integration.

Step 2 — Register custom driver in userDef.h

Uncomment and update the custom driver section:

#include "rtc/device/customRTC.h"
#define RTC_CTRL RTC_customRTC_ADDR
#define RTC_DRIVER customRTC_driver

Step 3 — Select the custom driver

#define ACTIVE_RTC_TYPE RTC_TYPE_CUSTOM

Execution Sequence

The following shows the expected execution sequence:

************Rtc Demo Main Menu***************
Please key in the selection and press enter:
1: Check Time 2: Configure Time
3: Change TimeSystem (12/24hrs)
*****************************************