PSoC 6 Peripheral Driver Library

General Description

Functions

__STATIC_INLINE void Cy_SysClk_PiloEnable (void)
 Enables the PILO. More...
 
__STATIC_INLINE bool Cy_SysClk_PiloIsEnabled (void)
 Reports the Enabled/Disabled status of the PILO. More...
 
__STATIC_INLINE void Cy_SysClk_PiloDisable (void)
 Disables the PILO. More...
 
__STATIC_INLINE void Cy_SysClk_PiloSetTrim (uint32_t trimVal)
 Sets the PILO trim bits, which adjusts the PILO frequency. More...
 
__STATIC_INLINE uint32_t Cy_SysClk_PiloGetTrim (void)
 Reports the current PILO trim bits value. More...
 

Function Documentation

◆ Cy_SysClk_PiloEnable()

__STATIC_INLINE void Cy_SysClk_PiloEnable ( void  )

Enables the PILO.

Note
This function blocks for 1 millisecond between enabling the PILO and releasing the PILO reset.
Function Usage
/* Scenario: PILO needs to source the LFCLK. All peripherals clocked by
the LFCLK are disabled and the Watchdog timer (WDT) is unlocked. */
/* Enable the PILO. Note: Blocks for 1 millisecond. */
/* Set the LFCLK source to the PILO */

◆ Cy_SysClk_PiloIsEnabled()

__STATIC_INLINE bool Cy_SysClk_PiloIsEnabled ( void  )

Reports the Enabled/Disabled status of the PILO.

Returns
Boolean status of PILO: true - Enabled, false - Disabled.
Function Usage
/* Scenario: LFCLK needs to be sourced by the ILO instead of the PILO. All
peripherals clocked by the LFCLK are disabled and the Watchdog
timer (WDT) is unlocked. */
{
/* Disable the PILO */
/* Enable the ILO */
/* Set the LFCLK source to the ILO */
}

◆ Cy_SysClk_PiloDisable()

__STATIC_INLINE void Cy_SysClk_PiloDisable ( void  )

Disables the PILO.

Function Usage
/* Scenario: LFCLK needs to be sourced by the ILO instead of the PILO. All
peripherals clocked by the LFCLK are disabled and the Watchdog
timer (WDT) is unlocked. */
{
/* Disable the PILO */
/* Enable the ILO */
/* Set the LFCLK source to the ILO */
}

◆ Cy_SysClk_PiloSetTrim()

__STATIC_INLINE void Cy_SysClk_PiloSetTrim ( uint32_t  trimVal)

Sets the PILO trim bits, which adjusts the PILO frequency.

This is typically done after measuring the PILO frequency; see Cy_SysClk_StartClkMeasurementCounters().

Function Usage
/* Scenario: PILO needs to be trimmed to +/- 2% of nominal 32.768 kHz using
the ECO as the source. */
#define ECO_FREQ 24000000UL /* 24 MHz ECO */
#define PILO_NOMINAL 32768UL /* 32.768 kHz PILO */
#define PILO_ACCURACY 655UL /* PILO_NOMINAL * 0.02 */
bool trimStatus = false;
while(!trimStatus)
{
/* Start the PILO clock measurement using the IMO */
(void)Cy_SysClk_StartClkMeasurementCounters(CY_SYSCLK_MEAS_CLK_PILO, /* Counter 1 clock = PILO */
0x3FFUL, /* Counter 1 init value = 1024 */
CY_SYSCLK_MEAS_CLK_ECO); /* Counter 2 clock = ECO */
/* Wait for counter 1 to reach 0 */
/* Measure clock 1 with the ECO clock cycles (counter 2) */
uint32_t measuredFreq = Cy_SysClk_ClkMeasurementCountersGetFreq(false, ECO_FREQ);
/* Increment/decrement the trim depending on the returned result */
if ((PILO_NOMINAL + PILO_ACCURACY) < measuredFreq)
{
}
else if (measuredFreq < (PILO_NOMINAL - PILO_ACCURACY))
{
}
else
{
/* Trimmed within limits */
trimStatus = true;
}
}

◆ Cy_SysClk_PiloGetTrim()

__STATIC_INLINE uint32_t Cy_SysClk_PiloGetTrim ( void  )

Reports the current PILO trim bits value.

Function Usage
/* Scenario: PILO needs to be trimmed to +/- 2% of nominal 32.768 kHz using
the ECO as the source. */
#define ECO_FREQ 24000000UL /* 24 MHz ECO */
#define PILO_NOMINAL 32768UL /* 32.768 kHz PILO */
#define PILO_ACCURACY 655UL /* PILO_NOMINAL * 0.02 */
bool trimStatus = false;
while(!trimStatus)
{
/* Start the PILO clock measurement using the IMO */
(void)Cy_SysClk_StartClkMeasurementCounters(CY_SYSCLK_MEAS_CLK_PILO, /* Counter 1 clock = PILO */
0x3FFUL, /* Counter 1 init value = 1024 */
CY_SYSCLK_MEAS_CLK_ECO); /* Counter 2 clock = ECO */
/* Wait for counter 1 to reach 0 */
/* Measure clock 1 with the ECO clock cycles (counter 2) */
uint32_t measuredFreq = Cy_SysClk_ClkMeasurementCountersGetFreq(false, ECO_FREQ);
/* Increment/decrement the trim depending on the returned result */
if ((PILO_NOMINAL + PILO_ACCURACY) < measuredFreq)
{
}
else if (measuredFreq < (PILO_NOMINAL - PILO_ACCURACY))
{
}
else
{
/* Trimmed within limits */
trimStatus = true;
}
}