中级
30 分钟

体验PT7C4311和STM32F302VC带来的RTC卓越性能

时机就是一切:用我们的RTC解决方案提升您的项目

RTC 21 Click with CLICKER 4 for STM32F302VCT6

已发布 7月 22, 2025

点击板

RTC 21 Click

开发板

CLICKER 4 for STM32F302VCT6

编译器

NECTO Studio

微控制器单元

STM32F302VC

集成高效的实时时钟到您的解决方案中,实现精确的事件计时和无缝的同步。

A

A

硬件概览

它是如何工作的?

RTC 21 Click 基于 Diodes Incorporated 的 PT7C4311,这是一款超低功耗的实时时钟 (RTC) 设备。PT7C4311 配置为基于 32.768kHz 石英晶体向 MCU 传输日历和时间数据(24 小时格式),并带有 56 字节的通用 RAM。它以秒为单位从 MCU 读取和写入时钟/日历数据,直到日历年的最后两位数字,提供秒、分、小时、日期、星期几、月份、年份

和世纪信息。月底日期会自动调整为少于 31 天的月份,包括对 2100 年之前的闰年的修正。此 Click board™ 使用标准 I2C 2 线接口与 MCU 通信,以读取数据和配置设置,支持最高 400kHz 的快速模式操作。它还包含一个标记为 FT 的开漏输出,可用作频率测试信号(用于频率测试目的的 512Hz 方波)或在方波禁用时作为寄存器可配置的输出直流电平。

PT7C4311 还包括一个自动备用切换电路,允许其与单个纽扣电池一起使用,从而延长使用时间。此 Click board™ 可以在 3.3V 或 5V 逻辑电压水平下运行,通过 VCC SEL 跳线选择。这样,3.3V 和 5V 的 MCU 都可以正确使用通信线路。此外,该 Click board™ 配备了包含易于使用的函数和示例代码的库,可作为进一步开发的参考。

RTC 21 Click top side image
RTC 21 Click bottom side image

功能概述

开发板

Clicker 4 for STM32F3 是一款紧凑型开发板,作为完整的解决方案而设计,可帮助用户快速构建具备独特功能的定制设备。该板搭载 STMicroelectronics 的 STM32F302VCT6 微控制器,配备四个 mikroBUS™ 插槽用于连接 Click boards™、完善的电源管理功能以及其他实用资源,是快速开发各类应用的理想平台。其核心 MCU STM32F302VCT6 基于高性能 

Arm® Cortex®-M4 32 位处理器,运行频率高达 168MHz,处理能力强大,能够满足各种高复杂度任务的需求,使 Clicker 4 能灵活适应多种应用场景。除了两个 1x20 引脚排针外,板载最显著的连接特性是四个增强型 mikroBUS™ 插槽,支持接入数量庞大的 Click boards™ 生态系统,该生态每日持续扩展。Clicker 4 各功能区域标识清晰,界面直观简洁,极大

提升使用便捷性和开发效率。Clicker 4 的价值不仅在于加速原型开发与应用构建阶段,更在于其作为独立完整方案可直接集成至实际项目中,无需额外硬件修改。四角各设有直径 4.2mm(0.165")的安装孔,便于通过螺丝轻松固定。对于多数应用,只需配套一个外壳,即可将 Clicker 4 开发板转化为完整、实用且外观精美的定制系统。

CLICKER 4 for STM32F302VCT6 double image

微控制器概述 

MCU卡片 / MCU

STM32F302VC Image

建筑

ARM Cortex-M4

MCU 内存 (KB)

256

硅供应商

STMicroelectronics

引脚数

100

RAM (字节)

40960

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Frequency Test/DC Level
PD0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB10
SCL
I2C Data
PB11
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

RTC 21 Click Schematic schematic

一步一步来

项目组装

PIC32MZ MXS Data Capture Board front image hardware assembly

从选择您的开发板和Click板™开始。以CLICKER 4 for STM32F302VCT6作为您的开发板开始。

PIC32MZ MXS Data Capture Board front image hardware assembly
Thermo 21 Click front image hardware assembly
Thermo 21 Click complete accessories setup image hardware assembly
Board mapper by product6 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
PIC32MZ MXS Data Capture Board 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 21 Click 驱动程序的 API。

关键功能:

  • rtc21_set_time - 此功能设置起始时间值 - 秒、分和小时

  • rtc21_set_date - 此功能设置起始日期值 - 星期几、日、月和年

  • rtc21_read_time - 此功能读取当前时间值 - 秒、分和小时

开源

代码示例

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

/*!
 * @file main.c
 * @brief RTC 21 Click example
 *
 * # Description
 * This example demonstrates the use of RTC 21 Click board by reading and displaying
 * the time and date values.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger and then sets the starting time and date.
 *
 * ## Application Task
 * Reads and displays on the USB UART the current time and date values once per second.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "rtc21.h"

static rtc21_t rtc21;
static log_t logger;
static rtc21_time_t time;
static rtc21_date_t date;

/**
 * @brief RTC 21 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 #rtc21_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 *rtc21_get_day_of_week_name ( uint8_t day_of_week );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rtc21_cfg_t rtc21_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.
    rtc21_cfg_setup( &rtc21_cfg );
    RTC21_MAP_MIKROBUS( rtc21_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc21_init( &rtc21, &rtc21_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    time.hour = 23;
    time.minute = 59;
    time.second = 50;
    if ( RTC21_OK == rtc21_set_time ( &rtc21, &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 = RTC21_SATURDAY;
    date.day = 31;
    date.month = 12;
    date.year = 22;
    if ( RTC21_OK == rtc21_set_date ( &rtc21, &date ) )
    {
        log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc21_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
    Delay_ms ( 100 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    if ( RTC21_OK == rtc21_read_time ( &rtc21, &time ) )
    {
        log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    if ( RTC21_OK == rtc21_read_date ( &rtc21, &date ) )
    {
        log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc21_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
    Delay_ms ( 1000 );
}

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 *rtc21_get_day_of_week_name ( uint8_t day_of_week )
{
    switch ( day_of_week )
    {
        case RTC21_MONDAY:
        {
            return "Monday";
        }
        case RTC21_TUESDAY:
        {
            return "Tuesday";
        }
        case RTC21_WEDNESDAY:
        {
            return "Wednesday";
        }
        case RTC21_THURSDAY:
        {
            return "Thursday";
        }
        case RTC21_FRIDAY:
        {
            return "Friday";
        }
        case RTC21_SATURDAY:
        {
            return "Saturday";
        }
        case RTC21_SUNDAY:
        {
            return "Sunday";
        }
        default:
        {
            return "Unknown";
        }
    }
}

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

额外支持

资源

喜欢这个项目吗?

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