5 Tips to Ensure Low Power Consumption of MCU
Tags: mcu, consumption, microcontroller
Published: 2022-11-29 07:23:15

Low power consumption is a very important indicator of [MCU](https://www.embedic.com/product/category-mcu/). For example, some wearable devices carry limited power. If the power consumed by the entire circuit is particularly large, there will often be insufficient power, which will affect user experience.

Usually when we are making products, the realization of basic functions is very simple, but as long as the problem of low power consumption is involved, it is more difficult. It is in the milliamp level, and the current can be hundreds to thousands of times higher than the standard. Don't be afraid when you encounter this situation, as long as you are serious, you will win. Let's take a closer look at the reasons for this below.

## Tip 1: Cut off the lifeline of the peripherals - turn off the clocks of the peripherals

Let me talk about the most intuitive aspect first, which is also the aspect that engineers pay more attention to, which is to turn off the peripheral clock of the MCU. For most of the MCUs that appear on the market today, the peripheral modules correspond to a clock switch. You only need to turn on the clock of this peripheral, and you can use this peripheral normally. Of course, this peripheral will also generate corresponding power consumption; conversely, if you want this peripheral to not generate power consumption, just turn it off clock.

## Tip 2: Slow down the pace of work - don't multiply the clock frequency

In addition to the power consumption of peripheral modules, there is another big power consumer that needs attention, which is the PLL and FLL modules. PLL and FLL are mainly used to multiply the frequency of the original clock signal, thereby improving the overall clock of the system, and correspondingly, its power consumption will also be raised. Therefore, before entering low power consumption, it is necessary to switch the mode, bypassing the PLL and FLL modules, so as to reduce the power consumption of the MCU as much as possible, and then switch the clock back after the MCU wakes up.


## Tip 3: Contain the trickle - pay attention to the level status of the I/O port

If you think that just turning off the peripheral clock can ensure that the peripheral does not consume power, then you are too naive. If the IO port is not properly handled, it will secretly steal power consumption, but you don't know it. The specific reason is this. Generally, there will be pull-up and pull-up resistors inside or outside the IO. For example, as shown in the figure below, if an IO port has a 10K&Omega; pull-up resistor, pull the pin to 3.3V, However, when the MCU enters low power consumption mode, this IO port is set to output low level. 

According to Ohm's law, this pin will consume 3.3V/10K=0.33mA current. If there are four or five such IO port, then a few mA are pasted in, which is a pity. So before entering low power consumption, please check the status of the IO ports one by one:
If this IO port has a pull-up, please set it as a high-level output or a high-impedance state input;
If this IO port has a pull-down, please set it as a low-level output or a high-impedance state input;

In a word, don't waste the good current on the function of generating heat. We don't rely on this temperature to warm our hands.

## Tip 4: Good-neighborly and friendly cooperation—pay attention to the overall planning of I/O and peripheral ICs.

The current consumption factor of the pull-up and pull-down resistors of the IO port is relatively obvious. Next, let’s talk about a non-obvious factor: the current consumption when the IO port is connected to an external IC. If an IO port has its own pull-up, and the IC pin connected to the IO has its own pull-down, then no matter what level the pin is outputting, a certain amount of current consumption will inevitably occur. So whenever you encounter this kind of situation, you first need to read the manual of the peripheral IC, determine the status of this pin, and be aware of it; then, before controlling the sleep of the MCU, set the pull-down mode and In the input and output state, it is necessary to ensure that no trace of current is consumed by it.

## Tip 5: Disconnect the debugger, don't be fooled by illusions.


There is another kind that is rather peculiar.The detected current consumption is very large, but the actual result is that I am unfounded. What is the reason? It is because the MCU is still connected to the debugger when testing the power consumption! At this time, most of the current will be taken away by the debugger, which makes the engineer feel extremely depressed for no reason. Therefore, when measuring low power consumption, you must not connect the debugger, let alone measure the current while debugging.

## Summary

The low power consumption design of the [MCU](https://www.embedic.com/product/category-mcu/) is a meticulous task. It is necessary to develop a good habit and re-verify whether the low power consumption meets the requirements every time a function is added, so that the factors that consume power can be eliminated anytime and anywhere. 

If all the functions are designed before considering the issue of low power consumption, if you are not careful, you may have to change the structure of the program-even so, the power consumption may not be completely reduced.