初学者
10 分钟

实现基于 RV-8263-C8 和 STM32L496AG 的精准实时时间追踪

适用于嵌入式项目的低功耗实时时间追踪解决方案

RTC 15 Click with Discovery kit with STM32L496AG MCU

已发布 7月 22, 2025

点击板

RTC 15 Click

开发板

Discovery kit with STM32L496AG MCU

编译器

NECTO Studio

微控制器单元

STM32L496AG

在嵌入式项目中使用超低功耗实时时钟模块,实现精准的时间和日期追踪

A

A

硬件概览

它是如何工作的?

RTC 15 Click 基于 Micro Crystal 推出的 RV-8263-C8,这是一款标准的商用级实时时钟/日历模块,以其超低功耗和高精度而闻名。该 CMOS 器件以 32.768kHz 晶振运行,内置偏移寄存器,可微调频率偏差,确保在长期应用中实现可靠的时间保持。它通过 I2C 接口与主控 MCU 通信,支持自动寄存器地址递增,提升数据访问效率。尽管体积小巧、重量极轻,该模块依然提供完整的日历功能,包括对年份、月份、日期、星期、小时、分钟和秒的追踪,并支持 2000 至 2099 年间的自动闰年校正。此外,还内建定时器和闹钟功能,适用于物联网系统、工业与汽车应用、计量设备、医疗装置及可穿戴与便携式电子产品等多种场景。RTC 15 Click 采用 MIKROE 最新引入

的 Click Snap 结构设计。与标准 Click 板不同,ClickSnap 允许用户将主传感器区域从 PCB 上拆分出来,形成可独立使用的 Snap 子板,从而大幅拓展应用灵活性。拆分后,RV-8263-C8 可通过标记为 1–8 的引脚直接获取所需信号,实现独立运行。Snap 区域还包含一个固定位置的螺丝孔,便于用户将其固定在目标位置。该 Click 板™ 支持最高 400kHz 的 I2C 通信速度,确保与主控 MCU 的快速数据交换。除了 I2C 引脚外,还包含 EN 引脚,用于控制板载 MAX40200 理想二极管(此处作为电源开关使用),以及 INT 中断引脚,用于输出闹钟、中断计时、半分钟或分钟中断、倒计时和补偿中断信号。EN 引脚激活时,MAX40200 向传感器供电,使传感器可根据需要

进行启用或关闭,特别适用于低功耗和电池供电应用。此外,RTC 15 Click 提供未焊接的 OUT 引脚,用于输出时钟信号,并可通过 CLE 引脚控制。当 CLE 引脚为高电平时,OUT 引脚会输出可选方波信号,频率包括 32.768kHz(默认)、16.384kHz、8.192kHz、4.096kHz、2.048kHz、1.024kHz 或 1Hz,满足不同的定时需求;若 CLE 引脚为低电平,则 OUT 引脚保持低电平,关闭时钟输出。本板支持 3.3V 或 5V 逻辑电平,通过 VCC SEL 跳线进行选择,确保兼容不同电压等级的 MCU。此外,该 Click 板™ 还附带配套的软件库及示例代码,为后续开发提供便利。

RTC 15 Click hardware overview image

功能概述

开发板

32L496GDISCOVERY Discovery 套件是一款功能全面的演示和开发平台,专为搭载 Arm® Cortex®-M4 内核的 STM32L496AG 微控制器设计。该套件适用于需要在高性能、先进图形处理和超低功耗之间取得平衡的应用,支持无缝原型开发,适用于各种嵌入式解决方案。STM32L496AG 采用创新的节能架构,集成

了扩展 RAM 和 Chrom-ART 图形加速器,在提升图形性能的同时保持低功耗,使其特别适用于音频处理、图形用户界面和实时数据采集等对能效要求较高的应用。为了简化开发流程,该开发板配备了板载 ST-LINK/V2-1 调试器/编程器,提供即插即用的调试和编程体验,使用户无需额外硬件即可轻松加载、调

试和测试应用程序。凭借低功耗特性、增强的内存能力以及内置调试工具,32L496GDISCOVERY 套件是开发先进嵌入式系统、实现高效能解决方案的理想选择。

Discovery kit with STM32L496AG MCU double side image

微控制器概述 

MCU卡片 / MCU

STM32L496AG Image

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

STMicroelectronics

引脚数

169

RAM (字节)

327680

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Device Enable
PB2
RST
ID COMM
PG11
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Clock Output Enable
PA0
PWM
Interrupt
PH2
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB8
SCL
I2C Data
PB7
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

RTC 15 Click Schematic schematic

一步一步来

项目组装

Discovery kit with STM32H750XB MCU front image hardware assembly

从选择您的开发板和Click板™开始。以Discovery kit with STM32L496AG MCU作为您的开发板开始。

Discovery kit with STM32H750XB MCU front image hardware assembly
Thermo 21 Click front image hardware assembly
Prog-cut hardware assembly
Thermo 21 Click complete accessories setup image hardware assembly
Board mapper by product7 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Discovery kit with STM32H750XB MCU NECTO MCU Selection Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto image step 11 hardware assembly

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

RTC 15 Click 演示应用程序使用 NECTO Studio开发,确保与 mikroSDK 的开源库和工具兼容。该演示设计为即插即用,可与所有具有 mikroBUS™ 插座的 开发板、入门板和 mikromedia 板完全兼容,用于快速实现和测试。

示例描述
本示例演示如何使用 RTC 15 Click 板,初始化设备并设置当前的时间与日期。程序通过定时器倒计时中断引脚,每秒持续读取并显示更新后的时间与日期。

关键功能:

  • rtc15_cfg_setup - 初始化 Click 配置结构为默认初始值。

  • rtc15_init - 初始化使用此 Click 板所需的所有引脚和外设。

  • rtc15_default_cfg - 执行 RTC 15 Click 板的默认配置。

  • rtc15_set_time - 设置 RTC 当前时间(小时、分钟、秒)。

  • rtc15_read_time - 读取 RTC 当前时间(小时、分钟、秒)。

  • rtc15_read_date - 读取 RTC 当前日期(日、星期、月、年)。

应用初始化
初始化日志模块和 RTC 15 Click 驱动器,应用默认配置,并设置起始时间与日期。

应用任务
等待 1Hz 中断信号触发后,读取并显示当前的时间与日期。

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief RTC 15 Click example
 *
 * # Description
 * This example demonstrates the use of the RTC 15 Click board by initializing
 * the device and setting up the current time and date. It continuously
 * reads and displays the updated time and date every second using the timer
 * countdown interrupt pin.
 *
 * The demo application is composed of two sections:
 *
 * ## Application Init
 * Initializes the logger and the RTC 15 Click driver, applies the default configuration,
 * and sets the starting time and date.
 *
 * ## Application Task
 * Waits for a 1 Hz interrupt signal and then reads and displays the current time and date.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "rtc15.h"

static rtc15_t rtc15;
static log_t logger;
static rtc15_time_t time;
static rtc15_date_t date;

/**
 * @brief RTC 15 get day of week name function.
 * @details This function returns the name of day of the week as a string.
 * @param[in] ctx : Click context object.
 * See #rtc15_t object definition for detailed explanation.
 * @param[in] day_of_week : Day of week decimal value.
 * @return Name of day as a string.
 * @note None.
 */
static uint8_t *rtc15_get_day_of_week_name ( uint8_t day_of_week );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rtc15_cfg_t rtc15_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    rtc15_cfg_setup( &rtc15_cfg );
    RTC15_MAP_MIKROBUS( rtc15_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc15_init( &rtc15, &rtc15_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( RTC15_ERROR == rtc15_default_cfg ( &rtc15 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    time.hour = 23;
    time.minute = 59;
    time.second = 50;
    if ( RTC15_OK == rtc15_set_time ( &rtc15, &time ) )
    {
        log_printf( &logger, " Set time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    date.day_of_week = RTC15_TUESDAY;
    date.day = 31;
    date.month = 12;
    date.year = 24;
    if ( RTC15_OK == rtc15_set_date ( &rtc15, &date ) )
    {
        log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc15_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }

    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    // Wait for a timer countdown flag configured at 1 Hz
    while ( rtc15_get_int_pin ( &rtc15 ) );

    if ( RTC15_OK == rtc15_read_time ( &rtc15, &time ) )
    {
        log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    if ( RTC15_OK == rtc15_read_date ( &rtc15, &date ) )
    {
        log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n\n", 
                    rtc15_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
    Delay_ms ( 100 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static uint8_t *rtc15_get_day_of_week_name ( uint8_t day_of_week )
{
    switch ( day_of_week )
    {
        case RTC15_MONDAY:
        {
            return "Monday";
        }
        case RTC15_TUESDAY:
        {
            return "Tuesday";
        }
        case RTC15_WEDNESDAY:
        {
            return "Wednesday";
        }
        case RTC15_THURSDAY:
        {
            return "Thursday";
        }
        case RTC15_FRIDAY:
        {
            return "Friday";
        }
        case RTC15_SATURDAY:
        {
            return "Saturday";
        }
        case RTC15_SUNDAY:
        {
            return "Sunday";
        }
        default:
        {
            return "Unknown";
        }
    }
}

// ------------------------------------------------------------------------ END

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。