The "division" of module division is the meaning of planning, which means how to reasonably divide a large software into a series of functional independent parts to complete the system. C language as a structured programming language, based on the function of the module is divided (based on the function of the object-oriented design becomes an error, Newton's law encountered> Relativity), C language modular program design need to understand The following concepts: (1) The module is a combination of a .c file and a .h file, and the header file (.h) is the declaration for the module interface; The result of the above program is that integer variables a are defined in modules 1, 2, and 3, and a different address unit corresponds to different modules. Such a program is never needed in the world. The correct approach is: In this way, if the module 1, 2, and 3 operate a, the corresponding memory unit is corresponding. An embedded system usually includes two types of modules: The typical architecture of a single task program (1) starts from the specified address at the time of CPU reset; (2) jumps to execution at the assembly code startup; (3) jumps to the user main program main execution, completes in main: a. All hardware devices; b. Initialize each software module; c. Enter the infinite loop (infinite loop), call the processing function of each module The user main program and the processing function of each module are all completed in C language. The user's main program has entered an endless loop at the end. Its preferred solution is: Some programmers write like this: This grammar does not exactly express the meaning of the code. We do not see anything from for(;;). We only understand that for(;;) means in the C language that an unconditional loop understands its meaning. Similar problems. In the face of these problems, we can only express our sincere feelings: There are still many meaningful things in the world waiting for us to digest the food we eat. In fact, the embedded system will run to the end of the world. Interrupt service routine interrupts are an important part of embedded systems, but they do not include interrupts in standard C. Many compiler vendors added support for interrupts on Standard C, and provided new keywords for identifying Interrupt Service Routines (ISRs) similar to __interrupt, #program interrupt, and so on. When a function is defined as an ISR, the compiler automatically adds the interrupt on-site stacking and stacking code required by the interrupt service routine for this function. The interrupt service program needs to meet the following requirements: Determine whether there is an interrupt in the main program loop: The interrupt service routine designed as described above is very small, and the actual work is performed by the main program. Hardware Driver Module A hardware driver module should normally include the following functions: (1) Interrupt Service Routine ISR (2) Hardware initialization a. Modify registers, set hardware parameters (such as UART should set its baud rate, AD/DA device should set it Sample rate, etc.) b. Write the interrupt service routine entry address to the interrupt vector table: (3) Set the CPU control line for the hardware a. If the control line can be used for PIO (programmable I/O) and control signals, set the CPU internal register as the control signal; b. Set the CPU internal target The interrupt mask bit of this device sets the interrupt mode (level trigger or edge trigger). (4) Provide a series of operation interface functions for the device. For example, for the LCD, the driver module should provide functions such as drawing pixels, drawing lines, drawing matrixes, and displaying character lattices. For real clocks, the driver module needs to provide functions such as the acquisition time and setup time. Object-oriented C In the object-oriented language, the concept of classes emerged. A class is a collection of specific operations on specific data. The class contains two categories: data and operations. Structs in C language are just collections of data. We can use function pointers to simulate a struct as a "class" containing data and operations. The following C program simulates the simplest "class": We can use C to simulate three object-oriented features: encapsulation, inheritance, and polymorphism, but more often than not, we just need to encapsulate data and behavior to solve the problem of software structure confusion. The purpose of C-simulation object-oriented thinking is not to simulate the behavior itself, but to solve the problem that the program's overall framework structure is dispersed and data and functions are disconnected when programming in C under certain circumstances. We will see such an example in subsequent chapters. Finally, I summarized the knowledge of the embedded system programming software architecture introduced today, mainly including module division, multitasking or single task selection, single task program typical architecture, interrupt service program, hardware driver module design, etc., given in macro terms. The main elements contained in an embedded system software. Remember: Software architecture is the soul of software! The confusing structure of the program can be daunting. It is extremely difficult to debug, test, maintain, and upgrade.
Outdoor Fixed LED Display is a popular product for its high quality, every year sold to at least 80,000 pieces around the world, including Europe, North America, southeast Asia.Compared to other indoor LED display in the market, its biggest advantage is that it can display high-definition images while maintaining low power consumption.Besides, it adopts Die casting aluminum cabinet which is ultra-thin and ultra-light and owns good heat dissipation.Easy to install and maintain and suitable for multiple indoor scenes.
Application:
Movie theaters, clubs, stages.
Outdoor Fixed LED Display,Led Wall Display Screen,Curved Led Display Screen,Led Display Board Guangzhou Chengwen Photoelectric Technology co.,ltd , https://www.cwledpanel.com
(2) The external function and data that a module provides to other modules should be called with the extern keyword declaration in the .h file;
(3) Function and global variables in the module must be declared with a static keyword at the beginning of the .c file;
(4) Never define a variable in the .h file! The difference between defining a variable and declaring a variable is that the definition creates a memory allocation operation and is the concept of an assembly phase; a declaration simply tells the module that contains the declaration to look for external functions and variables from other modules during the connection phase. Such as:
(1) hardware driver module, a specific hardware corresponding to a module;
(2) Software function modules, the division of modules should meet the requirements of low coupling and high cohesion. Multitasking or single task The so-called "single-task system" means that the system cannot support multitasking concurrency operations and performs a task in macro-series. Multitasking systems can perform multiple tasks "simultaneously" at the same time in macro-parallel (microscopically possible serial). Multitasking concurrent execution usually depends on a multitasking operating system (OS). The core of the multitasking OS is the system scheduler, which uses the task control block (TCB) to manage the task scheduling function. The TCB includes the current status of the task, the priority, the event or resource to wait for, the starting address of the task code, the initial stack pointer, and other information. The scheduler uses this information when the task is activated.
In addition, TCB is also used to store the task's "context". The context of the task is all the information to be saved when an executing task is stopped. Usually, the context is the current state of the computer, that is, the contents of each register. When a task switch occurs, the context of the currently running task is stored in the TCB, and the context of the task to be executed is taken out of its TCB and placed in various registers. Typical examples of embedded multitask OS are Vxworks, ucLinux, and so on. The embedded OS is not an unattainable altar. We can implement an OS kernel that is the simplest for the 80186 processor with less than 1000 lines of code. Whether to choose multi-task or single-task mode depends on whether the software system is large. For example, most mobile phone programs are multitasking, but there are also some PHS protocol stacks that are single-tasked and have no operating system. Their main programs in turn call the processing programs of each software module to simulate a multitasking environment.
Here are a few "famous" endless loops:
(1) The operating system is an infinite loop;
(2) WIN32 program is an infinite loop;
(3) Embedded system software is an infinite loop;
(4) The thread processing function of a multithreaded program is an infinite loop.
You may refute and say out loud: "All things are not absolute, 2, 3, and 4 may not be endless loops." Yes, you are right, but you do not get flowers and applause. In fact, this is a point that doesn't make much sense, because the world never needs a WIN32 program that calls OS to kill it after processing several messages. It doesn't need an embedded system that just broke RUN. , do not need to start something a little to start killing your own thread. Sometimes it is not convenience but trouble that is made too strict. Don’t you see, the five-tier TCP/IP stack goes beyond the rigorous ISO/OSI seven-layer protocol stack to become the de facto standard? Netizens are often discussed:
(1) cannot return a value;
(2) No parameters can be passed to the ISR;
(3) ISR should be as short and as small as possible;
(4) The printf(char * lpFormatString,...) function can cause reentrancy and performance problems that cannot be used in the ISR. In the development of a project, we designed a queue, in the interrupt service program, just add the interrupt type into the queue, in the main program's endless loop constantly scan interrupt queue whether there is an interrupt, and then remove the queue The first type of interrupt is handled accordingly.
* Business Organizations:
Supermarket, large-scale shopping malls, star-rated hotels, travel agencies
* Financial Organizations:
Banks, insurance companies, post offices, hospital, schools
* Public Places:
Subway, airports, stations, parks, exhibition halls, stadiums, museums, commercial buildings, meeting rooms
* Entertainments: