Rtc 10 click
RTC 10 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 : dec 2019.
- Type : I2C type
Software Support
We provide a library for the Rtc10 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 Rtc10 Click driver.
Standard key functions :
- Config Object Initialization function.
void rtc10_cfg_setup ( rtc10_cfg_t *cfg );
- Initialization function.
RTC10_RETVAL rtc10_init ( rtc10_t *ctx, rtc10_cfg_t *cfg );
- Click Default Configuration function.
void rtc10_default_cfg ( rtc10_t *ctx );
Example key functions :
- Generic write function.
oid rtc10_generic_write ( rtc10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
- Generic read function.
void rtc10_generic_read ( rtc10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
- Hardware reset function.
void rtc10_hw_reset ( rtc10_t *ctx );
Examples Description
This application is a real-time clock module.
The demo application is composed of two sections :
Application Init
Initialization driver enable's - I2C, hardware reset, set start time and date, enable counting also, write log.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_ms ( 1000 );
log_printf( &logger, "------------------- \r\n" );
log_printf( &logger, " Hardware Reset \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 10 );
Delay_ms ( 100 );
log_printf( &logger, "------------------- \r\n" );
log_printf( &logger, " Enable Counting \r\n" );
log_printf( &logger, "------------------- \r\n" );
log_printf( &logger, " Start RTC \r\n" );
log_printf( &logger, "------------------- \r\n" );
Delay_ms ( 100 );
}
#define RTC10_MAP_MIKROBUS(cfg, mikrobus)
Definition rtc10.h:65
void rtc10_enable_counting(rtc10_t *ctx)
Enable counting function.
void rtc10_hw_reset(rtc10_t *ctx)
Hardware reset function.
void rtc10_set_time(rtc10_t *ctx, uint8_t time_hours, uint8_t time_minutes, uint8_t time_seconds)
Set time: hours, minutes and seconds function.
void rtc10_cfg_setup(rtc10_cfg_t *cfg)
Config Object Initialization function.
void rtc10_set_date(rtc10_t *ctx, uint8_t day_of_the_week, uint8_t date_day, uint8_t date_month, uint16_t date_year)
Set date hours, minutes and seconds function.
RTC10_RETVAL rtc10_init(rtc10_t *ctx, rtc10_cfg_t *cfg)
Initialization function.
void application_init(void)
Definition main.c:72
uint8_t sec_flag
Definition main.c:36
Click configuration structure definition.
Definition rtc10.h:160
Application Task
This is an example which demonstrates the use of RTC 10 Click board. RTC 10 Click communicates with register via I2C interface, set time and date, enable counting and display time and date values, also, display temperature value for every 1 sec. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on Usart Terminal changes for every 1 sec.
{
uint8_t i;
uint8_t time_hours = 0;
uint8_t time_minutes = 0;
uint8_t time_seconds = 0;
uint8_t day_of_the_week = 0;
uint8_t date_day = 0;
uint8_t date_month = 0;
uint8_t date_year = 0;
float temperature;
Delay_ms ( 100 );
rtc10_get_date( &rtc10, &day_of_the_week, &date_day, &date_month, &date_year );
Delay_ms ( 100 );
{
log_printf( &logger, " \r\n\n Time: %u:%u:%u ", (uint16_t)time_hours, (uint16_t)time_minutes, (uint16_t)time_seconds );
log_printf( &logger, "Date: %u. %u. 20%u. ", (uint16_t)date_day, (uint16_t)date_month, (uint16_t)date_year );
if ( time_seconds == 0 )
{
log_printf( &logger, "\r\n\n Temp.:%.2f C", temperature);
}
log_printf( &logger, "--------------------------------------------" );
}
}
void rtc10_get_time(rtc10_t *ctx, uint8_t *time_hours, uint8_t *time_minutes, uint8_t *time_seconds)
Get time hours, minutes and seconds function.
void rtc10_get_date(rtc10_t *ctx, uint8_t *day_of_the_week, uint8_t *date_day, uint8_t *date_month, uint8_t *date_year)
Get time hours, minutes and seconds function.
float rtc10_get_temperature(rtc10_t *ctx)
Get temperature function.
void display_day_of_the_week(uint8_t day_of_the_week)
Definition main.c:40
void application_task(void)
Definition main.c:122
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.Rtc10
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.