Embedded software development tools simplify STM8-based smart device development

Embedded software development tools simplify STM8-based smart device development

Reducing power consumption has always been a major focus in the microcontroller (MCU) market. Ultra-low power MCUs can now significantly reduce active and deep sleep power consumption. The effect of this change is obvious, as it greatly improves battery life in everyday embedded applications, as well as the possibility of using energy harvesting in the future. However, in order to properly leverage the current consumption specifications of existing MCUs, embedded development engineers must consider many factors. Embedded development engineers can take advantage of the autonomous operation of peripheral devices in modern MCUs to achieve the low power consumption required by the specification sheet through operations closer to '0' MIPS.

For modern MCUs and wireless MCUs (WMCUs) used in power-sensitive Internet of Things (IoT) applications, the power consumption when executing code has dropped significantly, even reaching below 40μA/MHz. With these low-power specs, you might be wondering why sleep mode is needed. Why not just run the clock at 500kHz to achieve 20μA current consumption and let your application run on battery for up to 10 years? It's not that simple.

Sleep power consumption has improved significantly over the past few years. We can now see power consumption below 2μA in deep sleep mode, and even below 50nA in some sleep modes. You might think that the availability of these modes automatically results in lower system power consumption, but this is not the case. Instead, the app's ability to use sleep mode is key.

Why are active modes good…and bad?

The most direct way to use MCU or WMCU is to let the CPU manage everything. For example, you can start an analog-to-digital conversion (ADC), put some data into a communication interface (such as a USART transmission) to read the ADC data, and make a decision on the data, all of which are directly controlled by the CPU. Direct CPU control simplifies development, but it comes at a price: Whenever it has to pay attention to peripherals or external events, the MCU will find itself in active mode, which consumes a lot of power.

Recently, some spec sheets will specify power consumption of 40μA/MHz and below as active mode, especially at higher frequencies. Because lower frequencies have higher μA/MHz values, the absolute power consumption is higher. This is because the current in active mode does not scale linearly with frequency. It consists of two parts, the second part of which has less impact at higher operating frequencies:

The process itself varies with pulse frequency

Reference current for infrastructure components such as voltage regulators, undervoltage detectors (BOD), etc.

It is helpful to offload as much as possible to other peripherals in the MCU, and to sleep the CPU as much as possible to avoid high power consumption from active mode.

Power budget

For battery-powered applications with limited electrical energy, it is important to know where the energy is being used so that you can begin to optimize it. Table 1 shows the power budget of a wireless application without effective optimization (sensor monitoring).

Power consumption is measured or estimated by averaging the current consumption of each component. If the CPU has a duty cycle of 2% and operates at 20MHz at 60µA/MHz, the CPU contributes 24µA.

Note that the power budget shown in Table 1 is divided by function. For example, the baseline sleep current includes an LFO and a real-time clock (RTC) to time system events and allow deep sleep. The sensor measurement contribution comes from sampling the sensor at 0.5kHz with interrupts and deep sleep between interrupts. Devices that implement Bluetooth Low Energy transmit broadcast data packets every second, which is very common for Bluetooth Low Energy devices.

Finally, there are contributions from non-MCU components. The MCU may not be able to directly control some of these components, including power management peripherals, but the sensors sampled by the ADC can be directly cycled by the MCU in this case. If not, the sensor current will be completely controlled. For this example, the continuous sensor current is about 390µA, but with a modest duty cycle, only 10µs per ADC sample is used, reducing the current considerably.

Table 1: Power budget for target applications

If the wireless application is powered by a CR2032 battery with a capacity of 225mAh, the lifetime is about 0.4 years when operating at 61.5μA power consumption. But we can actually do better.

Improve the situation

Now let's look at ways to reduce the current measured by the MCU's sensors. While this example involves an ADC measuring an external sensor, a related example could focus on a range of different types of measurements and interactions with the external environment. In both cases, frequent interactions occur between the MCU and the external environment.

Figure 1: Using interrupts for ADC sampling, power consumption increases as the number of interactions per second increases.

The easiest way to achieve low power sensing is to put the CPU to sleep as much as possible, wake up only for sampling, and go back to sleep as soon as possible. This can be a good approach for very low sampling rates, but as you can see from Figure 1, when the sampling rate or number of interactions per second increases, the current consumption of the system also increases significantly.

Many types of applications must be highly active while still maintaining battery life. Activity rates in excess of 1KHz are not unheard of, and measures are required to keep these applications on low power settings.

Figure 2 shows two other approaches to sensor management. The Peripheral Reflective System/Direct Memory Access (PRS/DMA) approach is completely CPU-free and allows ADC sampling to occur entirely in deep-sleep mode. Therefore, the RTC sends events directly to the ADC through an event system (such as Silicon Labs' PRS), instead of the RTC waking up the CPU to start the ADC conversion. The ADC automatically starts an ADC conversion when it receives this event; after completion of the conversion, the DMA is also able to start operation from deep sleep mode in this case and retrieve data from the ADC and store it in RAM. The benefit of the PRS/DMA approach is significantly reduced current consumption. At 1kHz, the system current drops from 58µA to 25µA.

Figure 2: ADC sampling graph showing various ways to minimize current consumption

A more efficient way to drive the ADC is the PRS/Comparator (CMP) driven approach, where the RTC still triggers conversions through the PRS system, but in this case the ADC uses the comparator function to evaluate the samples immediately unless it finds a special matter, otherwise the DMA or CPU is not enabled. This approach enables ultimate power savings at a sampling rate of 1kHz and a system current of 3.5µA.

Dynamic ADC Comparator

Using the PRS/CMP approach, the CPU will only spend time looking at samples when necessary, leaving many samples discarded. This approach is often extremely beneficial when monitoring slowly changing signals or when looking for specific events in a signal.

When monitoring a signal with a comparator, one approach is to measure the value of the signal and set the comparator on either side of the last known value in the signal. As long as the signal stays within the comparator threshold, the system will remain in deep sleep while the ADC is monitoring the signal and the CPU will remain in sleep state.

Figure 3: Dynamic ADC comparator value can be changed via CPU interrupt when signal exceeds threshold

However, if the signal changes and exceeds the threshold, the system will detect and take appropriate action. Before going back to sleep, the ADC thresholds should be reconfigured to accommodate the new signal value and put the system back to sleep until the next signal change. Figure 3 shows an example of this technique. The dots represent ADC samples, and the arrows represent when the CPU wakes up, changes are recorded and thresholds are reconfigured.

With this approach, the system will lose some signal accuracy because the signal can move between thresholds between triggers. However, the advantage is that power consumption is significantly reduced.

If the goal of the system is to measure the dynamic values ​​of the signal, then driving with PRS/DMA is ideal because it makes all the data available while still providing very efficient power savings.

autonomous subsystem

The ADC example is just one of many ways sleep mode can be exploited to significantly reduce application power consumption. Modern MCUs focused on low-power applications, such as Silicon Labs' EFM32 Gecko MCUs, have a host of features to operate in deep-sleep mode, allowing for a high degree of autonomous behavior.

For example, the LESENSE (Low Power Sensing) peripheral of Gecko MCU can automatically sample and evaluate up to 16 sensors without CPU intervention and interact with the sensors at high frequency. At the same time, the battery can operate for 10 years on a single charge.

Figure 4: Autonomous ADC system includes automatic sensor duty cycle and watchdog monitor

In many cases, a single peripheral device can perform its role autonomously, but there are also many situations where interaction is required. In this case, we can take advantage of some peripheral interconnects like the PRS system in modern MCUs. These interconnections allow multiple peripheral devices to be interconnected to perform more complex tasks autonomously.

Figure 4 shows an example of this autonomous system, using a chain of events to perform its functions:

The RTC periodically sends a PRS signal to the ADC to start conversion with a specific time offset

The RTC signal also starts the excitation of the external sensor and will be ready before the sampling time;

The ADC samples and alerts the DMA, which captures the samples and transfers them to RAM ;

The completed PRS signal from the ADC ensures that the external sensor is powered off;

The CPU will only generate an interrupt when the buffer is full, or when the ADC threshold is exceeded;

The PRS watchdog monitoring event loop function ensures continuous operation, but this function is optional.

Note that there is no need to use DMA here, and this setting can be used with the dynamic comparator setting to achieve the lowest power consumption.

These autonomous subsystems offer several key benefits:

Significant energy savings;

Deterministic sensor operation, even during periods of heavy CPU load.

The disadvantage is that not all MCUs support this type of operation, and you might want hardware designers to think the same way when setting up interactions. For many battery-powered applications, the advantages clearly outweigh the disadvantages.

There are really a lot of things to learn about the embedded Internet of Things. Don’t learn the wrong route and content, which will cause your salary to go up!

I would like to share with you a data package, which is almost 150 gigabytes. The learning content, interviews, and projects are relatively new and comprehensive! (Click to find an assistant to receive it)

Guess you like

Origin blog.csdn.net/m0_70911440/article/details/132473161