35.4 Processor Clock Controller
The PMC features a Processor Clock (CPU_CLK) controller that implements the processor Sleep mode. CPU_CLK can be disabled by executing the WFI (WaitForInterrupt) or the WFE (WaitForEvent) processor instruction.
CPU_CLK is enabled after a reset and is automatically re-enabled by any enabled interrupt. The processor Sleep mode is entered by disabling CPU_CLK, which is automatically re-enabled by any enabled interrupt, or by the reset of the product.
When processor Sleep mode is entered, the current instruction is finished before the CPU_CLK is stopped, but this does not prevent data transfers from other hosts of the system bus.
The clock selection is done in PMC_CPU_CKR.CSS.
The prescaler is configured in PMC_CPU_CKR.PRES.
The Processor Clock Controller also generates a main system bus clock, MCK0, which is a subdivision of the FCLK.
Only one of CSS, PRES and MDIV fields can be modified at a time. When one of these parameters is modified, no other modification can be performed on these fields as long as the MCKRDY status flag is low.
Any modification in CSS, PRES or MDIV fields must never lead to generate an MCK frequency that is greater than the maximum allowed system frequency. When changing the source clock of the system to a faster clock, the fields must be modified using the following order: MDIV, PRES and then CSS. When changing the source clock of the system to a slower clock, the fields must be modified using the following order: CSS, PRES and then MDIV.
If the destination clock does not exist, the switching is not performed. The CPU_CLK keeps running with the previous clock and the system must be reset to run correctly again.
The user must implement a timeout when monitoring the MCKRDY flag after a clock source switching in order to perform a reset in case switching fails.
The Processor Clock Controller features a dynamic frequency scaling mechanism that allows the CPU_CLK to be a non-integer division of the free-running clock.