Functions | |
cy_en_sysclk_status_t | Cy_SysClk_EcoConfigure (uint32_t freq, uint32_t cLoad, uint32_t esr, uint32_t driveLevel) |
Configures the external crystal oscillator (ECO) trim bits based on crystal characteristics. More... | |
cy_en_sysclk_status_t | Cy_SysClk_EcoEnable (uint32_t timeoutUs) |
Enables the external crystal oscillator (ECO). More... | |
uint32_t | Cy_SysClk_EcoGetFrequency (void) |
Returns the frequency of the external crystal oscillator (ECO). More... | |
__STATIC_INLINE bool | Cy_SysClk_EcoIsEnabled (void) |
Returns the ECO enable/disable state. More... | |
__STATIC_INLINE void | Cy_SysClk_EcoDisable (void) |
Disables the external crystal oscillator (ECO). More... | |
__STATIC_INLINE cy_en_sysclk_eco_stat_t | Cy_SysClk_EcoGetStatus (void) |
Reports the current status of the external crystal oscillator (ECO). More... | |
cy_en_sysclk_status_t Cy_SysClk_EcoConfigure | ( | uint32_t | freq, |
uint32_t | cLoad, | ||
uint32_t | esr, | ||
uint32_t | driveLevel | ||
) |
Configures the external crystal oscillator (ECO) trim bits based on crystal characteristics.
This function should be called only when the ECO is disabled.
freq | Operating frequency of the crystal in Hz. Valid range: 4000000...33330000 (4..33.33 MHz). |
cLoad | Crystal load capacitance in pF. Valid range: 1...100. |
esr | Effective series resistance of the crystal in ohms. Valid range: 1...1000. |
driveLevel | Crystal drive level in uW. Valid range: 1...2000. |
* freqKhz = freq / 1000 * maxAmpl = sqrt(drivelevel / 2 / esr) / 3.14 / freqKhz / cLoad * ampSect = INT(5 * 4 * 3.14^2 * freqKhz^2 * cLoad^2 * 4 * esr / 1000000000 / 1000000 / 4.5) * * As a result of the above calculations, maxAmpl must be >= 0.5, and the * number of amplifier sections must be <= 3, otherwise this function returns with * a parameter error. * * atrim = maxAmpl < 0.6 ? 0 : * maxAmpl < 0.7 ? 1 : * maxAmpl < 0.8 ? 2 : * maxAmpl < 0.9 ? 3 : * maxAmpl < 1.025 ? 4 : * maxAmpl < 1.150 ? 5 : * maxAmpl < 1.275 ? 6 : 7 * wdtrim = maxAmpl < 1.2 ? INT(5 * maxAmpl) - 2 : 3 * gtrim = ampSect > 1 ? ampSect : ampSect == 1 ? 0 : 1 * rtrim = freqKhz > 30000 ? 0 : * freqMHz > 24000 ? 1 : * freqMHz > 17000 ? 2 : 3 * * ftrim = rtrim * *
cy_en_sysclk_status_t Cy_SysClk_EcoEnable | ( | uint32_t | timeoutUs | ) |
Enables the external crystal oscillator (ECO).
This function should be called after Cy_SysClk_EcoConfigure.
timeoutUs | Amount of time in microseconds to wait for the ECO to stabilize. To avoid waiting for stabilization, set this parameter to 0. |
uint32_t Cy_SysClk_EcoGetFrequency | ( | void | ) |
Returns the frequency of the external crystal oscillator (ECO).
__STATIC_INLINE bool Cy_SysClk_EcoIsEnabled | ( | void | ) |
Returns the ECO enable/disable state.
__STATIC_INLINE void Cy_SysClk_EcoDisable | ( | void | ) |
Disables the external crystal oscillator (ECO).
This function should not be called if the ECO is sourcing other resources.
__STATIC_INLINE cy_en_sysclk_eco_stat_t Cy_SysClk_EcoGetStatus | ( | void | ) |
Reports the current status of the external crystal oscillator (ECO).