The purpose of the system power-off protection design is to adopt a mechanism to ensure the certainty of the system operation status and the integrity of the recorded data when the system loses power unexpectedly; when the system power is restored, the field data can be restored in time to avoid confusion in the application system. We know that embedded operating systems are increasingly used in the design and development of embedded systems. Due to the introduction of operating systems, data reading and writing are often completed through files rather than directly operating on the storage unit address. When operating data in the file reading and writing mode, data is often temporarily stored in volatile storage space, such as SDRAM, during the operation of the program. Once the system loses power unexpectedly, these data are often lost. Therefore, when the system loses power unexpectedly, certain measures must be taken to protect the system from power failure to avoid confusion in the system. In general, the main idea of the power-off protection program is to generate power-off signals, capture power-off signals, process power-off signals and data, and restore the field status.
If the operating system is not introduced, and the data is directly operated on the storage unit, the amount of data each operation is small, and the power-off protection can be performed by interrupt service; while the data is operated by file, the amount of data is generally large, so the power-off protection based on interrupt service is no longer reliable. The object of this paper is the power-off protection in the design process of a more complex embedded system based on an operating system.
1 System basis for implementing power-off protection scheme
Power-off protection is implemented on the basis of ARM hardware platform and μClinux embedded operating system.
The ARM7 series of microprocessors support eight types of interrupt processing. The external interrupt request will be responded to by the processor when the external interrupt pin is valid (usually low level) and the relevant bit of the program status register (i.e. the I control bit of CPSR) is set to enable. After the response, the processor enters the interrupt working mode, and the PC is loaded into the interrupt vector 0x00000018. The interrupt service program population address is stored in this address unit, and the interrupt service program can be executed. In the power-off protection scheme, the interrupt service program is very simple, which is to set the global variable indicating power-off. This can shorten the program execution time.
Flash memory is a memory that can be electrically erased and written in the system without losing information after power failure. It has the characteristics of low power consumption, large capacity, in-system programming (burning) and erasing of the entire chip or sectors, and the chip can be operated by internal embedded algorithms, so it has been widely used in various embedded systems. As a non-volatile memory. Flash is usually used in the system to store program code, constant tables, and some user data that needs to be saved after the system power is off. Commonly used Flash has a data width of 8 or 16 bits, and the programming voltage is a single 3.3V.
Compared with Flash memory, SDRAM does not have the characteristic of retaining data when power is off, but its access speed is much higher than Flash memory, and it has read/write properties. Therefore, SDRAM is mainly used as the program running space, data and stack area in the system. When the system starts, the CPU first reads the startup code from the reset address 0x0. After completing the system initialization, the program code should generally be transferred to SDRAM to run in order to increase the system's running speed. At the same time, the system and user stacks and running data are also placed in SDRAM. The storage unit of SDRAM can be understood as a capacitor, which always tends to discharge. In order to avoid data loss, it must be refreshed (charged) regularly. Therefore, to use SDRAM in the system, it is required that the microprocessor has a refresh control logic, or a refresh control logic circuit is added to the system. In particular, after the system loses power, an effective mechanism must be adopted to ensure that the data in SDRAM is written into F1ash.
2 Hardware design based on power-off protection scheme
Figure 1 is a typical embedded system hardware design. The system's microprocessor uses S3c4510B, which is based on the ARM7 architecture. SDRAM is a volatile memory that serves as a program running space, similar to the memory of a PC; Flash is a non-volatile program storage space. Data during program execution is often cached in SDRAM and must be written to Flash when the system loses power.
In the system, 5V and 3.3V DC regulated power supplies are required. Among them, S3C4510B and some peripheral devices require 3.3V power supply, and some other devices require 5V power supply. In order to simplify the design of the system power supply circuit, the input voltage of the entire system is required to be a high-quality 5V DC regulated power supply. Different from the general power supply circuit design, the power supply circuit design process of this system adds the design of power-off protection. The system power supply circuit including this design is shown in Figure 2.
In addition to providing 5v and 3.3v power, this power circuit also provides delay and warning functions for system power-off protection. The system power-off protection mechanism can be realized through software cooperation. Under normal circumstances, the power supply circuit 1 supplies power to the entire system. When the system loses power due to unexpected reasons, due to the reduction of the input comparison voltage, the output voltage of the MAX809 module is reversed to provide the system with a power-off interrupt warning signal, and the interrupt request is generated through the external interrupt pin XREQ0; at the same time, the power supply circuit 2 starts to be enabled. Through the discharge of large capacitors C3 and c4, a supply voltage is continuously provided to the system to support the completion of the power-off interrupt service program. Power supply circuit 2 only supplies power to the minimum system, and does not supply power to peripheral components with high power consumption. In this way, the power supply time for the minimum system is long enough to complete the protection operation of sensitive data.
Through software calculation, the minimum system working time for capacitor discharge is between 0.5 and 4.5 seconds. This calculation method is very simple. Write a power-off interrupt service subroutine, which only continuously performs time refresh operations. Similarly, the software can be used to determine that 2 to 3 MB is erased to the Flash during this period. It can be seen that under the use of this hardware system, the system power-off protection can be reliably guaranteed.
3 Implementation of power-off signal processing software method
In μClinux system, there are two ways to capture power-off signal. One is to use system call, that is, void(*signal(intslg, void(*func)(int)))(int). This function can arrange the execution function for a specific interrupt signal, and pass it with the parameter func. In μCllnux, there are 31 system interrupt signals, among which the power-off signal is SIGPWR. Assuming that the power-off interrupt service handler is void interrupt-service(int), the way to associate the interrupt service with the signal is: signal(SIGPWR, interrupt_service). This method makes full use of system calls and is simple to implement. This mechanism was also used in the early stage of the power-off protection scheme design. However, it turns out that this mechanism is not reliable. The reason is that the mechanism for generating and managing signals in the Linux kernel is not perfect, and there may be signal loss. By consulting relevant information about Unix or L1nux, it can be found that this situation is also common in some other versions of Linux and Unix.
Another way is to use a waiting process to start a process that specifically waits for an interrupt signal. The main program divides its own process plan into several atomic operations according to the different data operation objects. The so-called atomic operation means that the designated program block is either fully executed or not executed. Each operation corresponds to a unique status flag. Before each atomic operation, the main process will read the interrupt signal through pipeline communication. If an interrupt signal is generated, the main process first saves the status flag, then writes the relevant data to the Flash and exits. After the power is restored, the main process first determines the system recovery plan based on the flag word. Figure 3 implements this process in the form of a flowchart.
Conclusion
The tax control cash register designed based on this scheme has complete power-off protection function in actual operation. The application object of this power-off protection design method is the embedded system built based on ARM and μClinux, which has a typical representative significance in the development of 32-bit embedded systems. Therefore, it has promotion value in embedded system design.
Previous article:Design and implementation of short message monitoring system based on AT91RM9200
Next article:Design of IP Phone Based on S3C2410
- Popular Resources
- Popular amplifiers
- Machine Learning and Embedded Computing in Advanced Driver Assistance Systems (ADAS)
- Embedded Systems with RISC-V and ESP32-C3 - A practical introduction to architecture, peripherals and
- Multiplexed Networks for Embedded Systems: CAN, LIN, FlexRay, Safe-by-Wire
- Principles and Applications of Single Chip Microcomputers and Embedded Systems
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Newbie question, please help! I just learned analog electronics and built a simple circuit using Multisim
- 【Zero Knowledge ESP8266】Tutorial: Mobile APP Control RGB LED
- The application of CAN bus data in automobile digital technology is the starting point
- TI AM335 Embedded Hardware Design Reference Guide OK335xD
- Infineon Position2Go Development Kit Review @2. Official Tools
- Application of ISP chips in edge computing
- [Atria AT32WB415 Review] 2. Firmware burning (taking AT-Link burning as an example)
- Last day! Prize live broadcast How does the area array photoelectric conversion solution work in CT equipment? AMS OSRAM reveals the secrets
- Use of 2.4G wireless communication module NRF24L01 on Cortex M
- [Last Week] Watch the Power Supply Seminar to Share a 3,000 RMB Red Packet - Learn How to Correctly Complete a Modular DC-DC System