Microchip® Advanced Software Framework

Quick start guide for RTC driver

This is the quick start guide for the RTC driver, with step-by-step instructions on how to configure and use the drivers in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic use case

In this basic use case, the RTC is configured for:

  • Clock source: 1 kHz from internal 32 kHz ULP
  • Prescaling: RTC clock/1024

Setup steps

Example code

Content of conf_rtc.h:

#define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1024_gc

Needed in conf_clock.h:

#define CONFIG_RTC_SOURCE SYSCLK_RTCSRC_ULP

Add to the initialization code:

Workflow

  1. Ensure that conf_rtc.h is present for the driver.
    • Note
      This configuration file is used by the driver and should not be included by the user.
  2. Initialize system clock:
    • Note
      Make sure the define CONFIG_RTC_SOURCE is defined in conf_clock.h
  3. Call RTC driver's own init function to start up the RTC and start counting from zero:

Usage steps

Example code

Add to, e.g., main loop in application C-file:

Workflow

  1. Get current time of the RTC:

Advanced use cases

For more advanced use of the RTC driver, see the following use cases: