ARM Cortex M4 Power Management Tutorial.
-Aviral Mittal avimit att yahu datt cam.

1.1    ARM Cortex M4 Power Management

1.1.1   ARM Cortex M4 Sleep Modes

 

Cortex M4 Power management methodology supports 2 sleep modes

1.     Sleep

2.     Deep Sleep.

From M4F processor logic point of view, there is little difference between the above two sleep modes. However, it’s the way these sleep modes may be utilized and/or implemented, which may make a difference. For example, the first i.e. the ‘Sleep’ mode may be implemented such that it’s only the clocks to the processor and any related logic which are stopped and the ‘Deep Sleep’ may be implemented such that the clocks and power both can be switched off to the processor. Its to be noted that if a WIC is implemented, the corresponding functionality is not available in ‘Sleep’ mode for M4F processor. i.e. the WIC’s functionality and features are only available in ‘Deep-Sleep mode’ for M4F processor. Deep Sleep in turn can be implemented with and without state retention.

1.1.2   How to put M4F processor in Sleep/Deep Sleep mode.

The M4F processor has a register called SCR ‘Status control Register’. This register has a bit which selects between the ‘Sleep’/’DeepSleep’ modes. The subsystem software will write to this bit to indicate which sleep mode is required, when the processor next enters the sleep mode. The processor enters the sleep mode by executing an instruction called ‘WFE (wait for event) or WFI (wait for Interrupt)’. Soon after the processor has executed one of these instructions, the processor will assert a hardware signal (o/p signal w.r.t the processor itself) to let the outside world know that its OK to stop clock and/or power to the processor.

1.1.3   M4F State retention in deep-sleep.

The M4F processor may be implemented using what is called the SRPG methodology. SRPG stands for State Retention Power Gating. This allows the internal ‘state’ of the processor to be ‘retained’ during low power modes, such that when the power is re-applied to the processor, it starts working from where it was before entering the sleep mode. This is an alternative method which may be used as opposed to copying the ‘state’ of the processor in RAMs, and then re-copying the state from RAM to back to the processor on power up. Of course, this is very helpful in reducing the turn-on time for a processor from deep-sleep state, however since it is implemented using ‘state retention’ flops, it will consume power while in deep-sleep state. Usually, all the sequential elements inside the processor are ‘retained’, and these state retention flops are powered by a different power rail. The implementation SRPG will require specific control over how the reset is applied, as while coming out from the deep-sleep mode which uses state-retention, the processor reset cannot be applied.

The use of this methodology is also technology dependent, as the technology library must support ‘retention’ flops or something equivalent.

1.1.4   M4F WIC

The WIC or Wake-up Interrupt Controller is an optional component with the M4F processor. The WIC is used to help wake-up of the processor from deep-sleep power state, when a valid interrupt is received at its boundary. While going into the deep-sleep mode, some of the data e.g. interrupt makes & priorities are copied from the processor NVIC to the WIC automatically. There are also a couple of hand-shake signals which must be activated, to agree that the next deep-sleep mode the processor will enter, will be a WIC enabled one.

WIC is a configuration option and can be used/omitted as required.

WIC has no program-able registers. It has nothing to do with software, it is completely transparent to software.

In principle the WIC can be implemented without a clock as well, where it requests to the power controller to make its clock/power available, as a valid interrupt is asserted towards it. However, this is not usually done, as it requires change to the generated RTL, and the implementation has some limitations and after-effects which must be taken care of.

1.1.5   Summary of M4F Power Options

Based upon the capabilities and the option(s) available for the M4F processor, following is the summary of what power management modes may be implemented

1.     Light Sleep Mode: Where only clock(s) i.e. FCLK and HCLK to the processor are stopped.

2.     Deep Sleep Mode: Where the power domain containing the M4F processor may be switched off. This mode can be further categorized into two kinds

a.     Deep Sleep with State Retention: It will allow fast wake-up times at an expense of increased leakage. Following a wake-up the processor is in a state which is the same as the state it was in before going into Deep Sleep.

b.     Deep Sleep without State retention: It will allow most power savings at an expense of decreased wake-up times. Before going to Deep Sleep, the processor state will have to be stored in SRAMs. Following wake-up, the processor will have to be re-initialized from scratch, before it will come in a state in which it was before going into deep-Sleep.







Some Random Info

FCLK vs HCLK
FCLK is told by arm as 'free running clock'. This clock also powers the WIC. So in case you are using the WIC, the FCLK may not be turned off.  Since the WIC functionality is only available in Deep-Sleep for Cortex M4, this means that if you want to power gate the ARM processor to do max power savings during deep-sleep mode, then you have to make sure that the WIC is implemented out of the power domain you want to put the rest of the M4 in. WIC will have a separate FCLK branch going into it. During Deep-Sleep, the FCLK branch going into the WIC will be running, while the FCLK branch going into the rest of the M4F can be gated.
HCLK is the one which is gated when the M4F goes in Sleep mode. The processor will assert a signal called 'SLEEPING' which can be used by hardware to gate the HCLK. The 'SLEEPING' in turn is asserted following the WFI instruction execution by the processor.

Now if you are planning to use the SRPG, then when coming out of power collapsed state, you must NOT issue a reset. That means, control of the reset must be separated from control of the power domain collapse/wakeup function.
 

I was wondering what is the purpose of the signals
WICENREQ, WICENACK.

These signals are merely to agree the sleep 'mode'.
A handshake on the above signals will make sure that any sleep which happens following this handshaking,
will be 'wic' mode sleep, i.e. the WIC will be automatically loaded upon WFI instruction.

The WICENREQ is input signal to the M4F Integration level RTL,
WICENACK is output signal from M4F Integration level RTL.

It is possible to tie WICENREQ to '1' permanently to indicate that the all the sleeps are WIC mode sleep.
It is also possible to tie WICENREQ to '0', if WIC is not configured/implemented.