Unlock precise timing control and synchronization capabilities to your solution with high-performance real-time clock solution
A
A
Hardware Overview
How does it work?
RTC 9 Click is based on the M41T82, an extreme low power real-time clock/calendar (RTC) module from STMicroelectronics. Thanks to its high integration level, this module provides high time accuracy, factory calibrated to ±5 ppm even after two reflows, with a very low count of external components required. It has a full RTC function, offering programmable counters, alarms, and an interrupt engine with selectable event reporting sources. The operational parameters are stored within the internal user SRAM memory, which is battery-backed, thus allowing their persistence in the event of the complete power failure. The M41T82 features a built-in 32.768 kHz oscillator.
However, RTC 9 click has an external oscillator too, in order to achieve the best accuracy possible. Eight bytes of the register map are used for the clock/calendar function and are configured in binary-coded decimal (BCD) format. An additional 17 bytes of the register map provide status/control of the two alarms, watchdog, 8-bit counter, and square wave functions. An additional seven bytes are made available as user SRAM. M41T82 supports the I2C communication interface, which is also used on the RTC 9 click for communicating with the main microcontroller through the mikroBUS socket. Functions available to the user include a non-volatile, time-of-day clock/calendar, two alarm
interrupts, watchdog timer, programmable 8-bit counter, and square wave outputs. The eight clock address locations contain the century, year, month, date, day, hour, minute, second, and tenths/hundredths of a second in 24-hour BCD format. Corrections for 28, 29 (leap year), 30, and 31 day months are made automatically. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used for further development.
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.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M4
MCU Memory (KB)
1024
Silicon Vendor
NXP
Pin count
121
RAM (Bytes)
262144
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for RTC 9 Click driver.
Key functions:
rtc9_set_time
- Set new time - 24 hour formatrtc9_get_time
- Get new time - 24 hour formatrtc9_get_date
- Get new date
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief Rtc9 Click example
*
* # Description
* This example demonstrates the use of RTC 9 click board.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, wakes up the module, and sets the time and date.
*
* ## Application Task
* Reads the current time and date and displays the results on the USB UART each second.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rtc9.h"
// ------------------------------------------------------------------ VARIABLES
static rtc9_t rtc9;
static log_t logger;
static uint8_t seconds_old = 0;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rtc9_cfg_t cfg;
rtc9_set_data_t set_data;
/**
* 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.
rtc9_cfg_setup( &cfg );
RTC9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rtc9_init( &rtc9, &cfg );
Delay_ms( 500 );
rtc9_wakeup( &rtc9 );
rtc9_set_time( &rtc9, 23, 59, 50 );
set_data.day = 22;
set_data.day_of_week = RTC9_DAY_MONDAY;
set_data.month = RTC9_MONTH_MARCH;
set_data.year = 21;
rtc9_set_date ( &rtc9, &set_data );
rtc9_wakeup( &rtc9 );
}
void application_task ( void )
{
rtc9_get_time_t get_time;
rtc9_get_date_t get_date;
char *week_string;
char *month_string;
rtc9_get_time( &rtc9, &get_time );
rtc9_get_date( &rtc9, &get_date );
if ( get_time.sec != seconds_old )
{
seconds_old = get_time.sec;
log_printf( &logger, "- Time [ %.2u:%.2u:%.2u ] \r\n", ( uint16_t ) get_time.hour,
( uint16_t ) get_time.min,
( uint16_t ) get_time.sec );
week_string = rtc9_current_day_of_week( get_date.day_of_week );
month_string = rtc9_current_month( get_date.month );
log_printf( &logger, "- Date [ %s, %s %.2u, %u ] \r\n", week_string, month_string,
( uint16_t ) get_date.day,
( uint16_t ) get_date.year + 2000 );
log_printf( &logger, "---------------------------------------- \r\n" );
}
Delay_ms( 10 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END