Application Note
60 of 80
002-26071 Rev. *B
2021-09-07
Clock configuration setup in TRAVEO™ T2G family CYT4D series MCUs
Configuring the internal clock
Code Listing 47
Cy_SysClk_SetEcoPrescaleManual() function
__STATIC_INLINE void Cy_SysClk_SetEcoPrescaleManual(uint16_t divInt, uint8_t divFract)
{
un_CLK_ECO_PRESCALE_t tempRegEcoPrescale;
tempRegEcoPrescale.u32Register = SRSS->unCLK_ECO_PRESCALE.u32Register;
tempRegEcoPrescale.stcField.u10ECO_INT_DIV = divInt;
tempRegEcoPrescale.stcField.u8ECO_FRAC_DIV = divFract;
SRSS->unCLK_ECO_PRESCALE.u32Register = tempRegEcoPrescale.u32Register;
return;
}
Code Listing 48
Cy_SysClk_EcoPrescaleEnable() function
cy_en_sysclk_status_t Cy_SysClk_EcoPrescaleEnable(uint32_t timeoutus)
{
// Send enable command
SRSS->unCLK_ECO_CONFIG.stcField.u1ECO_DIV_ENABLE = 1ul;
// Wait eco prescaler get enabled
while(CY_SYSCLK_ECO_PRESCALE_ENABLE != Cy_SysClk_GetEcoPrescaleStatus())
{
if(0ul == timeoutus)
{
return CY_SYSCLK_TIMEOUT;
}
Cy_SysLib_DelayUs(1u);
timeoutus--;
}
return CY_SYSCLK_SUCCESS;
}
Code Listing 49
Cy_SysClk_GetEcoPrescaleStatus() function
__STATIC_INLINE cy_en_eco_prescale_enable_t Cy_SysClk_GetEcoPrescaleStatus(void)
{
return (cy_en_eco_prescale_enable_t)(SRSS->unCLK_ECO_PRESCALE.stcField.u1ECO_DIV_ENABLED);
}
If you want to disable the ECO prescaler, set the wait time in the same way as the function above, and then call
the next function.
Code Listing 50
Cy_SysClk_EcoPrescaleDisable() function
cy_en_sysclk_status_t Cy_SysClk_EcoPrescaleDisable(uint32_t timeoutus)
{
// Send disable command
SRSS->unCLK_ECO_CONFIG.stcField.u1ECO_DIV_DISABLE = 1ul;
// Wait eco prescaler actually get disabled
while(CY_SYSCLK_ECO_PRESCALE_DISABLE != Cy_SysClk_GetEcoPrescaleStatus())
{
if(0ul == timeoutus)
{
return CY_SYSCLK_TIMEOUT;
}
Cy_SysLib_DelayUs(1u);
timeoutus--;
}
return CY_SYSCLK_SUCCESS;
}
(1) Configure the ECO prescaler.
(2) Enable the ECO prescaler.
(3) Wait until the ECO prescaler
is available.
Check the prescaler status.
(4) Disable the ECO prescaler.
(5) Wait until the ECO prescaler is
unavailable.