rtc7  2.0.0.0
Main Page

RTC 7 Click

RTC 7 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 or a super capacitor, 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 RTC7 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 RTC7 Click driver.

Standard key functions :

  • rtc7_cfg_setup Config Object Initialization function.
    void rtc7_cfg_setup ( rtc7_cfg_t *cfg );
  • rtc7_init Initialization function.
    err_t rtc7_init ( rtc7_t *ctx, rtc7_cfg_t *cfg );
  • rtc7_default_cfg Click Default Configuration function.
    err_t rtc7_default_cfg ( rtc7_t *ctx );

Example key functions :

  • rtc7_check_interrupt This function returns the interrupt state, state of INTA pin.
    uint8_t rtc7_check_interrupt ( rtc7_t *ctx );
  • rtc7_read_reg This function writes one byte data to the register.
    err_t rtc7_read_reg ( rtc7_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
  • rtc7_get_local_time This function gets the local time data including the determined time zone in calculations.
    err_t rtc7_get_local_time ( rtc7_t *ctx, rtc7_time_t *local_time );

Examples Description

This app is used to accurately measure time with low power consumption.

The demo application is composed of two sections :

Application Init

Initializes device.

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.
rtc7_cfg_setup( &cfg );
RTC7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rtc7_init( &rtc7, &cfg );
Delay_ms ( 300 );
time_set.year = 22;
err_t error_flag = rtc7_reset( &rtc7 );
error_flag |= rtc7_init_time ( &rtc7, 0 );
error_flag |= rtc7_set_gmt_time( &rtc7, &time_set );
error_flag |= rtc7_write_reg( &rtc7, RTC7_TIMER_INIT_REG, 15 );
Delay_ms ( 100 );
if ( RTC7_ERROR == error_flag )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Waits for a second count-up interrupt and then reads and logs the current time and date on the USB UART.

void application_task ( void )
{
// Wait for timer count-down interrupt which is set to 1Hz
while ( rtc7_check_interrupt ( &rtc7 ) );
// Clear interrupt status
uint8_t int_status = 0;
rtc7_read_reg( &rtc7, RTC7_INT_STATUS_REG, &int_status, 1 );
// Read time
if ( RTC7_OK == rtc7_get_local_time( &rtc7, &time_date ) )
{
// Display time
}
}

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

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.


rtc7_reset
err_t rtc7_reset(rtc7_t *ctx)
Reset function.
rtc7_set_timer
err_t rtc7_set_timer(rtc7_t *ctx, uint8_t enable_timer, uint8_t timer_freq)
Timer Set function.
RTC7_TIMER_EN
#define RTC7_TIMER_EN
Definition: rtc7.h:254
rtc7_time_t::year
uint8_t year
Definition: rtc7.h:290
RTC7_INT_STATUS_REG
#define RTC7_INT_STATUS_REG
Definition: rtc7.h:140
RTC7_OUTPUT_FREQ_32768HZ
#define RTC7_OUTPUT_FREQ_32768HZ
Definition: rtc7.h:184
rtc7_time_t::monthday
uint8_t monthday
Definition: rtc7.h:288
rtc7_time_t::hours
uint8_t hours
Definition: rtc7.h:286
application_task
void application_task(void)
Definition: main.c:137
RTC7_INPUT_FREQ_32768HZ
#define RTC7_INPUT_FREQ_32768HZ
Definition: rtc7.h:190
rtc7_time_t
Definition: rtc7.h:283
RTC7_TIMER_INIT_REG
#define RTC7_TIMER_INIT_REG
Definition: rtc7.h:149
rtc7_cfg_t
Click configuration structure definition.
Definition: rtc7.h:319
RTC7_OK
#define RTC7_OK
Definition: rtc7.h:77
rtc7_check_interrupt
uint8_t rtc7_check_interrupt(rtc7_t *ctx)
Interrupt Check function.
RTC7_ENABLE_OSC
#define RTC7_ENABLE_OSC
Definition: rtc7.h:185
rtc7_display_results
void rtc7_display_results(rtc7_t *ctx)
Definition: main.c:36
time_date
rtc7_time_t time_date
Definition: main.c:32
rtc7_time_t::seconds
uint8_t seconds
Definition: rtc7.h:284
rtc7_t
Click ctx object definition.
Definition: rtc7.h:298
rtc7_time_t::minutes
uint8_t minutes
Definition: rtc7.h:285
rtc7_write_reg
err_t rtc7_write_reg(rtc7_t *ctx, uint8_t reg, uint8_t data_in)
Write one byte function.
RTC7_MAP_MIKROBUS
#define RTC7_MAP_MIKROBUS(cfg, mikrobus)
Definition: rtc7.h:66
rtc7_time_t::month
uint8_t month
Definition: rtc7.h:289
application_init
void application_init(void)
Definition: main.c:90
rtc7_get_local_time
err_t rtc7_get_local_time(rtc7_t *ctx, rtc7_time_t *local_time)
Get Local Time function.
RTC7_TIMER_FREQ_16HZ
#define RTC7_TIMER_FREQ_16HZ
Definition: rtc7.h:248
rtc7_cfg_setup
void rtc7_cfg_setup(rtc7_cfg_t *cfg)
Config Object Initialization function.
rtc7_set_osc
err_t rtc7_set_osc(rtc7_t *ctx, uint8_t enable_osc, uint8_t clk_in, uint8_t clk_out)
Oscillator Set function.
rtc7_init
err_t rtc7_init(rtc7_t *ctx, rtc7_cfg_t *cfg)
Initialization function.
RTC7_ERROR
#define RTC7_ERROR
Definition: rtc7.h:78
rtc7_read_reg
err_t rtc7_read_reg(rtc7_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Read one byte function.
rtc7_time_t::weekdays
uint8_t weekdays
Definition: rtc7.h:287
rtc7_set_gmt_time
err_t rtc7_set_gmt_time(rtc7_t *ctx, rtc7_time_t *time)
Set Gmt Time function.
time_set
rtc7_time_t time_set
Definition: main.c:31
rtc7_init_time
err_t rtc7_init_time(rtc7_t *ctx, int8_t time_zone)
Initialization function.