rtc17  2.0.0.0
Main Page

RTC 17 click

RTC 17 Click is a compact add-on board that accurately keeps the time of a day. This board features the RV5C387A, a CMOS real-time clock with a built-in interrupt generation function from Nisshinbo Micro Devices Inc, to perform serial transmission of time and calendar data to the MCU. The BU9873 provides information like year, month, day, weekday, hours, minutes, and seconds based on a 32.768kHz quartz crystal through an I2C serial interface to transmit time and calendar data to the MCU. It also has an alarm function that outputs an interrupt signal to the MCU when the day of the week, hour, or minute matches with the preset time.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Mar 2022.
  • Type : I2C type

Software Support

We provide a library for the RTC 17 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for RTC 17 Click driver.

Standard key functions :

Example key functions :

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.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc17_cfg_t rtc17_cfg;
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 " );
}

Application Task

Waits for the second count-up interrupt and then reads and displays the current time and date values on the USB UART.

void application_task ( void )
{
// Wait for interrupt which is synchronized with second count-up
while ( rtc17_get_int_pin ( &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 );
}
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.RTC17

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


RTC17_MAP_MIKROBUS
#define RTC17_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rtc17.h:162
rtc17_read_time
err_t rtc17_read_time(rtc17_t *ctx, rtc17_time_t *time)
RTC 17 read time function.
RTC17_OK
@ RTC17_OK
Definition: rtc17.h:236
RTC17_SATURDAY
#define RTC17_SATURDAY
Definition: rtc17.h:136
rtc17_set_time
err_t rtc17_set_time(rtc17_t *ctx, rtc17_time_t *time)
RTC 17 set time function.
RTC17_ERROR
@ RTC17_ERROR
Definition: rtc17.h:237
application_task
void application_task(void)
Definition: main.c:100
rtc17_set_date
err_t rtc17_set_date(rtc17_t *ctx, rtc17_date_t *date)
RTC 17 set date function.
rtc17_clear_interrupts
err_t rtc17_clear_interrupts(rtc17_t *ctx)
RTC 17 clear interrupts function.
rtc17_get_int_pin
uint8_t rtc17_get_int_pin(rtc17_t *ctx)
RTC 17 get int pin function.
rtc17_t
RTC 17 Click context object.
Definition: rtc17.h:175
rtc17_time_t
RTC 17 Click time object.
Definition: rtc17.h:209
rtc17_cfg_t
RTC 17 Click configuration object.
Definition: rtc17.h:192
rtc17_init
err_t rtc17_init(rtc17_t *ctx, rtc17_cfg_t *cfg)
RTC 17 initialization function.
rtc17_default_cfg
err_t rtc17_default_cfg(rtc17_t *ctx)
RTC 17 default configuration function.
rtc17_date_t
RTC 17 Click date object.
Definition: rtc17.h:222
application_init
void application_init(void)
Definition: main.c:44
rtc17_cfg_setup
void rtc17_cfg_setup(rtc17_cfg_t *cfg)
RTC 17 configuration object setup function.
rtc17_read_date
err_t rtc17_read_date(rtc17_t *ctx, rtc17_date_t *date)
RTC 17 read date function.