Functions

group group_sysclk_clk_timer_funcs

Functions

void Cy_SysClk_ClkTimerSetSource(cy_en_clktimer_in_sources_t source)

Sets the source for the timer clock (clk_timer).

The timer clock can be used as a source for SYSTICK as an alternate clock and one or more of the energy profiler counters.

Function Usage

    /* Scenario: The timer clock source needs to be updated to HFCLK0. */

    if(CY_SYSCLK_CLKTIMER_IN_HF0_NODIV != Cy_SysClk_ClkTimerGetSource())
    {
        Cy_SysClk_ClkTimerSetSource(CY_SYSCLK_CLKTIMER_IN_HF0_NODIV);
    }

Parameters

sourcecy_en_clktimer_in_sources_t

cy_en_clktimer_in_sources_t Cy_SysClk_ClkTimerGetSource(void)

Reports the source for the timer clock (clk_timer).

Function Usage

    /* Scenario: The timer clock source needs to be updated to HFCLK0. */

    if(CY_SYSCLK_CLKTIMER_IN_HF0_NODIV != Cy_SysClk_ClkTimerGetSource())
    {
        Cy_SysClk_ClkTimerSetSource(CY_SYSCLK_CLKTIMER_IN_HF0_NODIV);
    }

Returns

cy_en_clktimer_in_sources_t

void Cy_SysClk_ClkTimerSetDivider(uint8_t divider)

Sets the divider for the timer clock (clk_timer).

note

Do not change the divider value while the timer clock is enabled.

Function Usage

    /* Scenario: The timer divider needs to be updated to 64. */

    if(63u != Cy_SysClk_ClkTimerGetDivider())
    {
        Cy_SysClk_ClkTimerSetDivider(63u); /* divider = value + 1 */
    }

Parameters

divider – Divider value; valid range is 0 to 255. Divides the selected source (Cy_SysClk_ClkTimerSetSource) by the (value + 1).

uint8_t Cy_SysClk_ClkTimerGetDivider(void)

Reports the divider value for the timer clock (clk_timer).

Function Usage

    /* Scenario: The timer divider needs to be updated to 64. */

    if(63u != Cy_SysClk_ClkTimerGetDivider())
    {
        Cy_SysClk_ClkTimerSetDivider(63u); /* divider = value + 1 */
    }

Returns

The divider value

void Cy_SysClk_ClkTimerEnable(void)

Enables the timer clock (clk_timer).

The timer clock can be used as a source for SYSTICK and one or more of the energy profiler counters.

Function Usage

    /* Scenario: Timer clock needs to operate at HFCLK/32. */

    Cy_SysClk_ClkTimerSetSource(CY_SYSCLK_CLKTIMER_IN_HF0_DIV8);
    Cy_SysClk_ClkTimerSetDivider(3u); /* divider = value + 1 */
    Cy_SysClk_ClkTimerEnable();

    /* Use the Timer clock as a source for the alternative ARM SysTick clock or
       for an Energy Profile counter clock. */

    /* In case if there is a need to get the timer clock frequency */
    uint32_t timerClkFreq = Cy_SysClk_ClkTimerGetFrequency();

bool Cy_SysClk_ClkTimerIsEnabled(void)

Reports the Enabled/Disabled status of the Timer.

note

This API is available for CAT1A devices.

Function Usage

    /* Scenario: Timer clock is no longer required and needs to be disabled.
                 All peripherals clocked using this source are disabled. */

    if (Cy_SysClk_ClkTimerIsEnabled())
    {
        Cy_SysClk_ClkTimerDisable();
    }

Returns

Boolean status of Timer: true - Enabled, false - Disabled.

void Cy_SysClk_ClkTimerDisable(void)

Disables the timer clock (clk_timer).

Function Usage

    /* Scenario: Timer clock is no longer required and needs to be disabled.
                 All peripherals clocked using this source are disabled. */

    if (Cy_SysClk_ClkTimerIsEnabled())
    {
        Cy_SysClk_ClkTimerDisable();
    }

uint32_t Cy_SysClk_ClkTimerGetFrequency(void)

Reports the frequency of the timer clock (clk_timer).

note

If the the timer clock is not enabled - a zero frequency is reported.

note

This API is available for CAT1A devices.

Function Usage

    /* Scenario: Timer clock needs to operate at HFCLK/32. */

    Cy_SysClk_ClkTimerSetSource(CY_SYSCLK_CLKTIMER_IN_HF0_DIV8);
    Cy_SysClk_ClkTimerSetDivider(3u); /* divider = value + 1 */
    Cy_SysClk_ClkTimerEnable();

    /* Use the Timer clock as a source for the alternative ARM SysTick clock or
       for an Energy Profile counter clock. */

    /* In case if there is a need to get the timer clock frequency */
    uint32_t timerClkFreq = Cy_SysClk_ClkTimerGetFrequency();