Commonly used software anti-jamming measures in the reliability design of single chip microcomputer
The reliability design of single chip microcomputer is a system engineering. The reliability of single chip system must be fully considered from the aspects of software, hardware and structural design. The reliability design of the hardware system is the basis of the reliability of the single-chip system, and the reliability design of the software system plays a role in suppressing external interference. The main methods of software system reliability design are: power-on self-test, software trap (for program "running" detection), setting program running status flag, output port refresh, input multiple sampling, software "watchdog" and so on. Through the reliability design of the software system, the impact of the interference on the system work is minimized, and the single-chip microcomputer is found to promptly find errors caused by the interference, and restore the system to the normal working state or timely alarm. First, after the boot self-test, first check the hardware and software status of the single-chip system. Once it is found to be abnormal, it will be processed accordingly. The power-on self-test routine usually includes detection of RAM, ROM, I/O port status, and so on. 1. Detect RAM Check whether the RAM read and write is normal. The actual operation is to write “00H†to the RAM unit, read “00Hâ€, write “FFH†to it, and read “FFHâ€. If the RAM unit reads and writes an error, a RAM error (sound and light or other form) should be given and wait for processing. 4. Other interface circuit detection In addition to detecting the internal resources of the above-mentioned single-chip microcomputer, other interface circuits in the system, such as extended E2PROM, A/D conversion circuit, etc., and 555 single-stable temperature measurement circuit in digital thermometer , should be tested by software to determine if there is a fault. Only if all the checks are normal, the program can continue to execute, otherwise it should prompt an error. Second, the software trap in the program memory will always have some areas unused, if the PC value of the instruction counter of the microcontroller is misplaced due to interference, the program jumps to these unused program storage space, the system will go wrong. The software trap is in the unused area of ​​the program memory, plus a number of empty operations and unconditional jump instructions. The unconditional jump instruction points to the entry address of the program "running" processing subroutine. If the program jumps to these unused areas, an unconditional jump instruction is executed and the corresponding program error "runaway" handler is transferred. In addition to the unused area of ​​the program, you can insert software traps between the blocks (such as between subroutines and after a section of processing) and at the end of a page, the effect will be better. Here is a program with a software trap; DSP: ...; display subroutine RET Toe Sock,Five Toe Sock,Injinji Toe Socks Sellers Union Co., Ltd , http://www.nbshousehold.com
2. Checking the contents of the ROM unit The detection of the ROM unit is mainly to check the checksum of the contents of the ROM unit. The so-called ROM checksum is to add the contents of the ROM one by one to obtain a value, which is called the checksum. The ROM unit stores programs, constants, and tables. Once the program is written, the contents of the ROM are determined and the checksum is unique. If the ROM checksum error occurs, a ROM error message (sound and light or other form) should be given and wait for processing.
3. Check the status of the I/O port Firstly, determine the status of the I/O port of the system in the standby state, and then check whether the I/O port of the MCU is in the standby state (if there is a short circuit or open circuit, etc.) . If it is not normal, an error message (sound and light or other form) should be given and it is waiting for processing.
NOP; software trap NOP
NOP
LIMP FLY
D10MS: MOV R0, #010H; delay subroutine...
RET
NOP; software trap NOP
NOP
LJMP FLY
......
FLY: ... ; "running" processing subroutine RET