What Advanced Applications Are There for MCUs?

Source | Crazy Electronic Engineer

On Zhihu, there is a very popular question – “What advanced applications are there for MCUs?”

Zhihu:https://www.zhihu.com/question/623077193

It is often said that MCUs themselves are not particularly advanced. During the MCU development process, it is necessary to follow certain standardization, such as defining variables and functions, determining their lifecycle, calling scope, access conditions, etc.; commonly used communication protocols should often be abstracted, specifying fixed inputs and outputs to facilitate product portability.

However, in reality, there are often multiple implementation solutions for the same requirement, but there is always one optimal solution. Therefore, in this process, there will always be some “out-of-the-box” operations that provide many ideas. Today, I will give a few examples for your reference.

Those Impressive Applications

When receiving a string of variable-length data via a serial port, you can use the serial port idle interrupt; this avoids entering the interrupt for every character received, reducing the number of times the program enters the interrupt and thus improving efficiency.

When measuring the frequency of a waveform, many people choose external interrupts. In fact, counting the waveform edges using the external clock input of a timer and then periodically reading the count to calculate the frequency can greatly reduce the interrupt trigger frequency and improve program execution efficiency.

In complex multitasking scenarios, a Real-Time Operating System (RTOS) can be used to manage task scheduling, improving system responsiveness and resource utilization.

For scenarios requiring low power consumption, Dynamic Voltage and Frequency Scaling (DVFS) technology can be employed to adjust the MCU’s operating voltage and frequency in real-time based on system load, thereby reducing power consumption.

When storing data, using a flash memory wear leveling algorithm can extend the lifespan of the flash memory.

Utilizing hardware encryption modules (such as AES encryption engines) to ensure data security and confidentiality, rather than implementing encryption through software, improves encryption efficiency and security.

For processing sensor data, employing digital filtering algorithms (such as Kalman filtering) can enhance data accuracy and stability.

When needing to communicate with multiple devices, using a bus arbitration mechanism and priority settings ensures efficient and stable communication.

In power management, monitoring power voltage and current can enable intelligent power management strategies, such as entering low-power mode when battery levels are low.

For control tasks with extremely high real-time requirements, using hardware-triggered interrupts instead of software polling can reduce response delays.

Any dynamic control of a nonlinear system running on a microcontroller is considered an advanced application.

Using a microcontroller to implement a specific motion control and making a lot of money from it is also an advanced application.

GPIO Simulates Everything

A user named ShiinaKaze took on a very challenging task.

He used an STM32F1 to simulate a camera interface to drive the OV2640 camera module using GPIO. He stated that it was a very torturous process, and he optimized it to a maximum of 1.5 FPS, so choosing the right model is crucial to avoid torturing oneself. The device uses STM32F103C8T6 and OV2640, achieving the following effect:

What Advanced Applications Are There for MCUs?

Actual timing diagram of OV2640:

What Advanced Applications Are There for MCUs?

The challenges of this project include: 1. SCCB simulation: SCCB is a revision of the I2C bus, mainly because the OV2640 module does not have pull-up resistors, making communication impossible. It took a long time to discover this issue; 2. Simulating the parallel interface: If using IO simulation, only 1 FPS can be achieved, but by using Timer and DMA, it can reach 1.5 to 2 FPS.

Regarding the background of data reception and processing for the image sensor: The existing OV2640 image sensor has a DCMI (parallel interface). The problem is: the existing STM32H7 wants to obtain the MJPEG stream data from OV2640 and transmit the data to PC software. 1. Should I use USART or USB? 2. Which interrupt should be chosen for data reception, Line interrupt or Frame interrupt? 3. DCMI transfers data to a RAM buffer via DMA; how should the buffer be designed? Should it be a large continuous buffer or a ring buffer to avoid data overwriting and disorder? 4. After triggering the interrupt, should DCMI and DMA be disabled?

Embedded software architecture is quite important, especially for large projects. This is the software architecture for STM32; I wonder if anyone has other architectures.

A user complained that if you were in school, I would respect you as a man, but if you were doing this at work, your architecture is too poor. He also stated – “I was wrong, I will never simulate again.”

What Advanced Applications Are There for MCUs?

Different Perspectives on MCUs

Despite this, many still believe that MCUs are not advanced, and using microcontrollers is not advanced either. Advanced content is something that can be published in papers, but using microcontrollers to solve specific tasks is quite advanced.

Especially the examples mentioned above are indeed some high-end applications of MCU peripherals. However, these mechanisms may just be standard usage. A user named lion187 stated that many hardware mechanisms are added only after there is a practical need, such as receiving variable-length data. Initially, without timeout interrupts, it could only be implemented in software, which greatly wasted CPU efficiency, leading to the design of timeout interrupts to reduce software workload, thus forming a standard usage method.

Of course, this is also a benefit brought by the improvement of chip design and manufacturing processes. In the early days, when chip design and processes could not meet the needs of complex peripheral circuits, no one dared to think of using hardware to implement such complex functions. The development of any product is inseparable from specific business needs, and MCUs are no exception. For products, the driving of MCU peripherals is just a basic element of development; more work revolves around the development of application programs based on business logic. At this point, data structures and algorithms, various control algorithms and numerical computation methods, design patterns, software engineering, and design concepts become advanced topics.

For example, the design of various driver subsystems in the Linux kernel, device objects, and driver objects have adopted the object-oriented programming ideas of C++, which can also be applied to MCU development. By separating devices from drivers, the same set of driver algorithms can be used to implement different driving methods for similar devices. For instance, the same UART driver can drive UART0 or UART1 based on different configurations, and the baud rate can also differ (as long as different instances of the UART class are created, this can be done using C language). This is the benefit of separating methods and properties in C++.

Similarly, in the business application part, the use of design patterns such as singleton and factory patterns, as well as state machine models, can bring many conveniences to development, making system structures clear, effectively reducing the number of bugs, and being easy to maintain and extend.

Of course, some believe that when it comes to advanced, FPGA is the way to go. For example, AMD (Xilinx) ZYNQ allows you to directly write a dedicated function in the Programmable Logic part when you need to receive a string of variable-length data via a serial port, with the final result placed in DRAM, and a signal sent to the ARM processor to read it. When you need to measure the frequency of a waveform, you can directly write a dedicated function in the Programmable Logic part for real-time continuous measurement. This is indeed very advanced.

What Advanced Applications Are There for MCUs?

So, what are your thoughts on this? Do you have any “advanced” applications you would like to share?

ENDPrevious Recommendations:

Is it really necessary to attend training for embedded systems?

Is embedded systems a dead end, with low pay and many troubles?

RT-thread scheduling: How to lightning lock the highest priority?

3KB ends the embedded baldness crisis

From 16K to 22K, he achieved it in less than half a year! – The real success story of embedded student Liu

What Advanced Applications Are There for MCUs?Douyin Video QR CodeWhat Advanced Applications Are There for MCUs?What Advanced Applications Are There for MCUs?

Leave a Comment