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
EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development 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
PIC
MCU Memory (KB)
24
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
2048
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
This Click board can be interfaced and monitored in two ways:
Application Output
- Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
UART Terminal
- Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
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
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
* \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