The reliability design of the single-chip microcomputer is a systematic project. The reliability of the single-chip microcomputer system must be comprehensively considered from the aspects of software, hardware and structural design. The reliability design of the hardware system is the foundation of the reliability of the single-chip microcomputer system, while the reliability design of the software system plays a role in suppressing external interference. The main methods of reliability design of the software system are: power-on self-test, software trap (to detect program "runaway"), setting program running status mark, output port refresh, input multiple sampling, software "watchdog", etc. Through the reliability design of the software system, the impact of interference on the system operation can be minimized, ensuring that the single-chip microcomputer can timely detect errors in the program caused by interference, and restore the system to normal working state or alarm in time.
1. Power-on self-test After booting up, first check the hardware and software status of the single-chip microcomputer system. Once abnormality is found, corresponding processing is carried out. The power-on self-test program usually includes the detection of RAM, ROM, I/O port status, etc.
1? Check RAM Check whether RAM read and write is normal. The actual operation is to write "00H" to the RAM unit, and the readout should also be "00H". Then write "FFH" to it, and the readout should also be "FFH". If the RAM unit reads and writes an error, a RAM error prompt (sound, light or other form) should be given, and wait for processing.
2? Check the content of the ROM unit The detection of the ROM unit is mainly to check the checksum of the content of the ROM unit. The so-called ROM checksum is a value obtained by adding the contents of the ROM one by one, and this value is called the checksum. The ROM unit stores programs, constants and tables. Once the program is written, the content in the ROM is determined, and its checksum is unique. If the ROM checksum is wrong, a ROM error prompt (sound, light or other form) should be given, and wait for processing.
3? Check the status of the I/O port First determine the state of the system's I/O port in the standby state, and then detect whether the state of the I/O port of the microcontroller in the standby state is normal (such as whether there is a short circuit or open circuit, etc.). If not normal, an error prompt (sound, light or other form) should be given, and wait for processing.
4? Other interface circuit detection In addition to the detection of the internal resources of the above-mentioned single-chip microcomputer, other interface circuits in the system, such as the extended E2PROM, A/D conversion circuit, and the 555 monostable temperature measurement circuit in the digital thermometer, should be detected by software to determine whether there is a fault.
Only when all the checks are normal can the program continue to execute, otherwise an error should be prompted.
2. Software traps There are always some unused areas in the program memory. If the PC value of the instruction counter of the single-chip microcomputer is misplaced due to interference, the program jumps to these unused program storage spaces and the system will fail. Software traps are to add several empty operations and unconditional jump instructions to the unused areas of the program memory. The unconditional jump instructions point to the entry address of the program "runaway" processing subroutine. If the program jumps to these unused areas, the unconditional jump instructions will be executed and transferred to the corresponding program error "runaway" processing program. In addition to the unused areas of the program, software traps can also be inserted between program segments (such as between subroutines and after a processing program is completed) and at the end of a page, which will have a better effect. The following is a program with software trap;
DSP: ...; Display subroutine
RET
NOP; Software trap
NOP
NOP
LIMP FLY
D10MS: MOV R0, #010H; Delay subroutine
...
RET
NOP; Software trap
NOP
NOP
LJMP FLY
...
FLY: ...; "Runaway" processing subroutine
RET
III. Program "runaway" processing To process the program "runaway", it is necessary to distinguish the impact caused by the program "runaway" and the process running before the program "runaway", which requires setting the corresponding flag.
RAM data normal flag RAM data normal flag is used to detect whether the data in the RAM area has been changed due to program "runaway" or other interference. If the data in the RAM area is indeed changed due to program "runaway" or other interference, the system cannot automatically recover to the original error location and can only be executed from the beginning by manual or software reset. To perform normal data detection in the RAM area, first set the RAM data normal flag for several units of RAM in the initialization program. Usually, several units are selected in the RAM area and set to fixed numbers in the initialization program, such as "55H" or "0AAH". As long as the program runs normally, the contents of these units will not be modified. If the data of any of these RAM units changes due to program "runaway" or other interference, it means that the contents of other RAM units may also change, which cannot reflect the results and status of program running, and the program running scene cannot be restored according to the flags in the RAM area.
Program running mark Program running status mark is to set up some flags in the RAM area, which represent the different stages of program running and the status after running. In the initialization program, these units are first set to initial values. At different stages of program running, the contents of these units will be changed to specific values to mark the stage of program running and the status after running. In addition to playing the role of conditional transfer in the normal operation of the program, these flags can also play the role of restoring the program running scene when the program "runaway" and the data in the RAM area are normal.
Program "runaway" handler Program "runaway" handling is to transfer to the "runaway" handler after the program is detected by the software trap. The "runaway" processing program determines the degree of the "runaway" impact, and decides whether to reset the alarm or automatically restore the scene according to the degree of impact. If the scene is automatically restored, it needs to be done according to the program running status mark. How to deal with the program "runaway" specifically should be carried out according to the design requirements of the control system.
4. Output port refresh Since the I/O port of the microcontroller is easily interfered by external signals, the state of the output port may also change. Periodically adding output terminal refresh instructions in the program can reduce the impact of interference on the output port state. In the program, specify the RAM unit to store the state that the output port should be in at that time, and refresh the I/O port according to the contents of these RAM units during the program running process.
5. Multiple input sampling interference to the input of the microcontroller will cause errors or misreading of the instantaneous sampling of the input signal. To eliminate the influence of interference, repeated sampling and weighted averaging methods are usually adopted.
For example, for external level sampling (such as keystrokes), the software reads the keyboard once every 10ms or reads it several times in succession, and the data read out each time is the same, or the voting method is adopted to confirm the input key value. For example, in a system that uses a monostable circuit to detect temperature (see "Electronics News" Issue 51, 1999, Page 9), the pulse width of the monostable circuit is counted, and then the temperature value is obtained by looking up the table. In order to eliminate the influence of interference, three samplings can be used to calculate the average value, or two samplings can be used, and the difference is less than the set value, and then the average value is calculated (also known as software filtering). In short, the input signal is sampled multiple times, and how to process it afterwards is to be optimized based on the actual processing effect of the specific object. The reader can determine it by applying interference during laboratory debugging and the effect of field environment debugging.
6. Software "Watchdog" Software trap is a method of detecting program errors when the program runs to an illegal area of ROM. The "watchdog" judges that the program is running incorrectly based on the fact that the program does not perform the corresponding operation within the specified time interval, that is, the watchdog timer is not reset on time.
If the system cost allows, a dedicated watchdog circuit chip or a microcontroller with a built-in watchdog timer should be selected. If conditions do not allow, a software "watchdog" should be added.
Previous article:Implementation of a portable PID parameter setting instrument based on MSP430 single chip microcomputer
Next article:Intelligent and practical programmable light controller source code
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- The transformer in the power supply has no output after loading
- Compile imx6-ek200 with buildroot
- Using MSP430 to implement PWM signal
- Get the MPM54304 evaluation board for the first quad-output module with digital power management
- Dead time problem of IGBT drive waveform
- The difference between single-phase carrier and type 2 collector
- CLF5356
- Why does the chip of the board heat up when the msp432 is powered on and compiled and downloaded under KEIL5 conditions? What is turned on?
- How to solve the thermal challenges of Wi-Fi front-end?
- Getting Started with Smart Home Audio Design