A low-power analog continuously operating clock monitor is provided to ensure that LFCLK is running when it is not sourced internally (for example, when LFCLK is sourced from LFXT or LFCLK_IN and not from LFOSC). The LFCLK monitor is only intended to check for clock stuck faults. It is not intended to be used to verify that the frequency of LFCLK is within a specific tolerance.
Enabling the LFCLK Monitor
The LFCLK monitor is disabled at startup after a BOOTRST, unless the cause of the BOOTRST was the NRST pin.
If the STARTLFXT bit in the LFXTCTL
register is set, the LFCLK monitor monitors the LFXT. If the STARTLFXT bit is left
cleared, the LFCLK monitor monitors the LFCLK_IN.
Before enabling the LFCLK monitor, make sure that the source clock has started and is
operating at 32 kHz. If STARTLFXT is set and the monitor is checking the LFXT, wait
for the LFXTGOOD indication before enabling the LFCLK monitor. If STARTLFXT is
cleared and the monitor is checking the LFCLK_IN digital clock input, make sure that
the external clock signal is active before enabling the LFCLK monitor. If a valid
clock is not present when starting the monitor, the monitor will assert a fault.
The LFCLK continuous monitor can be enabled by setting the MONITOR bit in LFCLKCFG register.
Note: The LFCLK monitor requires 100 µs to become active after being enabled. The LFCLK monitor can be enabled to monitor LFXT or LFCLK_IN before switching the LFCLK source from the internal LFOSC.
LFCLK Monitor Fault Handling
If an LFCLK stuck fault is detected, the system responds in one of two ways depending on the system clock configuration:
- If LFCLK is the source for MCLK
(for example, if the entire system is running at 32 kHz derived from LFCLK),
then a LFCLK fault is considered fatal and a BOOTRST is asserted. Following the
BOOTRST, MCLK will be sourced from SYSOSC at BASE frequency, and LFCLK will be
sourced from LFOSC.
- If LFCLK is not the source for
MCLK at the time of the failure or after the failure, an LFCLK fault asserts a
non-maskable interrupt (NMI) to the processor so that the application can
immediately handle the fault and take any necessary action.
Falling Back to LFOSC After LFXT Failure
In the event that an LFXT or LFCLK_IN failure is detected and the failure is due to a
system level / PCB level issue that is preventing the external clock source from
being able to run reliably, it is possible to fall back to the internal 32kHz LFOSC
rather then continuously trying to use the LFXT or LFCLK_IN. In this case, the
following procedure is recommended:
- Configure the device with LFXT or LFCLK_IN sourcing LFCLK and with the LFCLK
monitor enabled, per the procedure given above in Enabling the LFCLK
Monitor.
- In the event of an LFCLK monitor fault detection:
- If MCLK is sourced from LFCLK, the failure will generate a BOOTRST
automatically.
- If MCLK is not sourced from LFCLK, an NMI will be generated. In the
NMI handling, application software can switch MCLK to LFCLK when the
LFCLK fault is detected. This action will trigger the hardware to
generate a BOOTRST automatically. Switching the MCLK source to
LFCLK may be done by changing the operating mode from RUN0 to
RUN1/RUN2 or STOP2/STANDBY.
- Following the BOOTRST, MCLK will be sourced from SYSOSC at BASE frequency,
and LFCLK will be sourced from LFOSC. Application software can check the
cause of the reset was a fatal clock fault and decide what action to
take.
- Application software may attempt again to use LFXT/LFCLK_IN. If the
LFCLK fails again, application software can return to step 2 above
to again switch LFCLK back to LFOSC.
- To track the number of LFCLK failures, application software can
store diagnostic information in the shutdown memory of the device. The SHUTDNSTOREx memory
locations are retained through a BOOTRST. As such, it is possible
for the application software to track how many LFCLK failures have
occurred, and if that number exceeded some threshold, application
software can elect to remain with LFOSC as the LFCLK source rather
then again attempting to use the LFXT/LFCLK_IN.