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 : MikroE Team
- 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 :
rtc8_cfg_setup
Config Object Initialization function.
void rtc8_cfg_setup(rtc8_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition rtc8.h:266
rtc8_init
Initialization function.
err_t rtc8_init(rtc8_t *ctx, rtc8_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition rtc8.h:247
rtc8_default_cfg
Click Default Configuration function.
err_t rtc8_default_cfg(rtc8_t *ctx)
Click Default Configuration function.
Example key functions :
rtc8_set_time
Set new time - 24 hour format
err_t rtc8_set_time(rtc8_t *ctx, rtc8_time_t *time_s)
Set new time - 24 hour format.
Time structure definition.
Definition rtc8.h:285
rtc8_set_date
Set new date
err_t rtc8_set_date(rtc8_t *ctx, rtc8_date_t *date_s)
Set new date.
Date structure definition.
Definition rtc8.h:296
rtx8_get_time_and_date
Get RTC data ( Time and Data )
err_t rtx8_get_time_and_date(rtc8_t *ctx, rtc8_time_t *time_s, rtc8_date_t *date_s)
Get RTC data ( Time and Data )
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.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
rtc8_init( &rtc8, &rtc8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
time_s.hours = 23;
time_s.minutes = 59;
time_s.seconds = 50;
date_s.weekdays = 5;
date_s.day = 31;
date_s.month = 12;
date_s.year = 22;
alarm_s.weekdays = 6;
alarm_s.hours = 0;
alarm_s.minutes = 0;
log_info( &logger, " Application Task " );
}
#define RTC8_ERROR
Definition rtc8.h:78
#define RTC8_MAP_MIKROBUS(cfg, mikrobus)
Definition rtc8.h:66
err_t rtc8_set_alarm(rtc8_t *ctx, rtc8_alarm_t *alarm_s)
Set Alarm.
err_t rtc8_set_unix_time(rtc8_t *ctx, uint32_t unix_time)
Set UNIX time.
void application_init(void)
Definition main.c:86
Application Task
Read current Time, Date and UNIX time and checks if the alarm is active.
{
static uint8_t time_seconds = 0xFF;
uint8_t alarm = 0;
uint32_t unix_time = 0;
if ( (
RTC8_OK == error_flag ) && ( time_seconds != time_s.seconds ) )
{
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n Date: %.2u.%.2u.20%.2u.\r\n",
( uint16_t ) time_s.hours, ( uint16_t ) time_s.minutes,
( uint16_t ) time_s.seconds, ( uint16_t ) date_s.day,
( uint16_t ) date_s.month, ( uint16_t ) date_s.year );
log_printf( &logger, " UNIX: %lu\r\n", unix_time );
{
log_info( &logger, " Alarm Activated!!! " );
}
log_printf( &logger, "------------------\r\n" );
time_seconds = time_s.seconds;
}
Delay_ms ( 200 );
}
#define RTC8_ALARM_IS_ACTIVE
Definition rtc8.h:232
#define RTC8_OK
Definition rtc8.h:77
err_t rtc8_get_alarm_flag(rtc8_t *ctx, uint8_t *alarm_flag)
Get Alarm flag.
err_t rtc8_get_uinx_time(rtc8_t *ctx, uint32_t *unix_time)
Get current UNIX time.
err_t rtc8_reset_alarm_flag(rtc8_t *ctx)
Reset alarm.
void application_task(void)
Definition main.c:147
void display_weekday(uint8_t weekday)
Definition main.c:42
Note
Comment out 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.