# Function system_main_clock_set_failure_detect()

Enable or disable the main clock failure detection.

void system_main_clock_set_failure_detect(
const bool enable)

This mechanism allows switching automatically the main clock to the safe RCSYS clock, when the main clock source is considered off.

This may happen for instance when an external crystal is selected as the clock source of the main clock and the crystal dies. The mechanism is to detect, during a RCSYS period, at least one rising edge of the main clock. If no rising edge is seen the clock is considered failed. As soon as the detector is enabled, the clock failure detector (CFD) will monitor the divided main clock. When a clock failure is detected, the main clock automatically switches to the RCSYS clock and the CFD interrupt is generated if enabled.

Note: The failure detect must be disabled if the system clock is the same or slower than 32KHz as it will believe the system clock has failed with a too slow clock.
Table 1. Parameters
Data direction Parameter name Description

[in]

enable

Boolean true to enable, false to disable detection