RTC (Real Time Clock)
• Real Time Clock (RTC) is a time counter that counts real time
continuously.
• We can get present time details using RTC. It gives us time as well as
date information.
• RTC is clocked by separate 32.768KHz oscillator to continuously keep
track of current time.
• RTC is powered either by main system power or separately by battery
backup in absence of main system power.
• Since RTC needs to be running continuously, it should be provided
with battery backup in case of main system power failure. Otherwise,
it can lose present time information.
RTC (Real Time Clock)
• We can easily program the RTC with the current date and time
information in the case of loss time and date information due to
power failure.
• But this is not a feasible solution in real time systems once they are
deployed into the market, where there are many time constraints on
the tasks and timely decision making is important.
• In such cases, the RTC must not fail. This makes battery backup of
utmost importance.
RTC (Real Time Clock) in LPC2148
• LPC2148 has an inbuilt RTC.
• LPC2148RTC can be clocked by a separate 32.768 KHz oscillator or by
a programmable prescale divider based on the APB clock.
• It maintains a calendar and clock and provides seconds, minutes, hours,
month, year, day of week, day of month and day of year.
• It has power supply pin that can be connected to a battery or to the main
3.3V.
• It uses little power in power down mode.
• And most important, it has Alarm functionality.
RTC (Real Time Clock) in LPC2148
• RTCX1 & RTCX2 (RTC Crystal Pins)
• These pins are used to connect RTC external crystal. Generally, 32.768 kHz
crystal oscillator is connected to these pins.
• VBAT (RTC Power pin)
• Power to the RTC unit is given through this pin. Either it will be from main
system power or from battery backup mechanism.
• There are various RTC Registers that are used to set and control RTC
operations. (We are not going into details of those registers-few
registers will be discussed)
• Time Counter Group
• Alarm Register Group
Time Counter Group
• It consists of 8
counters.
• These can be
read/write.
Alarm Register Group
• It consists of 8
counters.
• The values in
these registers
are compared
with the timer
counters.
• If all unmasked
alarm registers
match their
corresponding
time counters,
then an
interrupt is
generated.
Programming Example
Example
We can write a program to set RTC time and generate alarm at desired time.
• UART0 is used to display time and alarm event on PC terminal.
• An LED is also used as an indicator of the alarm.
• The LED is blinked for 6 seconds when the alarm is turned on.
• The corresponding program is available in electronicwings site:
[Link]
RTC run using 32.768 kHz crystal as well as using prescaler (register).
• There is a youtube link as well to watch.