3. RTC oscillator
The RTC oscillator provides a 1 Hz clock to the RTC and a 32 kHz clock output that can
be used as the clock source for PLL0 and CPU and/or the watchdog timer.
Remark: The RTC oscillator must not be used as a clock source when the PLL0 output is
selected to drive the USB controller. In this case select the main oscillator as clock source
for PLL0
5. The Clock Control Register controls the operation of the clock divide circuit.
Bit 0 – CLKEN : Clock Enable
This bit is written with one to enable time counters and written with zero to disable time counters.
Bit 1 - CTCRST : CTC Reset
When this bit is set to one, the internal oscillator divider are reset.
Bit 3:2 - Reserved
These bits must be set to zero for normal RTC operation.
Bit 4 - CCALEN : Calibration counter enable
To disable calibration counter and reset it to zero, write one to this bit. When written zero, the counter is
enabled and starts counting
Bit 31:5 - Reserved
CCR ( Clock Control Register )
6. Time Counter Register
The time value consists of the eight counters and there is separate register associated with each counter. To
update the RTC, new values should be written to these registers.
7. Consolidated Time Registers
The values of the Time Counters can optionally be read in a consolidated format which allows the programmer to read
all time counters with only three read operations.
There are 3 Consolidated Time Registers. The minimum and maximum values of the various fields in these registers
are same as the respective Time Counter Register.
These registers are read only. New values should be written to Time Counter Registers.
8. Steps for Using RTC
Initialize RTC
•Disable RTC clock using CCR ( Clock Control Register )
•Reset clock using CCR register
•Enable RTC calibration in RTC Calibration Register
•Enable the clock for RTC using CCR register
Set Date and Time
As we saw previously, there are separate Time Counter registers for each time
parameter hour, min, sec and same is the case date. We just need to copy the
required values to these registers.
Read Date and Time
The values of date and time can be read from associated Time Counter
registers. Alternately, date and time can also be read from Consolidated Time
registers.
We will use Time Counter registers for both reading and writing.