LDO

group group_syspm_functions_ldo

Functions

cy_en_syspm_status_t Cy_SysPm_LdoSetVoltage(cy_en_syspm_ldo_voltage_t voltage)

Set output voltage on the core LDO regulator.

When changing from a higher voltage to a lower voltage as when the device enters system ULP mode, ensure that:

  • The device maximum operating frequency for all the Clk_HF paths, peripheral, and slow clock are under the ULP Limitations.

  • The total current consumption is under the ULP Limitations.

  • The appropriate wait states values are set for the flash using The Cy_SysLib_SetWaitStates() function as explained below.

Setting wait states values for flash

The flash access time when the core voltage is 0.9 V (nominal) is longer than at 1.1 V (nominal). Therefore, the number of the wait states must be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate wait state values for flash.

To change from a higher voltage to a lower voltage 0.9 V (nominal), call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.

To change from a lower voltage to a higher voltage 1.1 V (nominal), calling the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the wait states is optional, but can be done to improve performance. The clock frequency may now be increased up to LP Limitations.

note

1. The output is set to 0.9 V (nominal) - the system is in ULP mode and flash works for read-only operation.

note

2. The output is set to 1.1 V (nominal) - the system is in LP mode and flash works for read and write operations.

note

3. The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on conditions including the load current.

For more detail, refer to the

Switching the System into Ultra Low Power and Switching the System into Low Power sections. Refer to the SysLib (System Library) driver for more detail about setting the wait states.

Return

  • CY_SYSPM_SUCCESS - The voltage is set.

  • CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set because the protection context value is higher than zero (PC > 0) or the device revision does not support modifying registers via syscall.

  • CY_SYSPM_CANCELED - Operation was canceled. Call the function again until the function returns CY_SYSPM_SUCCESS. See cy_en_syspm_status_t. For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

Parameters

cy_en_syspm_status_t Cy_SysPm_LdoSetMode(cy_en_syspm_ldo_mode_t mode)

Configures the core LDO regulator operating mode to one of three modes.

Disabled - turns off the LDO regulator and should be selected only after the Buck regulator is operating. Normal mode configures the LDO for operation at the maximum output current limit. Minimal current mode optimizes the LDO at a reduced output current limit. Specific device current limits can be found in the device datasheet.

Return

  • CY_SYSPM_SUCCESS - Requested regulator current mode was set

  • CY_SYSPM_CANCELED - The power circuits were not ready to enter into minimum current mode. You should try to call the function again

  • CY_SYSPM_TIMEOUT - Timeout occurred because of active reference was not ready to enter into the normal regulator current mode

  • CY_SYSPM_FAIL - incorrect mode value was passed For the PSoC 64 devices there are possible situations when function returns the PRA error status code. This is because for PSoC 64 devices the function uses the PRA driver to change the protected registers. Refer to cy_en_pra_status_t for more details.

Side Effects

For PSoC 64 series devices CY_SYSPM_LDO_MODE_DISABLED mode is not supported. Use Cy_SysPm_BuckEnable() instead.

Parameters

cy_en_syspm_ldo_mode_t Cy_SysPm_LdoGetMode(void)

Returns the current core LDO regulator operating mode.

Return

The LDO regulator operating mode. See cy_en_syspm_ldo_mode_t mode

cy_en_syspm_ldo_voltage_t Cy_SysPm_LdoGetVoltage(void)

Gets the current output voltage value of the core LDO regulator.

note

The actual device Vccd voltage can be different from the nominal voltage because the actual voltage value depends on conditions including the load current.

note

CAT1B devices, function always returns 0.

Return

The nominal output voltage of the LDO. See cy_en_syspm_ldo_voltage_t.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }

bool Cy_SysPm_LdoIsEnabled(void)

Reads the current status of the core LDO regulator.

note

For CAT1B devices IP, function always returns 0.

Return

  • True means the LDO is enabled.

  • False means it is disabled.

Function Usage

    /* Scenario: There is a need to increase the core supply voltage  */
    cy_en_syspm_status_t retVal;

    /* Need to parse the error value for Cy_SysPm_LdoSetVoltage and 
    *  Cy_SysPm_BuckSetVoltage1 functions. The functions can return two types
    *  of error:
    *  CY_SYSPM_INVALID_STATE - The operation cannot be executed, because  
    *  the application runs in protection context higher than zero (PC > 0),  
    *  or device revision does not support modifying registers via syscall.
    *  CY_SYSPM_CANCELED - The operation was canceled, and you need to 
    *  call the function again to successfully finish the operation. 
    */ 

    if (Cy_SysPm_LdoIsEnabled())
    {
        if (CY_SYSPM_LDO_VOLTAGE_ULP == Cy_SysPm_LdoGetVoltage())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }
            
            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the core frequency in MHz
             */
        }
    }
    else if (Cy_SysPm_BuckIsEnabled())
    {
        if (CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP == Cy_SysPm_BuckGetVoltage1())
        {
            uint32_t triesToSetVoltage = 5u;
            
            do
            {
                /* Call the function until the operation is finished */
                retVal = Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V);
                --triesToSetVoltage;
            } while ((CY_SYSPM_SUCCESS != retVal) && (triesToSetVoltage != 0));
            
            if (0U == triesToSetVoltage)
            {
                /* The operation was not performed */
            }

            /* Call Cy_SysLib_SetWaitStates(false, clkMHz);
             * where clkMHz is the CPU frequency in MHz
             */
        }
    }