CAT2 Peripheral Driver Library

Functions

cy_en_sysclk_status_t Cy_SysClk_ClkHfSetSource (cy_en_sysclk_clkhf_src_t source)
 Selects the source of the HFCLK. More...
 
cy_en_sysclk_clkhf_src_t Cy_SysClk_ClkHfGetSource (void)
 Reports the source of the HFCLK. More...
 
__STATIC_INLINE void Cy_SysClk_ClkHfSetDivider (cy_en_sysclk_dividers_t divider)
 Sets a divider value for HFCLK. More...
 
__STATIC_INLINE cy_en_sysclk_dividers_t Cy_SysClk_ClkHfGetDivider (void)
 Returns the HFCLK divider value. More...
 
uint32_t Cy_SysClk_ClkHfGetFrequency (void)
 Reports the frequency of the HFCLK. More...
 

Detailed Description

Function Documentation

◆ Cy_SysClk_ClkHfSetSource()

cy_en_sysclk_status_t Cy_SysClk_ClkHfSetSource ( cy_en_sysclk_clkhf_src_t  source)

Selects the source of the HFCLK.

Parameters
sourcecy_en_sysclk_clkhf_src_t
Returns
Error / status code cy_en_sysclk_status_t :
CY_SYSCLK_SUCCESS - the source is successfully set;
CY_SYSCLK_INVALID_STATE - the selected clock source is not enabled or does not working;
CY_SYSCLK_BAD_PARAM - the source parameter is invalid.
Note
Call SystemCoreClockUpdate after this function calling if SYSCLK frequency is affected.
Call Cy_SysLib_SetWaitStates before this function calling if SYSCLK frequency is increasing.
Call Cy_SysLib_SetWaitStates after this function calling if SYSCLK frequency is decreasing.
Function Usage
/* Scenario: HFCLK needs to be switched to the ECO (if ECO is enabled, of course) */
if (Cy_SysClk_EcoIsEnabled() && (CY_SYSCLK_ECO_STABLE == Cy_SysClk_EcoGetStatus())) /* If ECO enabled and stabilized */
{
{
Cy_SysClk_PllBypass(0U, CY_SYSCLK_PLL_BYP_ECO); /* First make multiplexing inside the EXCO block */
}
if (CY_SYSCLK_SUCCESS != sysclkStatus)
{
/* Insert error handling */
}
}
/* Scenario: HFCLK needs to be switched to the HPOSC (if HPOSC is enabled, of course) */
if (Cy_SysClk_HposcIsEnabled()) /* If HPOSC enabled */
{
if (CY_SYSCLK_SUCCESS != sysclkStatus)
{
/* Insert error handling */
}
}

◆ Cy_SysClk_ClkHfGetSource()

cy_en_sysclk_clkhf_src_t Cy_SysClk_ClkHfGetSource ( void  )

Reports the source of the HFCLK.

Returns
cy_en_sysclk_clkhf_src_t :
CY_SYSCLK_CLKHF_IN_IMO - IMO - Internal R/C Oscillator.
CY_SYSCLK_CLKHF_IN_EXTCLK - EXTCLK - External Clock Pin.
CY_SYSCLK_CLKHF_IN_EXCO - EXCO block output, normally ECO or PLL (use Cy_SysClk_PllBypass to select between them). As part of the Clock Supervisor (CSV) failover strategy, when a fault is detected, the EXCO block output will be automatically switched to IMO and the CY_SYSCLK_INTR_SW_IMO interrupt will be generated.
CY_SYSCLK_CLKHF_IN_HPOSC - High Precision Oscillator.
Function Usage
/* Scenario: If ECO is enabled and sources HFCLK then the ECO needs
* to be disabled and replaced with the IMO for HFCLK
*/
if (Cy_SysClk_EcoIsEnabled()) /* If ECO enabled */
{
/* If ECO sources HFCLK */
{
/* First update the HFCLK clock to IMO */
{
/* Insert error handling */
}
}
/* Disable the ECO */
}

◆ Cy_SysClk_ClkHfSetDivider()

__STATIC_INLINE void Cy_SysClk_ClkHfSetDivider ( cy_en_sysclk_dividers_t  divider)

Sets a divider value for HFCLK.

Parameters
dividercy_en_sysclk_dividers_t
Note
Also call Cy_SysClk_ClkHfSetSource to set the HFCLK source.
Call SystemCoreClockUpdate after this function calling.
Call Cy_SysLib_SetWaitStates before calling this function if SYSCLK frequency is increasing.
Call Cy_SysLib_SetWaitStates after calling this function if SYSCLK frequency is decreasing.
Function Usage
/* Scenario: Set HFCLK divider to 8, to reduce frequency and save power */
{
/* Set the HFCLK divider to 8 */
}
/* Check the HFCLK frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();

◆ Cy_SysClk_ClkHfGetDivider()

__STATIC_INLINE cy_en_sysclk_dividers_t Cy_SysClk_ClkHfGetDivider ( void  )

Returns the HFCLK divider value.

Returns
cy_en_sysclk_dividers_t :
CY_SYSCLK_NO_DIV - don't divide.
CY_SYSCLK_DIV_2 - divide by 2
CY_SYSCLK_DIV_4 - divide by 4
CY_SYSCLK_DIV_8 - divide by 8
Function Usage
/* Scenario: Set HFCLK divider to 8, to reduce frequency and save power */
{
/* Set the HFCLK divider to 8 */
}
/* Check the HFCLK frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();

◆ Cy_SysClk_ClkHfGetFrequency()

uint32_t Cy_SysClk_ClkHfGetFrequency ( void  )

Reports the frequency of the HFCLK.

Returns
The frequency, in Hz.
Note
The reported value may be zero, which indicates the frequency is unknown.
If Clock Supervisor (CSV) has detected an ECO fault and automatically switched the EXCO output to IMO, this function will still report the configured ECO frequency (not the actual IMO frequency being output). To detect if CSV failover has occurred, check the CY_SYSCLK_INTR_SW_IMO interrupt status using Cy_SysClk_GetInterruptStatus or Cy_SysClk_GetInterruptStatusMasked.
Function Usage
/* Scenario: Set HFCLK divider to 8, to reduce frequency and save power */
{
/* Set the HFCLK divider to 8 */
}
/* Check the HFCLK frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();