Common Software Architectures in Embedded Development

Click the blue "One Click Linux" at the top left and select "Set as Star"
Be the first to see valuable articles
[Valuable]Learning Path for Embedded Driver Engineers
[Valuable]A comprehensive project based on Linux IoT that can be added to your resume
[Valuable]Free Access to Embedded Linux Knowledge Mind Map
Common Software Architectures in Embedded Development
1

Everyone is familiar with microcontroller programming, but not many truly consider architecture. As the number of programs increases, architecture becomes very necessary.

1. Time-Slice Polling Method

A program architecture design scheme that lies between sequential execution and operating systems. This design scheme should help embedded software developers to advance. In the embedded software development process, if you encounter the following points, this design scheme can be said to be the optimal choice, suitable for more complex embedded systems;

The current demand design does not require an operating system.

Task functions do not need to be executed continuously; there are intervals (e.g., buttons, usually requiring software debouncing, where beginners often delay for about 10ms before judging, but this wastes CPU resources greatly; during this time, the CPU can handle many other tasks)

There are certain real-time requirements.

This design scheme requires the use of a timer, generally set to 1ms (the timing can be set freely, but if interrupts are too frequent, efficiency decreases; if interrupts are too long, real-time performance suffers). Therefore, it is necessary to consider the execution time of each task function, which should not exceed 1ms (if execution time can be optimized, that is best; if not, the execution cycle must be much greater than the time consumed by the task), and there should not be any millisecond-level delays in the main loop or task function.

Common Software Architectures in Embedded Development

Below are two different implementation schemes, targeting friends without function pointers and those who want to learn further.

1. Design Method without Function Pointers

Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development

2. Design Method with Function Pointers

Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development

2. Operating Systems

The embedded operating system EOS (Embedded Operating System) is a versatile system software, primarily used in industrial control and national defense systems. For microcontrollers, commonly used ones include UCOS, FreeRTOS, RT-Thread Nano, and RTX, among various preemptive operating systems (others like Linux are not suitable for microcontrollers)

In terms of task execution, operating systems do not have strict requirements on the time taken for each task. They need to set the priority of each task, and when a high-priority task is ready, it can preempt a low-priority task; operating systems are relatively complex, so they are not detailed here.

About how to choose the right operating system (comparative characteristics of uCOS, FreeRTOS, RTThread, RTX, etc.):

  • uCOS: Rich online resources, very suitable for learning, but requires payment for product use.

  • FreeRTOS: Free to use, so many products use it.

  • RT-Thread: A domestic IoT operating system with a wealth of components, also free, see: RT-Thread Documentation Center.

  • RTX: A royalty-free, deterministic real-time operating system designed for ARM and Cortex-M devices.

Here’s a comparison chart from the internet:

Common Software Architectures in Embedded Development

3. Front and Back Sequential Execution Method

This is a commonly used program framework design scheme for beginners; there is not much to consider, the code is simple, or the overall real-time and concurrency requirements of the system are not high; after initialization, it continuously calls its own written functions through a while(1){} or for(;;){} loop, usually without considering the time needed for each function to execute, and most functions contain some millisecond-level delays.

Advantages: For beginners, this is the easiest and most intuitive program architecture, with simple and clear logic, suitable for software development that is logically simple and relatively low in complexity.

Disadvantages: Low real-time performance, as each function contains some millisecond-level delays; even 1ms can cause different intervals in the execution time of other functions. Although it can be addressed through timer interrupts, the premise is that the time taken by the interrupt execution function must be short. As the complexity of the program logic increases, it can confuse later maintainers, making it difficult to clarify the program’s operating state.

Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development
Common Software Architectures in Embedded Development

Source: https://blog.csdn.net/an520_/article/details/124877026

This article is sourced from the internet, freely conveying knowledge, and copyright belongs to the original author. If there are copyright issues, please contact me for deletion.

end

One Click Linux

Follow, reply 【1024】 to receive a wealth of Linux materials

Collection of Wonderful Articles

Recommended Articles

[Album]ARM
[Album]Fan Q&A
[Album] All Originals
[Album]Linux Entry
[Album] Computer Networks
[Album] Linux Drivers
[Valuable]Learning Path for Embedded Driver Engineers
[Valuable]All Embedded Linux Knowledge Points – Mind Map

Leave a Comment

×