Intermediate
30 min

Turn moments into opportunities with our RTC solution combined with MK64FN1M0VDC12

Sync your world with our real-time clock – experience perfect timing!

RTC 20 Click with Clicker 2 for Kinetis

Published Oct 21, 2023

Click board™

RTC 20 Click

Dev. board

Clicker 2 for Kinetis

Compiler

NECTO Studio

MCU

MK64FN1M0VDC12

Experience the precision of advanced real-time clock technology, ensuring reliable timekeeping and synchronization in your solution

A

A

Hardware Overview

How does it work?

RTC 20 Click is based on the AB0805, a low-power, real-time clock (RTC) time-keeping device from Abracon. The AB0805 is configured to transmit calendar and time data to the MCU based on a 32.768kHz quartz crystal and comes with 256 bytes of general-purpose RAM. It reads and writes clock/calendar data from and to the MCU in units ranging from seconds to the last two digits of the calendar year, providing seconds, minutes, hours, dates, days, weeks, months, years, and century information. The end-of-the-month date is automatically adjusted for months with fewer than 31 days, including corrections for the leap year until 2199. This Click board™

communicates with the MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting a Fast Mode operation up to 400kHz. By utilizing an automatic backup switch feature, this RTC can use an external power source (220mF supercapacitor) when there is no power supply on its main power terminals, thus allowing for uninterrupted operation. Besides an automatic backup switchover circuit, the AB0805 has flexible inputs that aggregate various interrupt sources to an MCU. Based on this, functions like external interrupt or watchdog timer reset could be found on this Click board™ routed on the EXT and WDI pins of the mikroBUS™ socket, as well as the

primary and secondary interrupt signals routed on the IR1 and IR2 pins of the mikroBUS™ socket. In addition to the alarm/interrupt feature, the IR1 signal also provides the selectable-frequency square wave signal (512Hz default value). This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

RTC 20 Click top side image
RTC 20 Click bottom side image

Features overview

Development board

Clicker 2 for Kinetis is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4F microcontroller, the MK64FN1M0VDC12 from NXP Semiconductors, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a JTAG programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and

features quickly. Each part of the Clicker 2 for Kinetis development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for Kinetis programming method, using a USB HID mikroBootloader or an external mikroProg connector for Kinetis programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or

using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for Kinetis is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Clicker 2 for Kinetis dimensions image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

NXP

Pin count

121

RAM (Bytes)

262144

Used MCU Pins

mikroBUS™ mapper

Secondary Interrupt
PB2
AN
Watchdog Timer Reset
PB11
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
External Interrupt
PA10
PWM
Primary Interrupt
PB13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PD8
SCL
I2C Data
PD9
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

RTC 20 Click Schematic schematic

Step by step

Project assembly

Clicker 2 for PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 2 for Kinetis as your development board.

Clicker 2 for PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Software Support

Library Description

This library contains API for RTC 20 Click driver.

Key functions:

  • rtc20_set_time - RTC 20 set time function.

  • rtc20_set_date - RTC 20 set date function.

  • rtc20_get_time - RTC 20 get time function.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief RTC 20 Click example
 *
 * # Description
 * This example demonstrates the use of the RTC 20 Click board™
 * by reading and displaying the RTC time and date values.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of I2C module, log UART and additional pins.
 * After driver initialization the app set RTC time to 23:59:50
 * and set date to Tuesday 28.02.2023.
 *
 * ## Application Task
 * This is an example that shows the use of a RTC 20 Click board™.
 * In this example, we read and display the current time ( PM ) 
 * and date ( day of the week ), which we also previously set.
 * Results are being sent to the Usart Terminal where you can track their changes.
 * All data logs write on USB changes every 1 sec.
 *
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "rtc20.h"

static rtc20_t rtc20;
static log_t logger;
static uint8_t new_sec = 255;
static rtc20_time_t time;
static rtc20_date_t date;

/**
 * @brief RTC 20 display day of week name function.
 * @details This function display the name of day of the week.
 */
static void display_day_of_week ( void );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rtc20_cfg_t rtc20_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.
    rtc20_cfg_setup( &rtc20_cfg );
    RTC20_MAP_MIKROBUS( rtc20_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rtc20_init( &rtc20, &rtc20_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    time.hour   = 23;
    time.minute = 59;
    time.second = 50;
    if ( RTC20_OK == rtc20_set_time( &rtc20, time ) )
    {
        log_printf( &logger, "  Set time : %.2d:%.2d:%.2d\r\n", 
                    ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
    }

    date.day_of_week = RTC20_DW_TUESDAY;
    date.day         = 28;
    date.month       = 2;
    date.year        = 23;
    if ( RTC20_OK == rtc20_set_date( &rtc20, date ) )
    {
        log_printf( &logger, "  Set date : %.2d-%.2d-%.2d\r\n", 
                    ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
    }

    Delay_ms ( 1000 );
    log_printf( &logger, "---------------------\r\n" );
}

void application_task ( void ) 
{
    if ( RTC20_OK == rtc20_get_time( &rtc20, &time ) )
    {
        if ( RTC20_OK == rtc20_get_date( &rtc20, &date ) )
        {
            if ( time.second != new_sec )
            {
                log_printf( &logger, "  Date : %.2d-%.2d-%.2d\r\n", 
                            ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
                display_day_of_week( );
                log_printf( &logger, "  Time : %.2d:%.2d:%.2d\r\n", 
                            ( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
                log_printf( &logger, "- - - - - - - - - - -\r\n" );
                new_sec = time.second;
                Delay_ms ( 1 );
            }
        }
    }
    Delay_ms ( 1 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void display_day_of_week ( void ) 
{
    switch ( date.day_of_week ) 
    {
        case RTC20_DW_SUNDAY: 
        {
            log_printf( &logger, "Sunday\r\n" );
            break;
        }
        case RTC20_DW_MONDAY: 
        {
            log_printf( &logger, "Monday\r\n" );
            break;
        }
        case RTC20_DW_TUESDAY: 
        {
            log_printf( &logger, "Tuesday\r\n" );
            break;
        }
        case RTC20_DW_WEDNESDAY: 
        {
            log_printf( &logger, "Wednesday\r\n" );
            break;
        }
        case RTC20_DW_THURSDAY: 
        {
            log_printf( &logger, "Thursday\r\n" );
            break;
        }
        case RTC20_DW_FRIDAY: 
        {
            log_printf( &logger, "Friday\r\n" );
            break;
        }
        case RTC20_DW_SATURDAY: 
        {
            log_printf( &logger, "Saturday\r\n" );
            break;
        }
        default:
        {
            log_printf( &logger, "Unknown\r\n" );
        }
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.