中级
30 分钟

通过 RV5C387A 和 TM4C129ENCPDT 提升您的项目的 RTC 功能

永不停歇的时钟:认识我们的 RTC 奇迹!

RTC 17 Click with Fusion for Tiva v8

已发布 6月 24, 2024

点击板

RTC 17 Click

开发板

Fusion for Tiva v8

编译器

NECTO Studio

微控制器单元

TM4C129ENCPDT

体验高精度实时时钟解决方案,实现时间敏感操作的无缝同步。

A

A

硬件概览

它是如何工作的?

RTC 17 Click 基于 RV5C387A,这是一款由日新微电子公司提供的、优化用于低功耗操作的 I2C 可配置实时时钟/日历。RV5C387A 被配置为向 MCU 传输日历和时间数据,并具有集成的中断生成功能。它以从秒到日历年最后两位数的单位读取和写入 MCU 的时间数据。当日历年的最后两位数是 4 的倍数时,该年份将自动识别为闰年。因此,直到 2099 年的闰年都可以自动识别。该 Click board™ 使用标准 I2C 双线接口与 MCU 通信,以读取数据和配置设置,支持高达 400kHz 的快速模式操作。

它还包含一个报警电路,配置为在预设时间从其 A、B 或 C 中断引脚向 mikroBUS™ 插座的 INT 引脚生成中断信号。报警电路允许通过 Alarm_W 和 Alarm_D 寄存器指定两个报警设置。Alarm_W 寄存器(中断 B)允许设置星期、小时和分钟报警,包括多星期几设置的组合,例如星期一和星期三,而 Alarm_D 寄存器(中断 C)允许设置小时和分钟报警。此外,RV5C387A 除了可以从中断 A 引脚生成的报警电路中断信号外,还可以生成周期性中断信号。RTC 17 Click 还具有一个标记为 CLKO 的板载

连接器,提供 32kHz 的时钟脉冲。像这样的最常见 RTC 配置是电池备份,它在停电时保持时间并继续工作。正因如此,除了 BU9873 外,RTC 17 Click 还配备了一个与 3000TR 电池座兼容的纽扣电池座,适用于 12mm 纽扣电池。该 Click board™ 可以通过 VCC SEL 跳线选择 3.3V 或 5V 逻辑电压级别操作。这种方式,3.3V 和 5V 兼容的 MCU 都可以正确使用通信线路。此外,该 Click board™ 配备了包含易于使用的函数和示例代码的库,可用作进一步开发的参考。

RTC 17 Click hardware overview image

功能概述

开发板

Fusion for TIVA v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持广泛的微控制器,如不同的32位ARM® Cortex®-M基础MCUs,来自Texas Instruments,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次通过WiFi网络实现的嵌入式调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,Fusion for TIVA v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何

时候都能访问。Fusion for TIVA v8开发板的每个部分都包含了使同一板块运行最高效的必要组件。一个先进的集成CODEGRIP程序/调试模块提供许多有价值的编程/调试选项,包括对JTAG、SWD和SWO Trace(单线输出)的支持,并与Mikroe软件环境无缝集成。此外,它还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB HOST/DEVICE、CAN(如果MCU卡支持的话)和以

太网也包括在内。此外,它还拥有广受好评的 mikroBUS™标准,为MCU卡提供了标准化插座(SiBRAIN标准),以及两种显示选项,用于TFT板线产品和基于字符的LCD。Fusion for TIVA v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。

Fusion for Tiva v8 horizontal image

微控制器概述 

MCU卡片 / MCU

default

类型

8th Generation

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

Texas Instruments

引脚数

128

RAM (字节)

262144

使用的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
Interrupt
PQ4
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PD2
SCL
I2C Data
PD3
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

RTC 17 Click Schematic schematic

一步一步来

项目组装

Fusion for PIC v8 front image hardware assembly

从选择您的开发板和Click板™开始。以Fusion for Tiva v8作为您的开发板开始

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
v8 SiBRAIN Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image 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 17 Click 驱动程序的 API。

关键功能:

  • rtc17_set_time - 该函数设置起始时间值 - 秒、分钟和小时。

  • rtc17_read_time - 该函数读取当前时间值 - 秒、分钟和小时。

  • rtc17_read_date - 该函数读取当前日期值 - 星期几、日期、月份和年份。

开源

代码示例

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

/*!
 * @file main.c
 * @brief RTC17 Click example
 *
 * # Description
 * This example demonstrates the use of RTC 17 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 performs the click default configuration
 * which sets 24h time mode and interrupt to be synchronized with second count-up.
 * And after that setting the starting time and date.
 *
 * ## Application Task
 * Waits for the second count-up interrupt and then reads and displays the current
 * time and date values on the USB UART.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "rtc17.h"

static rtc17_t rtc17;
static log_t logger;
static rtc17_time_t time;
static rtc17_date_t date;

/**
 * @brief RTC 17 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 #rtc17_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 char *rtc17_get_day_of_week_name ( uint8_t day_of_week );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rtc17_cfg_t rtc17_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.
    rtc17_cfg_setup( &rtc17_cfg );
    RTC17_MAP_MIKROBUS( rtc17_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc17_init( &rtc17, &rtc17_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( RTC17_ERROR == rtc17_default_cfg ( &rtc17 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    time.hour = 23;
    time.minute = 59;
    time.second = 50;
    if ( RTC17_OK == rtc17_set_time ( &rtc17, &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 = RTC17_SATURDAY;
    date.day = 31;
    date.month = 12;
    date.year = 22;
    if ( RTC17_OK == rtc17_set_date ( &rtc17, &date ) )
    {
        log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc17_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 interrupt which is synchronized with second count-up
    while ( rtc17_get_int_pin ( &rtc17 ) );
    
    rtc17_clear_interrupts ( &rtc17 );
    if ( RTC17_OK == rtc17_read_time ( &rtc17, &time ) )
    {
        log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    if ( RTC17_OK == rtc17_read_date ( &rtc17, &date ) )
    {
        log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n\n", 
                    rtc17_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

static char *rtc17_get_day_of_week_name ( uint8_t day_of_week )
{
    switch ( day_of_week )
    {
        case RTC17_MONDAY:
        {
            return "Monday";
        }
        case RTC17_TUESDAY:
        {
            return "Tuesday";
        }
        case RTC17_WEDNESDAY:
        {
            return "Wednesday";
        }
        case RTC17_THURSDAY:
        {
            return "Thursday";
        }
        case RTC17_FRIDAY:
        {
            return "Friday";
        }
        case RTC17_SATURDAY:
        {
            return "Saturday";
        }
        case RTC17_SUNDAY:
        {
            return "Sunday";
        }
        default:
        {
            return "Unknown";
        }
    }
}

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

额外支持

资源

喜欢这个项目吗?

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