rtc8  2.0.0.0
Main Page

RTC 8 click

RTC 8 click is a real time clock module which has an extremely low power consumption, allowing it to be used with a single button cell battery, for an extended period of time.

click Product page


Click library

  • Author : Katarina Perendic
  • Date : okt 2019.
  • Type : I2C type

Software Support

We provide a library for the Rtc8 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for Rtc8 Click driver.

Standard key functions :

  • Config Object Initialization function.

    void rtc8_cfg_setup ( rtc8_cfg_t *cfg );

  • Initialization function.

    RTC8_RETVAL rtc8_init ( rtc8_t *ctx, rtc8_cfg_t *cfg );

  • Click Default Configuration function.

    void rtc8_default_cfg ( rtc8_t *ctx );

Example key functions :

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

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
rtc8_cfg_setup( &cfg );
RTC8_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rtc8_init( &rtc8, &cfg );
rtc8_default_cfg( &rtc8 );
// 24h format - HH,MM,SS
time_s.hours = 23;
time_s.minutes = 58;
time_s.seconds = 30;
rtc8_set_time( &rtc8, &time_s );
// Set date format
date_s.day = 31;
date_s.month = 12;
date_s.year = 18;
rtc8_set_date( &rtc8, &date_s );
// Set UNIX time
rtc8_set_unix_time( &rtc8, 1545053360 );
// Set alarm format
alarm_s.weekdays = 3;
alarm_s.hours = 0;
alarm_s.minutes = 0;
rtc8_set_alarm( &rtc8, &alarm_s );
Delay_100ms();
}

Application Task

Read current Time, Date and UNIX time and checks if the alarm is active.

void application_task ( void )
{
uint8_t alarm;
uint32_t unix_time;
// Task implementation.
rtx8_get_time_and_date( &rtc8, &time_s, &date_s );
unix_time = rtc8_get_uinx_time( &rtc8 );
log_printf( &logger, "\r\n>> ----------------------------- <<\r\n" );
log_printf( &logger, ">> Time : %d : %d : %d \r\n", time_s.hours, time_s.minutes, time_s.seconds );
log_printf( &logger, ">> Weekday : %d \r\n", date_s.weekdays );
log_printf( &logger, ">> Date : %d : %d : %d \r\n", date_s.day, date_s.month, date_s.year );
log_printf( &logger, ">> UNIX : %ld \r\n", unix_time );
alarm = rtc8_get_alarm_flag( &rtc8 );
if ( alarm == RTC8_ALARM_IS_ACTIVE )
{
log_printf( &logger, " - Alarm Active!!! " );
}
else
{
log_printf( &logger, " - No Alarm." );
}
Delay_ms( 1000 );
}

Note

Comment the lines for setting date and time if you would like the module to keep counting time after a reset or shut down.

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Rtc8

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


rtc8_set_time
uint8_t rtc8_set_time(rtc8_t *ctx, rtc8_time_t *time_s)
Set new time - 24 hour format.
RTC8_ALARM_IS_ACTIVE
#define RTC8_ALARM_IS_ACTIVE
Definition: rtc8.h:220
application_task
void application_task(void)
Definition: main.c:98
rtc8_default_cfg
void rtc8_default_cfg(rtc8_t *ctx)
Click Default Configuration function.
rtc8_cfg_t
Click configuration structure definition.
Definition: rtc8.h:257
rtc8_reset_alarm_flag
void rtc8_reset_alarm_flag(rtc8_t *ctx)
Reset alarm.
rtc8_set_date
uint8_t rtc8_set_date(rtc8_t *ctx, rtc8_date_t *date_s)
Set new date.
rtc8_set_alarm
uint8_t rtc8_set_alarm(rtc8_t *ctx, rtc8_alarm_t *alarm_s)
Set Alarm.
rtx8_get_time_and_date
void rtx8_get_time_and_date(rtc8_t *ctx, rtc8_time_t *time_s, rtc8_date_t *date_s)
Get RTC data ( Time and Data )
rtc8_get_alarm_flag
uint8_t rtc8_get_alarm_flag(rtc8_t *ctx)
Get Alarm flag.
rtc8_set_unix_time
void rtc8_set_unix_time(rtc8_t *ctx, int32_t unix_time)
Set UNIX time.
rtc8_get_uinx_time
uint32_t rtc8_get_uinx_time(rtc8_t *ctx)
Get current UNIX time.
rtc8_init
RTC8_RETVAL rtc8_init(rtc8_t *ctx, rtc8_cfg_t *cfg)
Initialization function.
application_init
void application_init(void)
Definition: main.c:42
RTC8_MAP_MIKROBUS
#define RTC8_MAP_MIKROBUS(cfg, mikrobus)
Definition: rtc8.h:52
rtc8_cfg_setup
void rtc8_cfg_setup(rtc8_cfg_t *cfg)
Config Object Initialization function.