Application Note
9 of 38
001-86233 Rev. *I
2021-11-04
PSoC™ 4 MCU low
-power modes and power reduction techniques
Low-power mode details
CySysPmGetResetReason()
API function to determine if the reset was a wakeup from hibernate, or from
some other reset condition. The following code shows how to define a non-initialized variable, and initialize it if
the reset was not due to a hibernate wakeup.
/* Define non-initialized global variable */
int32 CY_NOINIT testVarNoInit;
/* Inside of main() */
/* Initialize variable when
PSoC™
is not reset from hibernation wakeup */
if
( CySysPmGetResetReason() != CY_PM_RESET_REASON_WAKEUP_HIB )
{
testVarNoInit = 0;
}
3.3.2
Hibernate mode transitions
Enter Hibernate mode using the
CySysPmHibernate()
API function. This function configures the device for
Hibernate mode. No other function calls are necessary because all components including clocks are powered
down and will be reinitialized when exiting hibernate mode with a reset. The only exception is that the low-
power comparator may remain active to cause a wakeup from hibernate mode.
Exit from Hibernate mode occurs when a pin or low-power comparator interrupt is triggered. Upon exiting
Hibernate mode,
PSoC™ MCU
resets. After the return to active mode from a reset, you can call
CySysPmGetResetReason()
to detect the hibernate wakeup reset. The specific pin or comparator
interrupt can then be detected using the component APIs, as those register states are retained.
Although not required, you have the option to lock the state of all I/O cells (GPIOs) by calling
CySysPmfreezeIo()
before entering Hibernate mode. The
CySysPmUnfreezeIo()
function should be
called after a wakeup from hibernate mode before the pins can again change state. Using these functions
prevents unexpected GPIO transitions during and after reset.
3.3.3
Hibernate mode use cases
Hibernate mode should be used when periodic wakeup is not required, and the device must use less than 1 µA
current. It may also be useful for a wakeup on an analog or digital signal transition, while requiring minimal
current.
Note that hibernate mode can be used effectively if your code is organized as a state machine, and the CPU can
start executing the code from the previously known state before wakeup once the device wakes up from
hibernate mode. You must use the
CY_NOINIT
attribute in the definition of the state variables to make sure
that the state variables are not reinitialized after wakeup from hibernate mode. You can call
CySysPmGetResetReason()
to detect the hibernate wakeup reset, as mentioned in the previous section.
3.4
Stop mode with PSoC™ Creator
Stop mode offers the lowest possible current consumption without removing power from the
PSoC™
4 MCU
supply pins. All peripherals are disabled, and the SRAM and register states are
not
retained. The device pins
may be “frozen” and retai
n their drive modes and logical states. A dedicated wakeup pin, P0[7], is available to