PSoC 4 Peripheral Driver Library - Alpha

General Description

Functions

__STATIC_INLINE void Cy_SysClk_IloEnable (void)
 Enables the ILO. More...
 
__STATIC_INLINE bool Cy_SysClk_IloIsEnabled (void)
 Returns the ILO enable/disable state. More...
 
__STATIC_INLINE cy_en_sysclk_status_t Cy_SysClk_IloDisable (void)
 Disables the ILO. More...
 
void Cy_SysClk_IloStartMeasurement (void)
 Starts the ILO accuracy measurement. More...
 
void Cy_SysClk_IloStopMeasurement (void)
 Stops the ILO accuracy measurement. More...
 
cy_en_sysclk_status_t Cy_SysClk_IloCompensate (uint32_t desiredDelay, uint32_t *compensatedCycles)
 Measures the current ILO accuracy. More...
 

Function Documentation

◆ Cy_SysClk_IloEnable()

__STATIC_INLINE void Cy_SysClk_IloEnable ( void  )

Enables the ILO.

Function Usage
/* Scenario: watchdog counter needs to be sourced by the ILO instead of the WCO. */
/* Disable the ILO */
/* Now switch the watchdog counter clocking to ILO */
/* Disable the WCO */

◆ Cy_SysClk_IloIsEnabled()

__STATIC_INLINE bool Cy_SysClk_IloIsEnabled ( void  )

Returns the ILO enable/disable state.

Function Usage
/* Scenario: watchdog counter needs to be sourced by the ILO instead of the WCO. */
/* Disable the ILO */
/* Now switch the watchdog counter clocking to ILO */
/* Disable the WCO */

◆ Cy_SysClk_IloDisable()

__STATIC_INLINE cy_en_sysclk_status_t Cy_SysClk_IloDisable ( void  )

Disables the ILO.

ILO can't be disabled if WDT is enabled.

Returns
Error / status code:
CY_SYSCLK_SUCCESS - ILO successfully disabled
CY_SYSCLK_INVALID_STATE - Cannot disable the ILO if the WDT is enabled.
Note
Do not call this function if the WDT is enabled, because the WDT is clocked by the ILO.
Function Usage
/* Scenario: ILO is not needed and should be shut down to reduce power consumption. */
{
Cy_SysClk_IloDisable(); /* Disable the ILO */
}

◆ Cy_SysClk_IloStartMeasurement()

void Cy_SysClk_IloStartMeasurement ( void  )

Starts the ILO accuracy measurement.

This function is non-blocking and needs to be called before using the CySysClkIloTrim() and CySysClkIloCompensate() functions.

This function configures measurement counters to be sourced by SysClk (Counter 1) and ILO (Counter 2).

Note
SysClk should be sourced by IMO. Otherwise CySysClkIloCompensate() function can give incorrect results.

◆ Cy_SysClk_IloStopMeasurement()

void Cy_SysClk_IloStopMeasurement ( void  )

Stops the ILO accuracy measurement.

Calling this function immediately stops the the ILO frequency measurement. This function should be called before placing the device to deepsleep, if Cy_SysClk_IloStartMeasurement() API was called before.

◆ Cy_SysClk_IloCompensate()

cy_en_sysclk_status_t Cy_SysClk_IloCompensate ( uint32_t  desiredDelay,
uint32_t *  compensatedCycles 
)

Measures the current ILO accuracy.

Basing on the measured frequency the required number of ILO cycles for a given delay (in microseconds) is obtained. The desired delay that needs to be compensated is passed through the desiredDelay parameter. The compensated cycle count is returned through the compesatedCycles pointer. The compensated ILO cycles can then be used to define the WDT period value, effectively compensating for the ILO inaccuracy and allowing a more accurate WDT interrupt generation.

Cy_SysClk_IloStartMeasurement() function should be called prior to calling this function.

Note
SysClk should be sourced by IMO. Otherwise Cy_SysClk_IloCompensate() function can give incorrect results.
If the System clock frequency is changed in runtime, the SystemCoreClockUpdate() should be called before calling a next Cy_SysClk_IloCompensate().
For a correct WDT or DeepSleep Timers functioning with ILO compensating the Cy_SysClk_IloCompensate() should be called before WDT or DeepSleep Timers enabling.
Warning
Do not enter deep sleep mode until the function returns CY_SYSCLK_SUCCESS.
Parameters
desiredDelayRequired delay in microseconds. Valid range is 100 ... 2 000 000 us.
*compensatedCyclesThe pointer to the variable in which the required number of ILO cycles for the given delay will be returned.

The value returned in *compensatedCycles pointer is not valid until the function returns CY_SYSCLK_SUCCESS.

Returns
The status cy_en_sysclk_status_t
  • CY_SYSCLK_SUCCESS - The compensation process is complete and the compensated cycles value is returned in the compensatedCycles pointer.
  • CY_SYSCLK_BAD_PARAM - One or more invalid parameters
  • CY_SYSCLK_STARTED - Indicates measurement is in progress. It is strongly recommended to do not make pauses between API calling. The function should be called repeatedly until the API returns CY_SYSCLK_SUCCESS.
  • CY_SYSCLK_INVALID_STATE - Indicates that measurement not started. The user should call Cy_SysClk_IloStartMeasurement() API before calling this function.