RTC_C Operation
722
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
Real-Time Clock C (RTC_C)
NOTE:
Invalid alarm settings
Invalid alarm settings are not checked by hardware. It is the user's responsibility that valid
alarm settings are entered.
NOTE:
Invalid time and date values
Writing of invalid date or time information or data values outside the legal ranges specified in
the RTCSEC, RTCMIN, RTCHOUR, RTCDAY, RTCDOW, RTCYEARH, RTCYEARL,
RTCAMIN, RTCAHOUR, RTCADAY, and RTCADOW registers can result in unpredictable
behavior.
NOTE:
Setting the alarm
Before setting an initial alarm, all alarm registers including the AE bits should be cleared.
To prevent potential erroneous alarm conditions from occurring, the alarms should be
disabled by clearing the RTCAIE, RTCAIFG, and AE bits before writing initial or new time
values to the RTC time registers.
29.2.4 Real-Time Clock Protection
RTC_C registers are key protected to ensure clock integrity and module configuration against software
crash or from runaway code. Key protection does not apply for reads from the RTC_C registers. That is,
any RTC_C register can be read at any time without having to unlock the module. Some predefined
registers of RTC_C are key protected for write access. The control registers, clock registers, calendar
register, prescale timer registers, and offset error calibration registers are protected. RTC_C alarm
function registers, prescale timer control registers, interrupt vector register, and temperature compensation
registers are not protected. RTC_C registers that are not protected can be written at any time without
unlocking the module.
shows which registers are affected by the protection scheme.
The RTCCTL0_H register implements key protection and controls the lock or unlock state of the module.
When this register is written with correct key, 0A5h, the module is unlocked and unlimited write access
possible to RTC_C registers. After the module is unlocked, it remains unlocked until the user writes any
incorrect key or until the module is reset. A read from RTCCTL0_H register returns value 96h. Write
access to any protected registers of RTC_C is ignored when the module is locked.
RTC_C Key Protection Software Example
; Unlock/lock sequence for RTC_C
MOV.B
#RTCKEY, &RTCCTL0_H
; Write correct key to unlock RTC_C
MOV.B
#8bit_value, &RTCSEC
; Write 8 bit value into RTCSEC
MOV.B
#8bit_value, &RTCMIN
; Write 8 bit value into RTCMIN
MOV.W
#16bit_value, &RTCTIM1
; Write 16bit value into RTCTIM1
MOV.W
#8bit_value, &RTCCTL0
; Write into RTCCTL0 with correct key in word mode
...
MOV.B
#00h, &RTCCTL0_H
; Write incorrect key to lock RTC_C