ensure MCU low power consumption, these five points are very important
Low power consumption is a very important indicator of MCU. For example, some wearable devices carry limited power. If the power consumption of the whole circuit is particularly large, there will often be insufficient power, which will affect the user experience. At ordinary times, when we are making products, the basic functions are very simple to realize, but as long as the problem of low power consumption is involved, it is more difficult, such as some MCU that can be as low as micro-ampere level, and the low power consumption designed by ourselves is measured by milliampere level, and the current can be hundreds to thousands of times higher than the standard. Don't be afraid in this situation, as long as you are serious, you will win. Let's analyze the reasons for this carefully.
Article 1: Cut off the peripheral lifeline-Turn off the peripheral clock
, the most intuitive aspect, which engineers pay more attention to, is to turn off the peripheral clock of MCU. For most MCU appearing on the market now, its peripheral module corresponds to a clock switch. Only need to turn on the clock of this peripheral, you can normally use this peripheral, of course, this peripheral will also generate corresponding power consumption; On the contrary, if you want this peripheral not to generate power consumption, just turn off its clock.
Article 2: Slow down the pace of work-Do not double the clock
In addition to the power consumption of peripheral modules, there is also a large power consumption that needs to be noted. These are PLL and FLL modules. PLL and FLL are mainly used to multiply the original clock signal, thus improving the overall clock of the system. Correspondingly, its power consumption will also be increased. Therefore, before entering low power consumption, it is necessary to switch between the mode and bypass the PLL and FLL modules, thus reducing the power consumption of the MCU as much as possible, and then switching the clock back after the MCU wakes up.
Article 3: Containment of Trickle-Pay Attention to the Level Status of I/O Port
you are naive to think that simply turning off the peripheral clock can ensure that the peripheral will no longer consume electricity. If the IO port is not handled properly, it will steal power consumption secretly, but you don't know it. The specific reason is that general IO will have up-down resistors inside or outside. For example, as shown in the following figure, if an IO port has a 10kΩ up-down resistor, pull the pin to 3.3V. However, when MCU enters low power consumption mode, the IO port is set to output low level. According to Ohm's law, this pin will consume 3.3V/10K = 0.33ma of current, if there are four or five such IO ports, then a few will be posted, which is too bad. Therefore, before entering low power consumption, please check the status of IO ports one by one:
If the IO port is pulled, set it to high-level output or high-impedance input;
If the IO port has a pull-down, set it to low-level output or high-impedance input;
In a word, don't waste good current on the function of generating heat. We don't need this temperature to warm our hands.
: Good-neighborliness, Friendship and Cooperation-Pay Attention to the Coordination of I/O and Peripheral IC
the factor of current consumption by the upper and lower resistors of IO port is relatively obvious, let's talk about an insignificant factor below: current consumption when IO port is connected to an external IC. If an IO port has its own pull-up, and the IC pin connected to IO has its own pull-down, then no matter what level output the pin is at, a certain current consumption will inevitably occur. Therefore, whenever you encounter this kind of situation, you need to read the manual of the peripheral IC first, determine the status of this pin, and know fairly well. Then, before controlling MCU sleep, set the pull-up mode and input and output state of IO port of MCU, and ensure that no trace of current is consumed by it.
Article 5: Disconnect the debugger and don't be fooled by illusion.
. The detected current consumption is very large, but the actual result is that I am worried about it. What is the reason? It is because MCU is still connected to debugger when testing power consumption! At this time, most of the current will be taken away by the debugger, making the engineer extremely depressed for no reason. Therefore, when measuring low power consumption, you must not connect the debugger, let alone measure the current while debugging.