rtc18  2.0.0.0
Main Page

RTC 18 click

RTC 18 Click is a compact add-on board that accurately keeps the time of a day. This board features the RV-3032-C7, an I2C-configurable real-time clock module that incorporates an integrated CMOS circuit and an XTAL from Micro Crystal AG. The RV-3032-C7 is a temperature compensated RTC with premium accuracy (0.22 sec/day) and extremely low power consumption, allowing it to be used with a single button cell battery for an extended period. It can measure temperature with a typical accuracy of ±1°C and a resolution of 0.0625°C/step with a programmable alarm on top and bottom temperature limits. It features standard RTC functions with automatic leap year correction, and standard interrupt for Periodic Countdown Timer and Periodic Time Update (seconds, minutes), date/hour/minute alarm, and an external event.

click Product page


Click library

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

Software Support

We provide a library for the RTC 18 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 18 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of RTC 18 click board by reading and displaying the time and date values as well as the temperature measurements in Celsius.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger and performs the click default configuration which enables the periodic interrupt on seconds count-up, and sets the starting time and date.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc18_cfg_t rtc18_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rtc18_cfg_setup( &rtc18_cfg );
RTC18_MAP_MIKROBUS( rtc18_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == rtc18_init( &rtc18, &rtc18_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( RTC18_ERROR == rtc18_default_cfg ( &rtc18 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
time.hour = 23;
time.minute = 59;
time.second = 50;
if ( RTC18_OK == rtc18_set_time ( &rtc18, &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 = RTC18_SATURDAY;
date.day = 31;
date.month = 12;
date.year = 22;
if ( RTC18_OK == rtc18_set_date ( &rtc18, &date ) )
{
log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc18_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 on the USB UART the current time and date values as well as the temperature measurements in Celsius.

void application_task ( void )
{
float temperature;
// Wait for a second count-up interrupt
while ( rtc18_get_int_pin ( &rtc18 ) );
Delay_ms ( 10 );
if ( RTC18_OK == rtc18_read_time ( &rtc18, &time ) )
{
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
}
if ( RTC18_OK == rtc18_read_date ( &rtc18, &date ) )
{
log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc18_get_day_of_week_name ( date.day_of_week ),
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
}
if ( RTC18_OK == rtc18_read_temperature ( &rtc18, &temperature ) )
{
log_printf( &logger, " Temperature: %.2f C\r\n\n", temperature );
}
}

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.RTC18

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.


rtc18_read_date
err_t rtc18_read_date(rtc18_t *ctx, rtc18_date_t *date)
RTC 18 read date function.
RTC18_MAP_MIKROBUS
#define RTC18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rtc18.h:246
RTC18_SATURDAY
#define RTC18_SATURDAY
Definition: rtc18.h:200
rtc18_init
err_t rtc18_init(rtc18_t *ctx, rtc18_cfg_t *cfg)
RTC 18 initialization function.
rtc18_set_time
err_t rtc18_set_time(rtc18_t *ctx, rtc18_time_t *time)
RTC 18 set time function.
rtc18_default_cfg
err_t rtc18_default_cfg(rtc18_t *ctx)
RTC 18 default configuration function.
application_task
void application_task(void)
Definition: main.c:98
rtc18_t
RTC 18 Click context object.
Definition: rtc18.h:260
rtc18_time_t
RTC 18 Click time object.
Definition: rtc18.h:298
rtc18_cfg_setup
void rtc18_cfg_setup(rtc18_cfg_t *cfg)
RTC 18 configuration object setup function.
rtc18_read_temperature
err_t rtc18_read_temperature(rtc18_t *ctx, float *temperature)
RTC 18 read temperature function.
rtc18_cfg_t
RTC 18 Click configuration object.
Definition: rtc18.h:280
rtc18_date_t
RTC 18 Click date object.
Definition: rtc18.h:312
rtc18_set_date
err_t rtc18_set_date(rtc18_t *ctx, rtc18_date_t *date)
RTC 18 set date function.
application_init
void application_init(void)
Definition: main.c:43
rtc18_clear_periodic_interrupt
err_t rtc18_clear_periodic_interrupt(rtc18_t *ctx)
RTC 18 clear periodic interrupt function.
rtc18_read_time
err_t rtc18_read_time(rtc18_t *ctx, rtc18_time_t *time)
RTC 18 read time function.
RTC18_OK
@ RTC18_OK
Definition: rtc18.h:326
rtc18_get_int_pin
uint8_t rtc18_get_int_pin(rtc18_t *ctx)
RTC 18 get int pin function.
RTC18_ERROR
@ RTC18_ERROR
Definition: rtc18.h:327