rtc20  2.1.0.0
Main Page

RTC 20 click

RTC 20 Click is a compact add-on board that measures the passage of real-time. This board features the AB0805, an I2C-configurable real-time clock with a highly sophisticated feature set from Abracon LLC. The AB0805 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 automatic leap year compensation, low power consumption, and full RTC functions such as battery backup, programmable counters, and alarms for timer and watchdog functions.

click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Feb 2023.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of the RTC 20 click boardâ„¢ by reading and displaying the RTC time and date values.

The demo application is composed of two sections :

Application Init

Initialization of I2C module, log UART and additional pins. After driver initialization the app set RTC time to 23:59:50 and set date to Tuesday 28.02.2023.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc20_cfg_t rtc20_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rtc20_cfg_setup( &rtc20_cfg );
RTC20_MAP_MIKROBUS( rtc20_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == rtc20_init( &rtc20, &rtc20_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
time.hour = 23;
time.minute = 59;
time.second = 50;
if ( RTC20_OK == rtc20_set_time( &rtc20, time ) )
{
log_printf( &logger, " Set time : %.2d:%.2d:%.2d\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
}
date.day_of_week = RTC20_DW_TUESDAY;
date.day = 28;
date.month = 2;
date.year = 23;
if ( RTC20_OK == rtc20_set_date( &rtc20, date ) )
{
log_printf( &logger, " Set date : %.2d-%.2d-%.2d\r\n",
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
}
Delay_ms ( 1000 );
log_printf( &logger, "---------------------\r\n" );
}

Application Task

This is an example that shows the use of a RTC 20 Click boardâ„¢. In this example, we read and display the current time ( PM ) and date ( day of the week ), which we also previously set. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB changes every 1 sec.

void application_task ( void )
{
if ( RTC20_OK == rtc20_get_time( &rtc20, &time ) )
{
if ( RTC20_OK == rtc20_get_date( &rtc20, &date ) )
{
if ( time.second != new_sec )
{
log_printf( &logger, " Date : %.2d-%.2d-%.2d\r\n",
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
display_day_of_week( );
log_printf( &logger, " Time : %.2d:%.2d:%.2d\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
log_printf( &logger, "- - - - - - - - - - -\r\n" );
new_sec = time.second;
Delay_ms ( 1 );
}
}
}
Delay_ms ( 1 );
}

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

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.


rtc20_get_time
err_t rtc20_get_time(rtc20_t *ctx, rtc20_time_t *rtc_time)
RTC 20 get time function.
rtc20_get_date
err_t rtc20_get_date(rtc20_t *ctx, rtc20_date_t *rtc_date)
RTC 20 get date function.
rtc20_set_time
err_t rtc20_set_time(rtc20_t *ctx, rtc20_time_t rtc_time)
RTC 20 set time function.
rtc20_set_date
err_t rtc20_set_date(rtc20_t *ctx, rtc20_date_t rtc_date)
RTC 20 set date function.
rtc20_date_t
RTC 20 Click date object.
Definition: rtc20.h:242
rtc20_time_t
RTC 20 Click time object.
Definition: rtc20.h:228
application_task
void application_task(void)
Definition: main.c:94
rtc20_init
err_t rtc20_init(rtc20_t *ctx, rtc20_cfg_t *cfg)
RTC 20 initialization function.
rtc20_cfg_t
RTC 20 Click configuration object.
Definition: rtc20.h:208
RTC20_DW_TUESDAY
#define RTC20_DW_TUESDAY
Definition: rtc20.h:139
RTC20_OK
@ RTC20_OK
Definition: rtc20.h:273
rtc20_t
RTC 20 Click context object.
Definition: rtc20.h:186
application_init
void application_init(void)
Definition: main.c:44
RTC20_MAP_MIKROBUS
#define RTC20_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rtc20.h:170
rtc20_cfg_setup
void rtc20_cfg_setup(rtc20_cfg_t *cfg)
RTC 20 configuration object setup function.