In this use case, the RTC is set up in calendar mode.
The time is set and also an alarm is set to show a general use of the RTC in calendar mode. Also the clock is swapped from 24h to 12h mode after initialization. The board LED will be toggled once the current time matches the set time.
The Generic Clock Generator for the RTC should be configured and enabled; if you are using the System Clock driver, this may be done via conf_clocks.h
.
The conf_clock.h
file needs to be changed with the different values to configure the clocks and oscillators for the module according to the used device.
For example, the following oscillator settings are needed for SAMD21:
The following generic clock settings are needed for SAMD21:
Create an rtc_module struct and add to the main application source file, outside of any functions:
Copy-paste the following setup code to your application:
Add the following to main()
.
Add the following to main()
.