Functions

group group_sysclk_wco_funcs

Functions

cy_en_sysclk_status_t Cy_SysClk_WcoEnable(uint32_t timeoutus)

Enables the WCO.

Return

Error / status code:

CY_SYSCLK_SUCCESS - WCO successfully enabled

CY_SYSCLK_TIMEOUT - Timeout waiting for WCO to stabilize CY_SYSCLK_INVALID_STATE - ECO already enabled For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to

cy_en_pra_status_t for more details.

Function Usage

    /* Scenario: The WCO needs to source the backup clock for the real-time clock
                 operation. Timeout of 2ms is tolerable. The WCO pins are configured
                 using the gpio driver(SRSS_WCO_IN_PIN, SRSS_WCO_OUT_PIN). */

    /* Enable the WCO with a timeout of 2000 microseconds */
    if(CY_SYSCLK_SUCCESS != Cy_SysClk_WcoEnable(2000))
    {
        /* Insert error handling */
    }

    /* Set the backup clock source to WCO */
    Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO);

Parameters
  • timeoutus: amount of time in microseconds to wait for the WCO to be ready. If WCO is not ready, WCO is stopped. To avoid waiting for WCO ready set this to 0, and manually check if WCO is okay using Cy_SysClk_WcoOkay.

bool Cy_SysClk_WcoOkay(void)

Reports the status of the WCO_OK bit.

Return

true = okay

false = not okay

Function Usage

    /* Scenario: The WCO needs to source the backup clock for the real-time
                 clock operation. It needs to be enabled in a non-blocking
                 manner. The WCO pins are configured using the gpio driver
                 (SRSS_WCO_IN_PIN, SRSS_WCO_OUT_PIN). */

    /* Enable the WCO without timeout */
    (void)Cy_SysClk_WcoEnable(0UL);
    while(!Cy_SysClk_WcoOkay())
    {
        /* WCO is not yet ready. Perform some other operation. */
    }

    /* Set the backup clock source to WCO */
    Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO);

void Cy_SysClk_WcoDisable(void)

Disables the WCO.

Function Usage

    /* Scenario: LFCLK needs to be sourced by the PILO instead of the WCO. All
                 peripherals clocked by the LFCLK are disabled and the Watchdog
                 timer (WDT) is unlocked. */

    /* Disable the WCO */
    Cy_SysClk_WcoDisable();

    /* Enable the PILO */
    Cy_SysClk_PiloEnable();

    /* Set the LFCLK source to the PILO */
    Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_PILO);

void Cy_SysClk_WcoBypass(cy_en_wco_bypass_modes_t bypass)

Sets whether the WCO is bypassed or not.

If it is bypassed, then a 32-kHz clock must be provided on the wco_out pin.

Function Usage

    /* Scenario: An external watch crystal oscillator needs to be connected to
                 the WCO pins instead of a watch crystal. This signal needs
                 to source the backup clock for the real-time clock operation.
                 The WCO pins are configured using the gpio driver
                 (SRSS_WCO_IN_PIN, SRSS_WCO_OUT_PIN). */

    /* WCO bypassed mode - 32768 kHz square-wave supplied through SRSS_WCO_OUT_PIN pin */
    Cy_SysClk_WcoBypass(CY_SYSCLK_WCO_BYPASSED);

    /* Enable the WCO with a timeout of 2000 microsecond */
    if(CY_SYSCLK_SUCCESS != Cy_SysClk_WcoEnable(2000UL))
    {
        /* Insert error handling */
    }

    /* Set the backup clock source to WCO */
    Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO);

Parameters