通过我们最先进的实时钟解决方案,在您的应用程序中实现事件的无缝协调和同步。
A
A
硬件概览
它是如何工作的?
RTC 8 Click基于瑞士Micro Crystal的RV-3028-C7,这是一款极低功耗的实时时钟/日历(RTC)模块。由于其高度集成,这款模块提供高时间精度,出厂校准至1 ppm,并且所需的外部组件非常少。它具有完整的RTC功能,提供可编程计数器、闹钟和具有可选事件报告源的中断引擎。除了标准时钟输出功能外,它还提供32位UNIX时间计数器。操作参数存储在内部非易失性存储器(EEPROM)中,即使在完全断电的情况下也能保持。RV-3028-C7模块的小尺寸使其能够用于空间非常受限的应用,包括可穿戴设备、医疗设备等。除了RV-3028-C7之外,RTC 8 Click还配备了兼容CR1225电池的纽扣电池座。通过利用自动备份开关,当主电源端子上没有电源时,IC能够使用外部电池电源,从而允许不中断的
操作。电流消耗低至40nA,可以几乎无限期地使用标准纽扣电池运行。此外,当RV-3028-C7通过主电源端子(VDD, VSS)供电时,涓流充电系统将补充电池电量。主电源电压可以在1.2V至5.5V之间变化。RV-3028-C7使用I2C通信协议与主机MCU进行通信。除了I2C总线线路外,RV-3028-C7上还有两个额外的引脚,允许向主机MCU报告中断,还可以捕获外部事件并用自动时间戳标记它。用户可以设置标准的时钟和日历功能(包括秒、分、小时、星期、日期、月份、年份和闰年校正),以及周期倒计时器、周期时间更新、闹钟、外部事件、自动备份切换和上电复位(POR)事件的中断功能。这些功能在模块通过备份电源(电池)运行时都可用。一组配置寄存器用于设置设备的各种工作参数。为了
防止任何意外更改内部寄存器,RV-3028-C7提供了配置的密码保护。如果在非易失性存储器中的使能寄存器设置了密码保护,每次尝试进行寄存器配置时,用户都需要先输入密码。当然,读出密码寄存器将返回0值;这个寄存器是只写的。除了其他功能外,EEPROM存储器还保存偏移校正值。偏移校正用于微调内部32.768 kHz晶体以及补偿老化现象。此Click板™可以选择3.3V或5V逻辑电压级,通过VCC SEL跳线选择。这样,具有3.3V和5V能力的MCU都可以正确使用通信线路。此外,此Click板™配备了一个包含易于使用的函数库和一个示例代码,可以用作进一步开发的参考。
功能概述
开发板
Fusion for KINETIS v8 是一款专为快速开发嵌入式应用而设计的开发板。它支持广泛的微控制器,如 NXP Semiconductor 的不同 32 位 ARM® Cortex®-M 基础 MCU,无论其引脚数量如何,并且具有一系列独特功能,例如首次通过 WiFi 网络的嵌入式调试器/程序员。开发板布局合理,设计周到,确保最终用户在一个地方可以找到所有必需的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,Fusion for KINETIS v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方都能访问。Fusion for
KINETIS 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 KINETIS v8 是 Mikroe 快速开发生态系统的一个重要组成部分,由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。
微控制器概述
MCU卡片 / MCU

类型
8th Generation
建筑
ARM Cortex-M4
MCU 内存 (KB)
512
硅供应商
NXP
引脚数
144
RAM (字节)
131072
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
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 8 Click 驱动程序的 API。
关键功能:
rtc8_set_time
- 设置新时间 - 24小时格式。rtc8_set_date
- 设置新日期。rtc8_get_time_and_date
- 获取RTC数据(时间和日期)。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* \file
* \brief Rtc8 Click example
*
* # Description
* Demo application shows the operation of RTC 8 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configuring clicks and log objects.
* Settings the click in the default configuration.
* Sets new: Time, Date, UNIX time and alarm data.
*
* ## Application Task
* Read current Time, Date and UNIX time and checks if the alarm is active.
*
* @note
* Comment out the lines for setting date and time if you would like the
* module to keep counting time after a reset or shut down.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rtc8.h"
// ------------------------------------------------------------------ VARIABLES
static rtc8_t rtc8;
static log_t logger;
static rtc8_time_t time_s;
static rtc8_date_t date_s;
static rtc8_alarm_t alarm_s;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
void display_weekday ( uint8_t weekday )
{
switch ( weekday )
{
case 0:
{
log_printf( &logger, " Monday \r\n" );
break;
}
case 1:
{
log_printf( &logger, " Tuesday \r\n" );
break;
}
case 2:
{
log_printf( &logger, " Wednesday \r\n" );
break;
}
case 3:
{
log_printf( &logger, " Thursday \r\n" );
break;
}
case 4:
{
log_printf( &logger, " Friday \r\n" );
break;
}
case 5:
{
log_printf( &logger, " Saturday \r\n" );
break;
}
case 6:
{
log_printf( &logger, " Sunday \r\n" );
break;
}
}
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rtc8_cfg_t rtc8_cfg;
/**
* 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.
rtc8_cfg_setup( &rtc8_cfg );
RTC8_MAP_MIKROBUS( rtc8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == rtc8_init( &rtc8, &rtc8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( RTC8_ERROR == rtc8_default_cfg ( &rtc8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
// 24h format - HH,MM,SS
time_s.hours = 23;
time_s.minutes = 59;
time_s.seconds = 50;
rtc8_set_time( &rtc8, &time_s );
// Set date format
date_s.weekdays = 5;
date_s.day = 31;
date_s.month = 12;
date_s.year = 22;
rtc8_set_date( &rtc8, &date_s );
// Set UNIX time
rtc8_set_unix_time( &rtc8, 1672527590ul );
// Set alarm format
alarm_s.weekdays = 6;
alarm_s.hours = 0;
alarm_s.minutes = 0;
rtc8_set_alarm( &rtc8, &alarm_s );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
static uint8_t time_seconds = 0xFF;
uint8_t alarm = 0;
uint32_t unix_time = 0;
err_t error_flag = rtx8_get_time_and_date( &rtc8, &time_s, &date_s );
error_flag |= rtc8_get_uinx_time( &rtc8, &unix_time );
error_flag |= rtc8_get_alarm_flag( &rtc8, &alarm );
if ( ( RTC8_OK == error_flag ) && ( time_seconds != time_s.seconds ) )
{
display_weekday ( date_s.weekdays );
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n Date: %.2u.%.2u.20%.2u.\r\n",
( uint16_t ) time_s.hours, ( uint16_t ) time_s.minutes,
( uint16_t ) time_s.seconds, ( uint16_t ) date_s.day,
( uint16_t ) date_s.month, ( uint16_t ) date_s.year );
log_printf( &logger, " UNIX: %lu\r\n", unix_time );
if ( RTC8_ALARM_IS_ACTIVE == alarm )
{
log_info( &logger, " Alarm Activated!!! " );
rtc8_reset_alarm_flag( &rtc8 );
}
log_printf( &logger, "------------------\r\n" );
time_seconds = time_s.seconds;
}
Delay_ms ( 200 );
}
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;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief Rtc8 Click example
*
* # Description
* Demo application shows the operation of RTC 8 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configuring clicks and log objects.
* Settings the click in the default configuration.
* Sets new: Time, Date, UNIX time and alarm data.
*
* ## Application Task
* Read current Time, Date and UNIX time and checks if the alarm is active.
*
* @note
* Comment out the lines for setting date and time if you would like the
* module to keep counting time after a reset or shut down.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rtc8.h"
// ------------------------------------------------------------------ VARIABLES
static rtc8_t rtc8;
static log_t logger;
static rtc8_time_t time_s;
static rtc8_date_t date_s;
static rtc8_alarm_t alarm_s;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
void display_weekday ( uint8_t weekday )
{
switch ( weekday )
{
case 0:
{
log_printf( &logger, " Monday \r\n" );
break;
}
case 1:
{
log_printf( &logger, " Tuesday \r\n" );
break;
}
case 2:
{
log_printf( &logger, " Wednesday \r\n" );
break;
}
case 3:
{
log_printf( &logger, " Thursday \r\n" );
break;
}
case 4:
{
log_printf( &logger, " Friday \r\n" );
break;
}
case 5:
{
log_printf( &logger, " Saturday \r\n" );
break;
}
case 6:
{
log_printf( &logger, " Sunday \r\n" );
break;
}
}
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rtc8_cfg_t rtc8_cfg;
/**
* 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.
rtc8_cfg_setup( &rtc8_cfg );
RTC8_MAP_MIKROBUS( rtc8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == rtc8_init( &rtc8, &rtc8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( RTC8_ERROR == rtc8_default_cfg ( &rtc8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
// 24h format - HH,MM,SS
time_s.hours = 23;
time_s.minutes = 59;
time_s.seconds = 50;
rtc8_set_time( &rtc8, &time_s );
// Set date format
date_s.weekdays = 5;
date_s.day = 31;
date_s.month = 12;
date_s.year = 22;
rtc8_set_date( &rtc8, &date_s );
// Set UNIX time
rtc8_set_unix_time( &rtc8, 1672527590ul );
// Set alarm format
alarm_s.weekdays = 6;
alarm_s.hours = 0;
alarm_s.minutes = 0;
rtc8_set_alarm( &rtc8, &alarm_s );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
static uint8_t time_seconds = 0xFF;
uint8_t alarm = 0;
uint32_t unix_time = 0;
err_t error_flag = rtx8_get_time_and_date( &rtc8, &time_s, &date_s );
error_flag |= rtc8_get_uinx_time( &rtc8, &unix_time );
error_flag |= rtc8_get_alarm_flag( &rtc8, &alarm );
if ( ( RTC8_OK == error_flag ) && ( time_seconds != time_s.seconds ) )
{
display_weekday ( date_s.weekdays );
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n Date: %.2u.%.2u.20%.2u.\r\n",
( uint16_t ) time_s.hours, ( uint16_t ) time_s.minutes,
( uint16_t ) time_s.seconds, ( uint16_t ) date_s.day,
( uint16_t ) date_s.month, ( uint16_t ) date_s.year );
log_printf( &logger, " UNIX: %lu\r\n", unix_time );
if ( RTC8_ALARM_IS_ACTIVE == alarm )
{
log_info( &logger, " Alarm Activated!!! " );
rtc8_reset_alarm_flag( &rtc8 );
}
log_printf( &logger, "------------------\r\n" );
time_seconds = time_s.seconds;
}
Delay_ms ( 200 );
}
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;
}
// ------------------------------------------------------------------------ END