rtc4  2.0.0.0
Main Page

RTC 4 click

RTC 4 click carries DS2417, a real time clock/calendar with a 1-Wire MicroLAN interface and a programmable interrupt for system output.

click Product page


Click library

  • Author : Aleksandra Cvjeticanin
  • Date : Mar 2022.
  • Type : One Wire type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of the RTC 4 click board.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger and then sets the starting time to 23:59:50 and date to 31.12.2022.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc4_cfg_t rtc4_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rtc4_cfg_setup( &rtc4_cfg );
RTC4_MAP_MIKROBUS( rtc4_cfg, MIKROBUS_1 );
if ( ONE_WIRE_ERROR == rtc4_init( &rtc4, &rtc4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Check communication." );
for ( ; ; );
}
time.hours = 23;
time.min = 59;
time.sec = 50;
date.day = 31;
date.month = 12;
date.year = 2022;
log_info( &logger, " Application Task " );
}

Application Task

With the usage of rtc4_get_date_time we get the time and date from the register and display them on the UART Terminal. The counter increments once per second.

void application_task ( void )
{
while ( rtc4_get_interrupt ( &rtc4 ) );
if ( RTC4_OK == rtc4_get_date_time ( &rtc4, &date, &time ) )
{
log_printf( &logger, "Time: %.2u:%.2u:%.2u\r\n",
( uint16_t ) time.hours, ( uint16_t ) time.min, ( uint16_t ) time.sec );
log_printf( &logger, "Date: %.2u/%.2u/%u\r\n",
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
log_printf( &logger, "------------------------\r\n\n");
}
}

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

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.


rtc4_cfg_setup
void rtc4_cfg_setup(rtc4_cfg_t *cfg)
RTC 4 configuration object setup function.
rtc4_date_t::day
uint32_t day
Definition: rtc4.h:174
rtc4_time_t::sec
uint32_t sec
Definition: rtc4.h:162
rtc4_init
err_t rtc4_init(rtc4_t *ctx, rtc4_cfg_t *cfg)
RTC 4 initialization function.
rtc4_time_t
RTC 4 Click time object.
Definition: rtc4.h:159
rtc4_get_interrupt
uint8_t rtc4_get_interrupt(rtc4_t *ctx)
RTC 4 get interrupt function.
time
rtc4_time_t time
Definition: main.c:30
rtc4_check_communication
err_t rtc4_check_communication(rtc4_t *ctx)
RTC 4 check communication function.
rtc4_set_date_time
err_t rtc4_set_date_time(rtc4_t *ctx, rtc4_date_t *date, rtc4_time_t *time, uint8_t int_interval)
RTC 4 set date time function.
application_task
void application_task(void)
Definition: main.c:79
rtc4_time_t::min
uint32_t min
Definition: rtc4.h:161
rtc4_cfg_t
RTC 4 Click configuration object.
Definition: rtc4.h:211
rtc4_date_t::month
uint32_t month
Definition: rtc4.h:173
RTC4_ERROR
@ RTC4_ERROR
Definition: rtc4.h:230
RTC4_OK
@ RTC4_OK
Definition: rtc4.h:229
rtc4_date_t
RTC 4 Click date object.
Definition: rtc4.h:171
RTC4_MAP_MIKROBUS
#define RTC4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: rtc4.h:145
date
rtc4_date_t date
Definition: main.c:31
rtc4_get_date_time
err_t rtc4_get_date_time(rtc4_t *ctx, rtc4_date_t *date, rtc4_time_t *time)
RTC 4 get date time function.
application_init
void application_init(void)
Definition: main.c:33
RTC4_DCB_INTERVAL_1S
#define RTC4_DCB_INTERVAL_1S
Definition: rtc4.h:114
rtc4_date_t::year
uint32_t year
Definition: rtc4.h:172
rtc4_t
RTC 4 Click context object.
Definition: rtc4.h:194
rtc4_time_t::hours
uint32_t hours
Definition: rtc4.h:160