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 :

  • rtc4_cfg_setup Config Object Initialization function.
    void rtc4_cfg_setup ( rtc4_cfg_t *cfg );
    void rtc4_cfg_setup(rtc4_cfg_t *cfg)
    RTC 4 configuration object setup function.
    RTC 4 Click configuration object.
    Definition rtc4.h:215
  • rtc4_init Initialization function.
    err_t rtc4_init ( rtc4_t *ctx, rtc4_cfg_t *cfg );
    err_t rtc4_init(rtc4_t *ctx, rtc4_cfg_t *cfg)
    RTC 4 initialization function.
    RTC 4 Click context object.
    Definition rtc4.h:198

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 " );
}
#define RTC4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition rtc4.h:149
#define RTC4_DCB_INTERVAL_1S
Definition rtc4.h:118
err_t rtc4_check_communication(rtc4_t *ctx)
RTC 4 check communication function.
void application_init(void)
Definition main.c:33
@ RTC4_ERROR
Definition rtc4.h:234
uint32_t month
Definition rtc4.h:177
uint32_t day
Definition rtc4.h:178
uint32_t year
Definition rtc4.h:176
uint32_t min
Definition rtc4.h:165
uint32_t sec
Definition rtc4.h:166
uint32_t hours
Definition rtc4.h:164

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");
}
}
void application_task(void)
Definition main.c:79
@ RTC4_OK
Definition rtc4.h:233

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.