3.2.5 Clock (CLK)

This section describes the oscillator, the clocking system and how to configure them. The oscillators, PLLs and clock generators supply clocking to the system, including the CPU and peripherals. The components are configured to work together to produce the required clocks for the system. The following features are covered in this section:

• Clock Generator (CLKGENn)

• PLL Generator (PLLGENn)

• Clock sources including FRC, Primary, BFRC.

• Fail Safe Clock monitor (FSCM)

• REFO Clock

Using The Library

The Clock peripheral library initializes the clock system as configured by the user in the MCC.

Library Interface

Clock Generator peripheral library provides the following interfaces:

Functions

NameDescription
CLOCK_Initialize

Initializes clock system as per MCC configuration

CLOCK_GeneratorFrequencyGetReturns clock generator frequency in Hz
CLOCK_FailStatusGetReturns clock generator failure status
CLOCK_MonitorEnable

Enables clock monitor

CLOCK_MonitorDisableDisables clock monitor
CLOCK_MonitorIsReadyChecks if the clock monitor capture data is ready
CLOCK_MonitorAccumulatedCountGet

Returns the accumulated data after the capture

CLOCK_MonitorMonCallbackRegisterOverride default callback and to define custom callback for CLOCK Monitor Saturation event
CLOCK_MonitorWarnCallbackRegisterOverride default callback and to define custom callback for CLOCK Monitor Warning event
CLOCK_MonitorFailCallbackRegisterOverride default callback and to define custom callback for CLOCK Monitor Fail event
CLOCK_MonitorRdyCallbackRegisterOverride default callback and to define custom callback for CLOCK Monitor Data Ready event
CLOCK_CombinedClockFailCallbackRegisterOverride default callback and to define custom callback for CLOCK Combined Clock Fail event

Data types and constants

NameTypeDescription
CLOCK_GENERATOREnumDefines clock generators enabled in the clock plib
CLOCK_FAIL_STATUS_MASKSEnumDefines the fail status mask for each PLL generator and Clock generator
CLOCK_MONITOREnumDefines clock monitors enabled in the clock plib
CLOCK_MonitorMonCallbackTypedefDefines the Clock-Monitor callback function prototype
CLOCK_CombinedFailCallbackTypedef

Defines the Clock-Fail callback function prototype