22.4.1.2 Configure RTC
To operate the RTC, follow these steps:
- Set the compare value in the Compare (RTC.CMP) register, and/or the overflow value in the Period (RTC.PER) register.
- Enable the desired interrupts by writing to the respective interrupt enable bits (CMP, OVF) in the Interrupt Control (RTC.INTCTRL) register.
- Configure the RTC internal prescaler by writing the desired value to the Prescaler (PRESCALER) bit field in the Control A (RTC.CTRLA) register.
- Enable the RTC by writing a
‘
1
’ to the RTC Peripheral Enable (RTCEN) bit in the RTC.CTRLA register.
Note: The RTC peripheral is used internally
during device start-up. Always check the Synchronization Busy bits in the Status
(RTC.STATUS) and Periodic Interrupt Timer Status (RTC.PITSTATUS) registers, and on the
initial configuration.