Clocks¶
-
group
group_hal_impl_clock
Implementation specific interface for using the Clock driver.
These items, while usable within the HAL, are not necessarily portable between devices. The diagram below shows how the clocks relate to each other. This is a superset of what is available. See the device specific Data Sheet for the exact set of clocks that are available on a specific device.
Code snippets
note
Error handling code has been intentionally left out of snippets to highlight API usage.
Snippet: System initialization
The following snippet shows the clock driver can be used to initialize all clocks in the system.
note
This example is device specific.
cy_rslt_trslt;
cyhal_clock_tclock_imo,clock_path,clock_pll,clock_hf;
cyhal_usb_dev_tusb_obj;
rslt=cyhal_clock_get(&clock_imo,&CYHAL_CLOCK_IMO);
//InitializethePathMux[1]tosourcefromtheIMO
rslt=cyhal_clock_get(&clock_path,&CYHAL_CLOCK_PATHMUX[1]);
rslt=cyhal_clock_init(&clock_path);
rslt=cyhal_clock_set_source(&clock_path,&clock_imo);
//InitializethePLL[0]tosourcefromthePathMux[0],andrunat48MHz
rslt=cyhal_clock_get(&clock_pll,&CYHAL_CLOCK_PLL[0]);
rslt=cyhal_clock_init(&clock_pll);
rslt=cyhal_clock_set_source(&clock_pll,&clock_path);
rslt=cyhal_clock_set_frequency(&clock_pll,48000000,NULL);
//InitializetheHF[3]clocktosourcefromthePLL[0],andrunat48MHz
rslt=cyhal_clock_get(&clock_hf,&CYHAL_CLOCK_HF[3]);
rslt=cyhal_clock_init(&clock_hf);
rslt=cyhal_clock_set_source(&clock_hf,&clock_pll);
rslt=cyhal_clock_set_divider(&clock_hf,1);
//InitializetheUSBwiththeclockpaththatwasjustsetup
rslt=cyhal_usb_dev_init(&usb_obj,USBDP,USBDM,&clock_hf);
Variables
-
const cyhal_resource_inst_t
CYHAL_CLOCK_IMO
¶ Internal Main Oscillator: This is a fixed-frequency clock that is commonly used as a general purpose source for clocks that do not require specific frequencies or very high accuracy.
This clock is stopped in the deep sleep and hibernate power modes.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_EXT
¶ External Clock: This is an off-chip clock (not an oscillator).
This clock is stopped in the deep sleep and hibernate power modes.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_ILO
¶ Internal Low Speed Oscillator: This is a low accuracy fixed-frequency clock in the kilohertz range that is available in sleep, deep sleep and hibernate power modes.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_LF
¶ Low Frequency Clock: This clock is the source for the multi-counter watchdog timers (MCWDT), and can also be a source for the RTC.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_PUMP
¶ Analog Pump Clock: This clock ensures precision analog performance in low voltage applications.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_BAK
¶ Backup Clock: This clock is available to the backup domain.
Typically useful if an external WCO is not available.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_ALT_SYS_TICK
¶ AltSysTickClk: Provides an optional external source for the CM4/CM0+ SysTick timers.
-
const cyhal_resource_inst_t
CYHAL_CLOCK_HF
[SRSS_NUM_HFROOT
]¶ High Frequency Clock: A high-frequency clock output driving specific peripherals.
-
const cyhal_resource_inst_t