TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139251 times)
  2. FAT32 Library (71749 times)
  3. Network Ethernet Library (57120 times)
  4. USB Device Library (47430 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28077 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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 21 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.8

mikroSDK Library: 2.0.0.0

Category: RTC

Downloaded: 90 times

Not followed.

License: MIT license  

RTC 21 Click is a compact add-on board that accurately keeps the time of the day. This board features the PT7C4311, an I2C-configurable real-time clock module with programmable square-wave output from Diodes Incorporated. The PT7C4311 includes time and calendar functions providing various information such as hour, minute, second, day, date, month, year, and century. It operates in a 24-hour format indicator, has automatic leap year compensation, and low power consumption, allowing it to be used with a single button cell battery for an extended period.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "RTC 21 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "RTC 21 Click" changes.

Do you want to report abuse regarding "RTC 21 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


RTC 21 Click

RTC 21 Click is a compact add-on board that accurately keeps the time of the day. This board features the PT7C4311, an I2C-configurable real-time clock module with programmable square-wave output from Diodes Incorporated. The PT7C4311 includes time and calendar functions providing various information such as hour, minute, second, day, date, month, year, and century. It operates in a 24-hour format indicator, has automatic leap year compensation, and low power consumption, allowing it to be used with a single button cell battery for an extended period.

rtc21_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Feb 2023.
  • Type : I2C type

Software Support

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

Standard key functions :

  • rtc21_cfg_setup Config Object Initialization function.

    void rtc21_cfg_setup ( rtc21_cfg_t *cfg );
  • rtc21_init Initialization function.

    err_t rtc21_init ( rtc21_t *ctx, rtc21_cfg_t *cfg );

Example key functions :

  • rtc21_set_time This function sets the starting time values - second, minute and hour.

    err_t rtc21_set_time ( rtc21_t *ctx, rtc21_time_t *time );
  • rtc21_set_date This function sets the starting date values - day of week, day, month and year.

    err_t rtc21_set_date ( rtc21_t *ctx, rtc21_date_t *date );
  • rtc21_read_time This function reads the current time values - second, minute and hour.

    err_t rtc21_read_time ( rtc21_t *ctx, rtc21_time_t *time );

Example Description

This example demonstrates the use of RTC 21 Click board by reading and displaying the time and date values.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger and then sets the starting time and date.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rtc21_cfg_t rtc21_cfg;  /**< Click config object. */

    /** 
     * 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.
    rtc21_cfg_setup( &rtc21_cfg );
    RTC21_MAP_MIKROBUS( rtc21_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc21_init( &rtc21, &rtc21_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    time.hour = 23;
    time.minute = 59;
    time.second = 50;
    if ( RTC21_OK == rtc21_set_time ( &rtc21, &time ) )
    {
        log_printf( &logger, " Set time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    date.day_of_week = RTC21_SATURDAY;
    date.day = 31;
    date.month = 12;
    date.year = 22;
    if ( RTC21_OK == rtc21_set_date ( &rtc21, &date ) )
    {
        log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc21_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
    Delay_ms ( 100 );

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

Application Task

Reads and displays on the USB UART the current time and date values once per second.

void application_task ( void )
{
    if ( RTC21_OK == rtc21_read_time ( &rtc21, &time ) )
    {
        log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }
    if ( RTC21_OK == rtc21_read_date ( &rtc21, &date ) )
    {
        log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n", 
                    rtc21_get_day_of_week_name ( date.day_of_week ),
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }
    Delay_ms ( 1000 );
}

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

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.


ALSO FROM THIS AUTHOR

Smart Card 2 Click

0

Smart Card 2 Click is a compact add-on board for reading smart cards. This board features Microchip’s SEC1210, a low-power single-chip Smart Card controller with a UART interface. The SEC1210 bridge controller uses a combination of hardware and software to deliver high-performance and flexible design customization options. It is fully compliant with standards like ISO/IEC 7816, EMV 4.2/4.3, ETSI TS 102 221, and PC/SC, utilizing TrustSpan™ technology that enables digital systems to communicate securely, process, move and store information. With its onboard card holder, it supports data processing with 2FF smart cards, and with an additional connector for external connection, it also allows the processing of a standard 1FF card.

[Learn More]

RN4871 Click

0

RN4871 Click carries the RN4871 Bluetooth® 4.2 low energy module from Microchip.The Click is designed to run on a 3.3V power supply. It uses ASCII Command Interface over UART for communication with target microcontroller, with additional functionality provided by the following pins on the mikroBUS™ line: RST, CS, and INT.

[Learn More]

mikromedia for PIC18FJ - Examples

5

Set of examples for mikromedia for PIC18FJ. Provided examples demonstrate working with mikromedia's various features and modules:
- Accelerometer
- MMC SD card
- MP3
- Serial Flash
- TFT
- Touch Panel
- USB

[Learn More]