rtc19 2.1.0.0
Main Page

RTC 19 click

‍RTC 19 Click is a compact add-on board that measures the passage of real-time. This board features the MAX31334, an I2C-configurable real-time clock with an integrated power switch from Analog Devices. The MAX31334 provides information like seconds, minutes, hours, days, months, years, and dates 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 pre-set time, as well as a programmable square-wave output, event detection input with timestamping, and backup supply.

click Product page


Click library

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

Software Support

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

Standard key functions :

  • rtc19_cfg_setup Config Object Initialization function.
    void rtc19_cfg_setup(rtc19_cfg_t *cfg)
    RTC 19 configuration object setup function.
    RTC 19 Click configuration object.
    Definition rtc19.h:267
  • rtc19_init Initialization function.
    err_t rtc19_init ( rtc19_t *ctx, rtc19_cfg_t *cfg );
    err_t rtc19_init(rtc19_t *ctx, rtc19_cfg_t *cfg)
    RTC 19 initialization function.
    RTC 19 Click context object.
    Definition rtc19.h:245
  • rtc19_default_cfg Click Default Configuration function.
    err_t rtc19_default_cfg ( rtc19_t *ctx );
    err_t rtc19_default_cfg(rtc19_t *ctx)
    RTC 19 default configuration function.

Example key functions :

  • rtc19_set_time This function sets the starting time values - second, minute and hour.
    err_t rtc19_set_time ( rtc19_t *ctx, rtc19_time_t *time );
    err_t rtc19_set_time(rtc19_t *ctx, rtc19_time_t *time)
    RTC 19 set time function.
    RTC 19 Click time object.
    Definition rtc19.h:287
  • rtc19_read_time This function reads the current time values - second, minute and hour.
    err_t rtc19_read_time ( rtc19_t *ctx, rtc19_time_t *time );
    err_t rtc19_read_time(rtc19_t *ctx, rtc19_time_t *time)
    RTC 19 read time function.
  • rtc19_read_date This function reads the current date values - day of week, day, month and year.
    err_t rtc19_read_date ( rtc19_t *ctx, rtc19_date_t *date );
    err_t rtc19_read_date(rtc19_t *ctx, rtc19_date_t *date)
    RTC 19 read date function.
    RTC 19 Click date object.
    Definition rtc19.h:301

Example Description

‍This example demonstrates the use of RTC 19 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 resets the device and sets the timer interrupt to 1 Hz. After that, it sets the starting time and date.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc19_cfg_t rtc19_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rtc19_cfg_setup( &rtc19_cfg );
RTC19_MAP_MIKROBUS( rtc19_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == rtc19_init( &rtc19, &rtc19_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( RTC19_ERROR == rtc19_default_cfg ( &rtc19 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
time.hour = 23;
time.minute = 59;
time.second = 50;
if ( RTC19_OK == rtc19_set_time ( &rtc19, &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 = RTC19_SATURDAY;
date.day = 31;
date.month = 12;
date.year = 22;
if ( RTC19_OK == rtc19_set_date ( &rtc19, &date ) )
{
log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc19_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 " );
}
#define RTC19_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition rtc19.h:229
#define RTC19_SATURDAY
Definition rtc19.h:203
err_t rtc19_set_date(rtc19_t *ctx, rtc19_date_t *date)
RTC 19 set date function.
void application_init(void)
Definition main.c:44
@ RTC19_ERROR
Definition rtc19.h:316
@ RTC19_OK
Definition rtc19.h:315

Application Task

‍Waits for a timer countdown interrupt (1 Hz) and then reads and displays on the USB UART the current time and date values.

void application_task ( void )
{
// Wait for a timer countdown flag configured at 1 Hz
while ( rtc19_get_inta_pin ( &rtc19 ) );
Delay_ms ( 100 );
if ( RTC19_OK == rtc19_read_time ( &rtc19, &time ) )
{
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
}
if ( RTC19_OK == rtc19_read_date ( &rtc19, &date ) )
{
log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc19_get_day_of_week_name ( date.day_of_week ),
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
}
}
err_t rtc19_clear_interrupts(rtc19_t *ctx)
RTC 19 clear interrupts function.
uint8_t rtc19_get_inta_pin(rtc19_t *ctx)
RTC 19 get inta pin function.
void application_task(void)
Definition main.c:99

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

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.