PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Functions
PDL API Reference » SysClk (System Clock) » Low-Frequency Clock

## General Description

## Functions
void | Cy_SysClk_ClkLfSetSource (cy_en_clklf_in_sources_t source)
| Sets the source for the low frequency clock(clkLf). More...
cy_en_clklf_in_sources_t | Cy_SysClk_ClkLfGetSource (void)
| Reports the source for the low frequency clock (clkLf). More...
uint32_t | Cy_SysClk_ClkLfGetFrequency (void)
| Reports the frequency of the clklf. More...
uint32_t | Cy_SysClk_ClkLfCsvGetRefFrequency (cy_en_clklf_csv_ref_clk_t refClk)
| Get the clklf csv reference clock frequency. More...
cy_en_sysclk_status_t | Cy_SysClk_ClkLfCsvManualConfigure (cy_en_clklf_csv_ref_clk_t refClk, const cy_stc_clklf_csv_manual_config_t *csvConfig)
| Manually configures the clklf csv based on user inputs. More...
cy_en_sysclk_status_t | Cy_SysClk_ClkLfCsvConfigure (cy_en_clklf_csv_ref_clk_t refClk, uint32_t accuracy)
| Configures clklf csv. More...
void | Cy_SysClk_ClkLfCsvEnable (void)
| Enables the csv for the clklf. More...
void | Cy_SysClk_ClkLfCsvDisable (void)
| Disables the csv for the clklf. More...
bool | Cy_SysClk_IsClkLfCsvEnabled (void)
| Returns the enabled status of csv for the clklf. More...

## Function Documentation

## ◆ Cy_SysClk_ClkLfSetSource()

void Cy_SysClk_ClkLfSetSource | ( | cy_en_clklf_in_sources_t | source | ) |

Sets the source for the low frequency clock(clkLf).

Parameters

  source | cy_en_clklf_in_sources_t

Note
  The watchdog timer (WDT) must be unlocked before calling this function.
  It takes four cycles of the originally selected clock to switch away from it. Do not disable the original clock during this time.

Function Usage
  /* Scenario: LFCLK source needs to be updated to the ILO. */
  if(CY_SYSCLK_CLKLF_IN_ILO != Cy_SysClk_ClkLfGetSource())
  {
  Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO);
  }
  CY_SYSCLK_CLKLF_IN_ILO
  @ CY_SYSCLK_CLKLF_IN_ILO
  clkLf is sourced by the internal low speed oscillator (ILO)
  Definition: cy_sysclk.h:3998
  Cy_SysClk_ClkLfSetSource
  void Cy_SysClk_ClkLfSetSource(cy_en_clklf_in_sources_t source)
  Sets the source for the low frequency clock(clkLf).
  Definition: cy_sysclk_v2.c:2378
  Cy_SysClk_ClkLfGetSource
  cy_en_clklf_in_sources_t Cy_SysClk_ClkLfGetSource(void)
  Reports the source for the low frequency clock (clkLf).
  Definition: cy_sysclk_v2.c:2385

## ◆ Cy_SysClk_ClkLfGetSource()

cy_en_clklf_in_sources_t Cy_SysClk_ClkLfGetSource | ( | void |  | ) |

Reports the source for the low frequency clock (clkLf).

Returns
  cy_en_clklf_in_sources_t

Function Usage
  /* Scenario: LFCLK source needs to be updated to the ILO. */
  if(CY_SYSCLK_CLKLF_IN_ILO != Cy_SysClk_ClkLfGetSource())
  {
  Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_ILO);
  }

## ◆ Cy_SysClk_ClkLfGetFrequency()

uint32_t Cy_SysClk_ClkLfGetFrequency | ( | void |  | ) |

Reports the frequency of the clklf.

Returns
  The frequency, in Hz.

Note
  This API is Secure Aware. On devices with ARM TrustZone enabled, it is safe to call on a Secure hardware resource from a Non-Secure CPU state. The involved PPC region is PROT_PERI0_SRSS_MAIN. See Secure Aware SysCLK for further details.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();
  Cy_SysClk_ClkLfCsvConfigure
  cy_en_sysclk_status_t Cy_SysClk_ClkLfCsvConfigure(cy_en_clklf_csv_ref_clk_t refClk, uint32_t accuracy)
  Configures clklf csv.
  Definition: cy_sysclk_v2.c:2568
  Cy_SysClk_ClkLfCsvEnable
  void Cy_SysClk_ClkLfCsvEnable(void)
  Enables the csv for the clklf.
  Definition: cy_sysclk_v2.c:2602
  Cy_SysClk_ClkLfCsvManualConfigure
  cy_en_sysclk_status_t Cy_SysClk_ClkLfCsvManualConfigure(cy_en_clklf_csv_ref_clk_t refClk, const cy_stc_clklf_csv_manual_config_t *csvConfig)
  Manually configures the clklf csv based on user inputs.
  Definition: cy_sysclk_v2.c:2532
  Cy_SysClk_IsClkLfCsvEnabled
  bool Cy_SysClk_IsClkLfCsvEnabled(void)
  Returns the enabled status of csv for the clklf.
  Definition: cy_sysclk_v2.c:2614
  Cy_SysClk_ClkLfCsvDisable
  void Cy_SysClk_ClkLfCsvDisable(void)
  Disables the csv for the clklf.
  Definition: cy_sysclk_v2.c:2608
  cy_stc_clklf_csv_manual_config_t
  Manual CSV configuration struct.
  Definition: cy_sysclk.h:4028

## ◆ Cy_SysClk_ClkLfCsvGetRefFrequency()

uint32_t Cy_SysClk_ClkLfCsvGetRefFrequency | ( | cy_en_clklf_csv_ref_clk_t | refClk | ) |

Get the clklf csv reference clock frequency.

Parameters

  refClk | Reference clock source.

Returns
  cy_en_sysclk_status_t.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();

## ◆ Cy_SysClk_ClkLfCsvManualConfigure()

cy_en_sysclk_status_t Cy_SysClk_ClkLfCsvManualConfigure | ( | cy_en_clklf_csv_ref_clk_t | refClk,
|  | const cy_stc_clklf_csv_manual_config_t * | csvConfig
| ) |  |

Manually configures the clklf csv based on user inputs.

Parameters

  refClk | Reference clock for csv operation.
  csvConfig | Selects the csv configuration required.

Returns
  The frequency in Hz.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();

## ◆ Cy_SysClk_ClkLfCsvConfigure()

cy_en_sysclk_status_t Cy_SysClk_ClkLfCsvConfigure | ( | cy_en_clklf_csv_ref_clk_t | refClk,
|  | uint32_t | accuracy
| ) |  |

Configures clklf csv.

The configuration formula used is: Lower_limit = Target - Required accuracy/2 Upper_limit = Target + Required accuracy/2 Period = Target / (Reference frequency / Monitor frequency) Start_time = (Period +3) * (Reference frequency / Monitor frequency) - Upper_limit

Parameters

  refClk | Selects the reference clock for csv operation.
  accuracy | Required accuracy.

Returns
  cy_en_sysclk_status_t.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();

## ◆ Cy_SysClk_ClkLfCsvEnable()

void Cy_SysClk_ClkLfCsvEnable | ( | void |  | ) |

Enables the csv for the clklf.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();

## ◆ Cy_SysClk_ClkLfCsvDisable()

void Cy_SysClk_ClkLfCsvDisable | ( | void |  | ) |

Disables the csv for the clklf.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();

## ◆ Cy_SysClk_IsClkLfCsvEnabled()

bool Cy_SysClk_IsClkLfCsvEnabled | ( | void |  | ) |

Returns the enabled status of csv for the clklf.

Returns
  cy_en_sysclk_status_t.

Function Usage
  /* Scenario: Generate clklf csv using the below lfConfig, csvConfig configuration.*/
  bool manualConfig = 1UL;
  /* Configure faults using sysFault API */
  /* CSV Config. */
  if (manualConfig)
  {
  cy_stc_clklf_csv_manual_config_t csvConfig = {198, 195, 205, 208}; // Start time, lower limit, upper limit, period.
  Cy_SysClk_ClkLfCsvManualConfigure(4 , &csvConfig); // ref clock.
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  else
  {
  // Auto config
  Cy_SysClk_ClkLfCsvConfigure(4, 1); // Accuracy 1%
  Cy_SysClk_ClkLfCsvEnable(); // Enable clklf csv
  }
  if(Cy_SysClk_IsClkLfCsvEnabled())
  Cy_SysClk_ClkLfCsvDisable();