TOP Contributors

  1. MIKROE (2656 codes)
  2. Alcides Ramos (353 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136886 times)
  2. FAT32 Library (70014 times)
  3. Network Ethernet Library (56001 times)
  4. USB Device Library (46305 times)
  5. Network WiFi Library (41933 times)
  6. FT800 Library (41208 times)
  7. GSM click (29017 times)
  8. PID Library (26426 times)
  9. mikroSDK (26398 times)
  10. microSD click (25386 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

RTC 8 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: RTC

Downloaded: 193 times

Not followed.

License: MIT license  

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.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "RTC 8 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "RTC 8 click" changes.

Do you want to report abuse regarding "RTC 8 click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


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.

rtc8_click.png

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 ); 
  • rtc8_init Initialization function.

    err_t rtc8_init ( rtc8_t *ctx, rtc8_cfg_t *cfg );
  • rtc8_default_cfg Click Default Configuration function.

    err_t rtc8_default_cfg ( rtc8_t *ctx );

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 );
  • rtc8_set_date Set new date

    err_t rtc8_set_date ( rtc8_t *ctx, rtc8_date_t *date_s );
  • 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 );

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.

void application_init ( void )
{
    log_cfg_t log_cfg;
    rtc8_cfg_t rtc8_cfg;

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    rtc8_cfg_setup( &rtc8_cfg );
    RTC8_MAP_MIKROBUS( rtc8_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc8_init( &rtc8, &rtc8_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( RTC8_ERROR == rtc8_default_cfg ( &rtc8 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    // 24h format - HH,MM,SS
    time_s.hours = 23;
    time_s.minutes = 59;
    time_s.seconds = 50;

    rtc8_set_time( &rtc8, &time_s );

    // Set date format
    date_s.weekdays = 5;
    date_s.day = 31;
    date_s.month = 12;
    date_s.year = 22;

    rtc8_set_date( &rtc8, &date_s );

    // Set UNIX time
    rtc8_set_unix_time( &rtc8, 1672527590ul );

    // Set alarm format
    alarm_s.weekdays = 6;
    alarm_s.hours = 0;
    alarm_s.minutes = 0;

    rtc8_set_alarm( &rtc8, &alarm_s );

    log_info( &logger, " Application Task " );
} 

Application Task

Read current Time, Date and UNIX time and checks if the alarm is active.

void application_task ( void )
{
    static uint8_t time_seconds = 0xFF;
    uint8_t alarm = 0;
    uint32_t unix_time = 0;

    err_t error_flag = rtx8_get_time_and_date( &rtc8, &time_s, &date_s );
    error_flag |= rtc8_get_uinx_time( &rtc8, &unix_time );
    error_flag |= rtc8_get_alarm_flag( &rtc8, &alarm );

    if ( ( RTC8_OK == error_flag ) && ( time_seconds != time_s.seconds ) )
    {
        display_weekday ( date_s.weekdays );
        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 );
        if ( RTC8_ALARM_IS_ACTIVE == alarm )
        {
            log_info( &logger, " Alarm Activated!!! " );
            rtc8_reset_alarm_flag( &rtc8 );
        }
        log_printf( &logger, "------------------\r\n" );
        time_seconds = time_s.seconds;
    }
    Delay_ms ( 200 );
}

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.


ALSO FROM THIS AUTHOR

Brushless 20 click

0

Brushless 20 Click is a compact add-on board that controls brushless DC (BLDC) motors with any MCU. This board features the DRV8313, a fully integrated three-phase BLDC motor driver from Texas Instruments. It provides three individually controllable half-H-bridge drivers intended to drive a three-phase BLDC motor, solenoids, or other loads. Each output driver channel consists of N-channel power MOSFETs configured in a 1/2-H-bridge configuration. Besides, it has a wide operating voltage range from 8V to 60V, alongside several built-in protection circuits such as undervoltage, charge pump faults, overcurrent, and overtemperature.

[Learn More]

Thermo 28 click

0

Thermo 28 Click is a compact add-on board that accurately measures temperature. This board features the ams AG’s AS6221, a high-accuracy digital temperature sensor. The AS6221 consists of a Si bandgap temperature factory-calibrated sensor, 16-bit ADC, and a digital signal processor, offering a high accuracy of ±0.9°C. It provides temperature data to the host controller through a compatible I2C interface, reliability, user-selectable I2C addresses, and alert functionality, which triggers an interrupt to protect the device from excessive temperatures.

[Learn More]

Thumbwheel click

15

Thumbwheel click is a mikroBUS add-on board with a 10-position rotary sprocket connected to a 1-Wire 8-Channel Addressable Switch.

[Learn More]