Main and standby code memory switching circuit and method for switching main and standby code memories

By designing the main and backup code memory switching circuit, the processor's switch pins selectively access the main and backup code memory, detecting and updating the code, the system downtime caused by memory read and write errors in the existing technology is solved, and a higher level of reliability and stability and automatic recovery capabilities.

CN118916219APending Publication Date: 2024-11-08BAOLI TIANTONG INSTR CORP +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411411426.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

In existing circuits that integrate processors and memory, excessive memory read and write times or external environment factors cause misalignment when the processor loads the program, the system has a risk of downtime and cannot recover on its own, resulting in poor reliability.

Method used

Design a master-support code memory switching circuit, output different levels through the processor's main select switch pin and alternative switch pin, selectively access the main code memory and backup code memory, detect and update the code, and in the main When the code memory is damaged, it will automatically switch to the backup code memory loader to achieve self-recovery.

Benefits of technology

It improves the reliability and stability of the system, realizes the functions of automatic restart and unattended devices, ensuring that the processor can automatically switch to the backup code memory loader when the main code memory is damaged, and avoids system downtime.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916219A_ABST
    Figure CN118916219A_ABST
Patent Text Reader

Abstract

The invention discloses a main and standby code memory switching circuit and a method for switching a main code memory and a standby code memory, and belongs to the technical field of electronic circuits. The main and standby code memory switching circuit comprises a processor, a main code memory, a standby code memory, an OR gate chip and a D trigger; a fifth pin and a sixth pin of the D trigger are connected to a first pin and a fourth pin of the OR gate chip, a third pin and a sixth pin of the OR gate chip are connected to the main code memory and the standby code memory, and a chip selection pin of the processor is connected to a second pin and the fifth pin of the OR gate chip. The processor is connected to the main code memory and the standby code memory, when a fifth pin of the D trigger outputs a low level and a sixth pin of the D trigger outputs a high level, the processor loads a program from the main code memory, and when the fifth pin of the D trigger outputs the high level and the sixth pin outputs the low level, the processor loads a program from the standby code memory. Therefore, self-recovery and unattended operation of equipment are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic circuits, and in particular to a main-standby code memory switching circuit and a method for switching main-standby code memories. Background Art

[0002] In existing circuits that integrate processors and memories, a single memory is generally used to store program instructions, and the processor is allowed to load program instructions from this memory for operation. The memory has the problem of being damaged due to excessive read and write times or other cloud factors, which leads to the risk of system downtime during operation, resulting in poor system reliability. In addition, external environmental factors can also cause the processor to be misaligned when loading program instructions stored in the memory, and once misalignment occurs, the system cannot recover by itself. Summary of the invention

[0003] An object of the present invention is to provide a master-slave code memory switching circuit and a method for switching master-slave code memories, wherein when a processor in the master-slave code memory switching circuit is unable to load a program from a master code memory, the master-slave code memory switching circuit allows the processor to load a program from a master code memory, thereby making the master-slave code memory switching circuit have higher reliability and stability.

[0004] An object of the present invention is to provide a main-standby code memory switching circuit and a method for switching the main-standby code memory, wherein since the main-standby code memory switching circuit allows the processor to load a program from the standby code memory, the main-standby code memory switching circuit can automatically restart to achieve self-recovery and realize unattended equipment.

[0005] An object of the present invention is to provide a main-standby code memory switching circuit and a method for switching main-standby code memories, wherein the processor selectively accesses the main code memory and the standby code memory by outputting different levels through the main selection switch pin SW_M and the standby switch pin SW_S. In this way, the main-standby code memory switching circuit can detect and / or update the code stored in the main code memory and the standby code memory, and can also detect whether the hardware of the main code memory and the standby code memory is damaged.

[0006] According to one aspect of the present invention, the present invention provides a main-standby code memory switching circuit, which includes a processor, a main code memory, a standby code memory, an OR gate chip and a D flip-flop, wherein the fifth pin and the sixth pin of the D flip-flop are respectively connected to the first pin and the fourth pin of the OR gate chip, the third pin and the sixth pin of the OR gate chip are respectively connected to the main code memory and the standby code memory, the chip select pin of the processor is respectively connected to the second pin and the fifth pin of the OR gate chip, and the processor is respectively connected to the main code memory and the standby code memory, wherein: When the fifth pin of the D flip-flop outputs a low level and the sixth pin outputs a high level, the first pin of the OR gate chip is input with a low level and the fourth pin is input with a high level, the chip select pin of the processor outputs a low level so that the second pin and the fifth pin of the OR gate chip are respectively input with a low level, at this time, the third pin of the OR gate chip outputs a low level and the sixth pin outputs a high level, and the processor loads a program from the main code memory; When the fifth pin of the D flip-flop outputs a high level and the sixth pin outputs a low level, the first pin of the OR gate chip is input with a high level and the fourth pin is output with a low level, the chip select pin of the processor outputs a low level so that the second pin and the fifth pin of the OR gate chip are respectively input with a low level, at this time, the third pin of the OR gate chip outputs a high level and the sixth pin outputs a low level, and the processor loads the program from the backup code memory.

[0007] According to one embodiment of the present invention, the main-standby code memory switching circuit further includes an AND gate chip, the main selection switch pin and the standby switch pin of the processor are respectively connected to the fifth pin and the tenth pin of the AND gate chip, and the sixth pin and the eighth pin of the AND gate chip are respectively connected to the first pin and the fourth pin of the D flip-flop, wherein: the main selection switch pin and the standby switch pin of the processor input a high level to the fifth pin and the tenth pin of the AND gate chip respectively, when the fourth pin of the AND gate chip is input with a low level and the ninth pin is input with a high level, the sixth pin of the AND gate chip outputs a low level and the eighth pin outputs a high level, the first pin of the D flip-flop is input with a low level and the fourth pin is input with a high level, at this time, the fifth pin of the D flip-flop outputs a low level and the sixth pin outputs a high level; When the fourth pin of the AND gate chip is input with a high level and the ninth pin is input with a low level, the sixth pin of the AND gate chip outputs a high level and the eighth pin outputs a low level, the first pin of the D flip-flop is input with a high level and the fourth pin is input with a low level, at this time, the fifth pin of the D flip-flop outputs a high level and the sixth pin outputs a low level.

[0008] According to one embodiment of the present invention, the main-standby code memory switching circuit further includes a counter, an oscillator and an inverter with a Schmitt trigger function, wherein the twelfth pin of the counter is connected to the dog feeding signal output pin of the processor, the third pin of the counter is connected to the thirteenth pin of the inverter, the oscillator is connected to the ninth pin, the tenth pin and the eleventh pin of the counter, the twelfth pin of the inverter is connected to the second pin and the ninth pin of the AND gate chip, and the third pin of the AND gate chip is respectively connected to the main code memory, the standby code memory and the processor, wherein when the twelfth pin of the inverter outputs a low level and causes the ninth pin of the AND gate chip to be input with a low level, the eighth pin of the AND gate chip outputs a low level.

[0009] According to one embodiment of the present invention, the master-standby code memory switching circuit further includes an inverter with a Schmitt trigger function and a power-on reset unit, the power-on reset unit is connected to the first pin of the inverter, the second pin and the third pin of the inverter are connected to each other, and the fourth pin of the inverter is connected to the first pin and the fourth pin of the AND gate chip.

[0010] According to one embodiment of the present invention, the master-standby code memory switching circuit includes a jumper cap, two pins of the jumper cap are respectively connected to the third pin of the counter and the thirteenth pin of the inverter, so that the third pin of the counter is connected to the thirteenth pin of the inverter.

[0011] According to an embodiment of the present invention, the power-on reset unit includes a resistor R3 and a capacitor C1, the resistor R3 is connected between a power supply and a first pin of the inverter, and the capacitor C1 is connected between the ground and the first pin of the inverter.

[0012] According to one embodiment of the present invention, the oscillator includes a resistor R5, a resistor R6 and a second capacitor, one end of the resistor R5, one end of the resistor R6 and one end of the second capacitor are connected to each other, and the other end of the second capacitor, the other end of the resistor R6 and the other end of the resistor R5 are respectively connected to the ninth pin, the tenth pin and the eleventh pin of the counter.

[0013] According to one embodiment of the present invention, the chip model of the counter is 74HC4060, the chip model of the inverter is 74HC14, the chip model of the AND gate chip is 74HC08, the chip model of the D flip-flop is 74HC74, and the chip model of the OR gate chip is 74HC32.

[0014] According to another aspect of the present invention, the present invention further provides a method for switching between a primary and a standby code memory, wherein the switching method comprises the following steps: When the first pin and the fourth pin of the OR gate chip are respectively input with a low level and a high level by the fifth pin and the sixth pin of the D flip-flop, and the second pin and the fifth pin of the OR gate chip are respectively input with a low level by the processor, the third pin of the OR gate chip connected to the main code memory is allowed to output a low level and the sixth pin connected to the backup code memory is allowed to output a high level, so that the processor can load a program from the main code memory; When the first pin and the fourth pin of the OR gate chip are respectively input with high level and low level by the fifth pin and the sixth pin of the D flip-flop, and the second pin and the fifth pin of the OR gate chip are respectively input with low level by the processor, the third pin of the OR gate chip connected to the main code memory is allowed to output a high level and the sixth pin connected to the backup code memory is allowed to output a low level, so that the processor can load the program from the backup code memory.

[0015] According to one embodiment of the present invention, a high level is input to the fourth pin and the fifth pin of the AND gate chip to allow the sixth pin of the AND gate chip to output a high level to the first pin of the D flip-flop. At this time, the fifth pin of the D flip-flop outputs a high level to the first pin of the OR gate chip, and a high level is input to the ninth pin and the tenth pin of the AND gate chip to allow the eighth pin of the AND gate chip to input a low level to the fourth pin of the D flip-flop. At this time, the sixth pin of the D flip-flop inputs a low level to the fourth pin of the OR gate chip, so that the processor can switch from loading a program from the main code memory to loading a program from the backup code memory.

[0016] According to one embodiment of the present invention, a high level is input to the fourth pin of the AND gate chip and a low level is input to the fifth pin to allow the sixth pin of the AND gate chip to output a low level to the first pin of the D flip-flop. At this time, the fifth pin of the D flip-flop outputs a low level to the first pin of the OR gate chip. A high level is input to the ninth pin of the AND gate chip and a high level is input to the tenth pin to allow the eighth pin of the AND gate chip to input a high level to the fourth pin of the D flip-flop. At this time, the sixth pin of the D flip-flop inputs a high level to the fourth pin of the OR gate chip, so that the processor can switch from loading a program from the backup code memory to loading a program from the main code memory.

[0017] Compared with the prior art, the present invention has at least the following beneficial effects: 1. When the processor cannot load a program from the main code memory, the processor can automatically load a program from the backup code memory to achieve automatic restart of the main and backup code memory switching circuit, so as to achieve self-recovery and unattended equipment; 2. When the processor cannot load a program from the main code memory, the processor can automatically load a program from the backup code memory. In this way, the main-backup code memory switching circuit of the present invention has higher reliability and stability; 3. During the normal process of loading a program from the main code memory, the processor can selectively access the main code memory and the standby code memory by outputting different levels from the main selection switch pin SW_M and the standby switch pin SW_S. For example, when the main selection switch pin SW_M of the processor outputs a high level and the standby switch pin SW_S outputs a low level, the processor switches from loading the program from the main code memory to loading the program from the standby code memory; when the main selection switch pin SW_M of the processor outputs a low level and the standby switch pin SW_S outputs a high level, the processor switches from loading the program from the standby code memory to loading the program from the main code memory, so as to enable the processor to selectively access the main code memory and the standby code memory. In this way, the main-standby code memory switching circuit can detect and / or update the codes stored in the main code memory and the standby code memory, and can also detect whether the hardware of the main code memory and the standby code memory is damaged.

[0018] Other beneficial effects of the present invention will be further explained in the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a circuit diagram of a main-standby code memory switching circuit according to a preferred embodiment of the present invention.

[0020] Figure 2 It is a timing diagram of the main-standby code memory switching circuit according to the above preferred embodiment of the present invention when the dog is not fed.

[0021] Figure 3 It is a timing diagram of the main-standby code memory switching circuit when feeding the dog according to the above preferred embodiment of the present invention.

[0022] Figure 4 This is the state of the main-standby code memory switching circuit when powered on according to the above preferred embodiment of the present invention.

[0023] Figure 5 This is the state of the main-standby code memory switching circuit when it is powered on for 250ms according to the above preferred embodiment of the present invention.

[0024] Figure 6 This is the state of the main-standby code memory switching circuit according to the above preferred embodiment of the present invention when it is powered on for 1 second and fed to the dog.

[0025] Figure 7 This is the state of the main-standby code memory switching circuit according to the above preferred embodiment of the present invention when the processor autonomously switches from the main code memory to the standby code memory under the dog feeding condition.

[0026] Figure 8 This is the state of the main-standby code memory switching circuit according to the above preferred embodiment of the present invention when the processor autonomously switches from the standby code memory to the main code memory under the dog feeding condition.

[0027] Fig. 9 This is the state of the main-standby code memory switching circuit according to the above preferred embodiment of the present invention when it is powered on for 1.2s and the dog is not fed.

[0028] Fig.10 It is a flowchart of a method for switching between a primary and a secondary code memory according to a preferred embodiment of the present invention.

[0029] In the figure: 10. Processor; 20. Main code memory; 30. Backup code memory; 40. Counter; 50. Jumper cap; 60. Oscillator; 70. Inverter; 80. Power-on reset unit; 90. AND gate chip; 100. D flip-flop; 110. OR gate chip; 120. Switch. DETAILED DESCRIPTION

[0030] Before describing in detail any embodiment of the present invention, it should be understood that the present invention is not limited in its application to the construction and arrangement details of the components described below or illustrated in the following figures. The present invention can have other embodiments and can be practiced or carried out in various ways. In addition, it should be understood that the words and terms used here are for descriptive purposes and should not be considered restrictive. The use of "including" or "having" and its variations herein is intended to cover the items and their equivalents and additional items displayed below. Unless otherwise specified or limited, the terms "install", "connect", "support" and "couple" and their variations are widely used and cover direct installation and indirect installation, connection, support and connection. In addition, "connect" and "couple" are not limited to physical or mechanical connections or connections.

[0031] Furthermore, on the first aspect, in the disclosure of the present invention, the terms "longitudinal", "lateral", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore the above terms cannot be understood as limitations on the present invention; on the second aspect, the term "one" should be understood as "at least one" or "one or more", that is, in one embodiment, the number of an element may be one, while in another embodiment, the number of the element may be multiple, and the term "one" cannot be understood as a limitation on the quantity.

[0032] With reference to the accompanying drawings of the present invention Figures 1 to 9 A master-slave code memory switching circuit according to a preferred embodiment of the present invention will be disclosed and explained in the following description, wherein the master-slave code memory switching circuit includes a processor 10, a master code memory 20, a backup code memory 30, a counter 40, a jumper cap 50, an oscillator 60, an inverter with a Schmitt trigger function 70, a power-on reset unit 80, an AND gate chip 90, a D flip-flop 100 and an OR gate chip 110.

[0033] The processor 10 is configured to connect the main code memory 20 and the standby code memory 30. The processor 10 can load programs not only from the main code memory 20, but also from the standby code memory 30. Preferably, after the main-standby code memory switching circuit is powered on, the processor 10 loads programs from the main code memory 20. When the main-standby code memory switching circuit fails, for example, when the main code memory 20 is damaged and cannot be started due to too many read and write times or other reasons, or when the code runs incorrectly due to environmental problems, the processor 10 can load programs from the standby code memory 30 to achieve automatic restart of the main-standby code memory switching circuit, so as to achieve self-recovery and unattended equipment. Moreover, through the above-mentioned method, the main-standby code memory switching circuit of the present invention has higher reliability and stability.

[0034] It is worth mentioning that the main code memory 20 and the backup code memory 30 have different identifiers to facilitate identification by the processor 10. For example, the high address of the main code memory 20 that is not covered by the code is written as "5555", and the high address of the backup code memory 30 that is not covered by the code is written as "AAAA". If the code read by the processor 10 contains "5555", it is identified as the main code memory 20. Correspondingly, if the code read by the processor 10 contains "AAAA", it is identified as the backup code memory 30.

[0035] Specifically, refer to the attached Figure 1 , the twelfth pin MR of the counter 40 is connected to the dog feeding signal output pin WDI_OUT of the processor 10, and the third pin Q14 of the counter 40 is connected to the second pin of the jumper cap 50. Preferably, the dog feeding signal output pin WDI_OUT of the processor 10 is connected to a resistor R7, and the resistor R7 is grounded, that is, the resistor R7 is connected in series between the dog feeding signal output pin WDI_OUT of the processor 10 and the ground. In particular, the resistance value of the resistor R7 is 4.7KΩ.

[0036] The oscillator 60 is connected to the ninth pin O and the tenth pin of the counter 40. and the eleventh pin I. In this specific example of the main-standby code memory switching circuit of the present invention, the oscillator 60 includes a resistor R5, a resistor R6 and a capacitor C2, one end of the resistor R5, one end of the resistor R6 and one end of the capacitor C2 are connected to each other, and the other end of the capacitor C2, the other end of the resistor R6 and the other end of the resistor R5 are connected to the ninth pin O, the tenth pin O and the tenth pin O of the counter 40, respectively. and an eleventh pin I, wherein the counting time of the counter 40 is realized by the resistor R6 and the capacitor C2, and the counting time of the counter 40 is T=[1 / (2.2×R6×C2] / 2 14 ≈1.2s. In particular, the resistance of the resistor R5 is 1MΩ, the resistance of the resistor R6 is 100KΩ, and the capacitance of the capacitor C2 is 200pF. Preferably, the sixteenth pin VCC of the counter 40 is connected to the power supply VCC3V3, and the eighth pin GND of the counter 40 is grounded. Preferably, in a specific example of the main-standby code memory switching circuit of the present invention, the chip model of the counter 40 is 74HC4060.

[0037] The thirteenth pin 6A of the inverter 70 is connected to the first pin of the jumper cap 50, so that the jumper cap 50 connects the thirteenth pin 6A of the inverter 70 and the third pin Q14 of the counter 40. Preferably, the first pin of the jumper cap 50 is connected to a resistor R4, and the resistor R4 is grounded. In particular, the resistance of the resistor R4 is 4.7KΩ. In other specific examples of the master-slave code memory switching circuit of the present invention, the master-slave code memory switching circuit may not have the jumper cap 50, in which case the thirteenth pin 6A of the inverter 70 and the third pin Q14 of the counter 40 are directly connected.

[0038] The twelfth pin 6Y of the inverter 70 is connected to the second pin 1B and the ninth pin 3A of the AND gate chip 90, the power-on reset unit 80 is connected to the first pin 1A of the inverter 70, the second pin 1Y and the third pin 2A of the inverter 70 are connected to each other, and the fourth pin 2Y of the inverter 70 is connected to the first pin 1A and the fourth pin 2A of the AND gate chip 90. In particular, the fourteenth pin VCC of the inverter 70 is connected to the power supply VCC3V3, and the seventh pin GND of the inverter 70 is grounded. Preferably, in a specific example of the main-standby code memory switching circuit of the present invention, the chip model of the inverter 70 is 74HC14.

[0039] Further, the power-on reset unit 80 includes a resistor R3 and a capacitor C1, the resistor R3 is connected between the power supply VCC3V3 and the first pin 1A of the inverter 70, the capacitor C1 is connected between the ground and the first pin 1A of the inverter 70, and the power-on reset unit 80 is used to implement the power-on reset of the processor 10, the main code memory 20 and the backup code memory 30. That is to say, in this specific example of the main and backup code memory switching circuit of the present invention, the resistor R3 and the capacitor C1 of the power-on reset unit 80 implement the RC power-on reset function. Since RC rises slowly and does not conform to the characteristics of the logic signal of the digital circuit, the inverter 70 has a Schmitt trigger function to shape the output signal of the RC circuit to achieve a low-effective power-on reset function.

[0040] In particular, the reset time of the power-on reset unit 80 is 250ms. The resistance of the resistor R3 is 27KΩ, the capacitance of the capacitor C1 is 22μF, and when the power supply is 3.3V, the inverter 70 changes from low to high level by about 2V, so the reset time of the power-on reset unit 80 is 250ms, that is, the time of power-on outputting a low level is 250ms. In other words, before the main-standby code memory switching circuit is powered on for 250ms, the fourth pin 2Y of the inverter 70 will output a low level, and after the main-standby code memory switching circuit is powered on for 250ms, the fourth pin 2Y of the inverter 70 will output a high level.

[0041] In addition, please refer to the attached Figure 1 The master-slave code memory switching circuit further includes a switch 120, which connects the first pin 1A of the inverter 70 and the ground. The switch 120 can be a manual switch. Pressing the switch 120 can reset the master-slave code memory switching circuit. The switch 120 can also be a relay. When the switch 120 is implemented as a relay, the switch 120 is controllably connected to the processor 10, and the processor 10 controls the state of the switch 120, thereby resetting the master-slave code memory switching circuit.

[0042] The fifth pin 2B of the AND gate chip 90 is connected to the main selection switch pin SW_M of the processor 10, the tenth pin 3B of the AND gate chip 90 is connected to the alternative switch pin SW_S of the processor 10, the third pin 1Y of the AND gate chip 90 is connected to the processor 10, the main code memory 20 and the spare code memory 30, and the sixth pin 2Y of the AND gate chip 90 is connected to the first pin 10 of the D flip-flop 100. The eighth pin 3Y of the AND gate chip 90 is connected to the fourth pin of the D flip-flop 100 Preferably, the fourteenth pin VCC of the AND gate chip 90 is connected to the power supply VCC3V3, and the seventh pin GND of the AND gate chip 90 is grounded. Preferably, in a specific example of the main-standby code memory switching circuit of the present invention, the chip model of the AND gate chip 90 is 74HC08.

[0043] The fifth pin 1Q of the D flip-flop 100 is connected to the first pin 1A of the OR gate chip 110, and the sixth pin 1Q of the D flip-flop 100 is connected to the first pin 1A of the OR gate chip 110. is connected to the fourth pin 2A of the OR gate chip 110. Preferably, the fourteenth pin VCC of the D flip-flop 100 is connected to the power supply VCC3V3, the seventh pin GND of the D flip-flop 100 is grounded, the second pin 1D of the D flip-flop 100 is connected to a resistor R2, the resistor R2 is grounded, and the third pin 1CP of the D flip-flop 100 is connected to a resistor R1, the resistor R1 is grounded, so that the input of the second pin 1D and the third pin 1CP of the D flip-flop 100 is a low level. In particular, the resistance value of the resistor R1 is 4.7KΩ, and the resistance value of the resistor R2 is 4.7KΩ. Preferably, in a specific example of the main-standby code memory switching circuit of the present invention, the chip model of the D flip-flop 100 is 74HC74.

[0044] The chip select pin EMIF_CS of the processor 10 is connected to the second pin 1B and the fifth pin 2B of the OR chip 110, the third pin 1Y of the OR chip 110 is connected to the main code memory 20, and the sixth pin 2Y of the OR chip 110 is connected to the standby code memory 30. Preferably, the fourteenth pin VCC of the OR chip 110 is connected to the power supply VCC3V3, and the seventh pin GND of the OR chip 110 is grounded. In a specific example of the main and standby code memory switching circuit of the present invention, the chip model of the OR chip 110 is 74HC32.

[0045] The truth table of the inverter 70 is shown in Table 1: Table 1 The truth table of the AND gate chip 90 is shown in Table 2: Table 2 The truth table of the D flip-flop 100 is shown in Table 3: Table 3 The truth table of the OR gate chip 110 is shown in Table 4: Table 4 "A" in Tables 1 to 4 refers to the input pins of each chip, that is, the first pin 1A and the thirteenth pin 6A of the inverter 70, the first pin 1A, the fourth pin 2A and the ninth pin 3A of the AND gate chip 90, and the first pin 1A and the fourth pin 2A of the OR gate chip 110; "B" in Tables 1 to 4 refers to the input pins of each chip, that is, the second pin 1B, the fifth pin 2B and the tenth pin 3B of the AND gate chip 90, the second pin 1A, the fourth pin 2A and the ninth pin 3A of the OR gate chip 110. 1B and the fifth pin 2B; "Y" in Tables 1 to 4 refers to the output pins of each chip, that is, the second pin 1Y, the fourth pin 2Y and the twelfth pin 6Y in the inverter 70, the third pin 1Y, the sixth pin 2Y and the eighth pin 3Y in the AND gate chip 90, the third pin 1Y and the sixth pin 2Y in the OR gate chip 110; "L" in index 4 of Table 1 refers to a low level, "H" refers to a high level, and "X" refers to any one of a low level and a high level; "↑" represents a rising edge in a pulse.

[0046] Reference Figure 2 , Figure 3 and Figure 4, when the main-standby code memory switching circuit is powered on, the chip select pin EMIF_CS of the processor 10 outputs a low level, the main select switch pin SW_M and the standby switch pin SW_S of the processor 10 output a high level, and the dog feeding signal output pin WDI_OUT of the processor 10 outputs a low level. Since the dog feeding signal output pin WDI_OUT of the processor 10 outputs a low level, the twelfth pin MR of the counter 40 is input with a low level. Within the counting time T of the counter 40, the dog feeding signal output pin WDI_OUT of the processor 10 can reset the counter 40 after a high pulse to realize the watchdog function. At this time, the third pin Q14 of the counter 40 outputs a low level. Since the third pin Q14 of the counter 40 outputs a low level, the thirteenth pin 6A of the inverter 70 is input with a low level. According to Table 1, after being inverted by the inverter 70, the twelfth pin 6Y of the inverter 70 outputs a high level, and at this time, the second pin 1B and the ninth pin 3A of the AND chip 90 are input with a high level. The power-on reset unit 80 outputs a low level to allow the first pin 1A of the inverter 70 to be input with a low level. Since the second pin 1Y and the third pin 2A of the inverter 70 are connected to each other, after being inverted and shaped by the inverter 70, the fourth pin 2Y of the inverter 70 outputs a low level, and at this time, the first pin 1A and the fourth pin 2A of the AND chip 90 are input with a low level. According to Table 2, when the first pin 1A of the AND gate chip 90 is input with a low level and the second pin 1B is input with a high level, the third pin 1Y of the AND gate chip 90 outputs a low level to realize the power-on reset of the processor 10, the main code memory 20 and the backup code memory 30. When the fourth pin 2A of the AND gate chip 90 is input with a low level and the fifth pin 2B is input with a high level, the sixth pin 2Y of the AND gate chip 90 outputs a low level. When the ninth pin 3A of the AND gate chip 90 is input with a high level and the tenth pin 3B is input with a high level, the eighth pin 3Y of the AND gate chip 90 outputs a high level. At this time, the first pin 1Y of the D flip-flop 100 is reset. The input is low level and the fourth pin According to Table 3, the fifth pin 1Q of the D flip-flop 100 outputs a low level and the sixth pin Output high level, at this time, the first pin 1A of the OR gate chip 110 is input with low level and the fourth pin 2A is input with high level. According to Table 4, when the first pin 1A of the OR gate chip 110 is input with low level and the second pin 1B is input with low level, the third pin 1Y of the OR gate chip 110 outputs low level, and when the fourth pin 2A of the OR gate chip 110 is input with high level and the fifth pin 2B is input with low level, the sixth pin 2Y of the OR gate chip 110 outputs high level, and at this time, the processor 10 loads the program from the main code memory 20.

[0047] Reference Figure 2 , Figure 3 and Figure 5 , when the main-standby code memory switching circuit is powered on for a predetermined time, for example, when the main-standby code memory switching circuit is powered on for 250ms, the power-on reset unit 80 outputs a high level. Since the second pin 1Y and the third pin 2A of the inverter 70 are connected to each other, after being inverted and shaped by the inverter 70, the fourth pin 2Y of the inverter 70 is higher than the low level. At this time, the first pin 1A and the fourth pin 2A of the AND gate chip 90 are input with a high level. According to Table 2, when the first pin 1A and the second pin 1B of the AND gate chip 90 are input with a high level, the third pin 1Y of the AND gate chip 90 outputs a high level. At this time, the processor 10, the main code memory 20 and the standby code memory 30 are no longer reset. When the fourth pin 2A of the AND gate chip 90 is input with a high level and the fifth pin 2B is input with a high level, the sixth pin 2Y of the AND gate chip 90 outputs a high level. At this time, the first pin 1A of the D flip-flop 100 is reset. According to Table 3, the first pin of the D flip-flop 100 is The input high level and the fourth pin When a high level is input, the fifth pin 1Q and the sixth pin of the D flip-flop 100 Keep the last output unchanged, that is, the fifth pin 1Q of the D flip-flop 100 outputs a low level and the sixth pin Outputs a high level, at this time the processor 10 is still loading the program from the main code memory 20.

[0048] Reference Figure 2 , Figure 3 and Figure 6, when the main-standby code memory switching circuit is powered on for 1s and the dog is fed, the dog feeding signal output pin WDI_OUT of the processor 10 outputs a high pulse to clear the counter 40. At this time, the counting time of the counter 40 does not reach the set counting time T, so that the third pin Q14 of the counter 40 still outputs a low level to realize the watchdog function. In this case, the processor 10 always loads the program from the main code memory 20. It can be understood that as long as the dog feeding signal output pin WDI_OUT of the processor 10 outputs a high pulse in each cycle with a time interval of 1.2s, the counter 40 can be cleared to ensure that the counting time T of the counter 40 does not reach the set counting time T in each cycle.

[0049] Reference Figure 2 , Figure 3 and Figure 7 , in the dog feeding condition, the processor 10 can autonomously switch from loading the program from the main code memory 20 to loading the program from the backup code memory 30. Specifically, the main selection switch pin SW_M of the processor 10 keeps outputting a high level, and the backup switch pin SW_S of the processor 10 switches to outputting a low level. At this time, the fifth pin 2B of the AND gate chip 90 is input with a high level and the tenth pin 3B is input with a low level. According to Table 2, when the fourth pin 2A of the AND gate chip 90 is input with a high level and the fifth pin 2B is input with a high level, the sixth pin 2Y of the AND gate chip 90 outputs a high level, and when the ninth pin 3A of the AND gate chip 90 is input with a high level and the tenth pin 3B is input with a low level, the eighth pin 3Y of the AND gate chip 90 outputs a low level. At this time, the first pin 2B of the D flip-flop 100 is input with a high level and the fifth pin 2B is input with a high level. The input high level and the fourth pin According to Table 3, the fifth pin 1Q of the D flip-flop 100 outputs a high level and the sixth pin Output low level, at this time, the first pin 1A of the OR gate chip 110 is input with high level and the fourth pin 2A is input with low level. According to Table 4, when the first pin 1A of the OR gate chip 110 is input with high level and the second pin 1B is input with low level, the third pin 1Y of the OR gate chip 110 outputs high level, and when the fourth pin 2A of the OR gate chip 110 is input with low level and the fifth pin 2B is input with low level, the sixth pin 2Y of the OR gate chip 110 outputs low level, and at this time, the processor 10 switches from loading the program from the main code memory 20 to loading the program from the backup code memory 30.

[0050] Reference Figure 2 , Figure 3 and Figure 8, in the dog feeding condition, the processor 10 can autonomously switch from loading the program from the backup code memory 30 to loading the program from the main code memory 20. Specifically, the main selection switch pin SW_M of the processor 10 is switched to output a low level, and the backup switch pin SW_S of the processor 10 keeps outputting a high level. At this time, the fifth pin 2B of the AND gate chip 90 is input with a low level and the tenth pin 3B is input with a high level. According to Table 2, when the fourth pin 2A of the AND gate chip 90 is input with a high level and the fifth pin 2B is input with a low level, the sixth pin 2Y of the AND gate chip 90 outputs a low level, and when the ninth pin 3A of the AND gate chip 90 is input with a high level and the tenth pin 3B is input with a high level, the eighth pin 3Y of the AND gate chip 90 outputs a high level. At this time, the first pin 2B of the D flip-flop 100 is input with a high level and the fifth pin 2B is input with a low level. The input is low level and the fourth pin According to Table 3, the fifth pin 1Q of the D flip-flop 100 outputs a low level and the sixth pin Output high level, at this time, the first pin 1A of the OR gate chip 110 is input with low level and the fourth pin 2A is input with high level. According to Table 4, when the first pin 1A of the OR gate chip 110 is input with low level and the second pin 1B is input with low level, the third pin 1Y of the OR gate chip 110 outputs low level, and when the fourth pin 2A of the OR gate chip 110 is input with high level and the fifth pin 2B is input with low level, the sixth pin 2Y of the OR gate chip 110 outputs high level, and at this time, the processor 10 switches from loading the program from the standby code memory 30 to loading the program from the main code memory 20.

[0051] Reference Figure 2 , Figure 3 and Fig. 9, when the processor 10 loads a program abnormally from the main code memory 20, for example, when the main code memory 20 is damaged and cannot be started due to too many read and write times or other reasons, or the code runs incorrectly due to environmental problems, the dog feeding signal output pin WDI_OUT of the processor 10 cannot output a high pulse to the twelfth pin MR of the counter 40 in a time period, resulting in failure to feed the dog. At this time, the counter 40 reaches the set counting time T, causing the third pin Q14 of the counter 40 to output a high level, and the thirteenth pin 6A of the inverter 70 is input with a high level. According to Table 1, after being inverted by the inverter 70, the twelfth pin 6Y of the inverter 70 outputs a low level, and at this time, the second pin 1B and the ninth pin 3A of the AND gate chip 90 are input with a low level. According to Table 2, when the first pin 1A of the AND gate chip 90 is input with a low level and the second pin 1B is input with a high level, the third pin 1Y of the AND gate chip 90 outputs a low level to realize the power-on reset of the processor 10, the main code memory 20 and the backup code memory 30. When the fourth pin 2A of the AND gate chip 90 is input with a high level and the fifth pin 2B is input with a high level, the sixth pin 2Y of the AND gate chip 90 outputs a high level. At this time, the first pin 1A of the D flip-flop 100 is input with a high level. When a high level is input to the ninth pin 3A of the AND gate chip 90 and a high level is input to the tenth pin 3B, the eighth pin 3Y of the AND gate chip 90 outputs a low level. At this time, the fourth pin of the D flip-flop 100 is According to Table 3, the first pin of the D flip-flop 100 is The input high level and the fourth pin When a low level is input, the fifth pin 1Q of the D flip-flop 100 outputs a high level and the sixth pin Output low level, at this time, the first pin 1A of the OR gate chip 110 is input with high level and the fourth pin 2A is input with low level. According to Table 4, when the first pin 1A of the OR gate chip 110 is input with high level and the second pin 1B is input with low level, the third pin 1Y of the OR gate chip 110 outputs high level, and when the fourth pin 2A of the OR gate chip 110 is input with low level and the fifth pin 2B is input with low level, the sixth pin 2Y of the OR gate chip 110 outputs low level, and at this time, the processor 10 switches to load the program from the standby code memory 30.

[0052] In addition, when the main-standby code memory switching circuit is powered on, the processor 10 can read the code. According to the identifier in the code, the processor 10 can identify whether the read code is stored in the main code memory 20 or in the standby code memory 30. If the processor 10 identifies that the read code is stored in the main code memory 20, the processor 10 reads the code in the standby code memory 30 by switching the main selection switch pin SW_M and the standby switch pin SW_S to output different levels, and compares the code read from the main code memory 20 with the code read from the standby code memory 30. If the result of the comparison of the processor 10 is that the code stored in the main code memory 20 is inconsistent with the code stored in the standby code memory 30, the standby code memory 30 is refreshed, and the code in the main code memory 20 is copied to the standby code memory 30, allowing the code stored in the standby code memory 30 to be consistent with the code stored in the main code memory 20. Next, the processor 10 disconnects the dog feeding signal, so that the processor 10 loads the program in the standby code memory 30. If the processor 10 cannot load the program in the standby code memory 30, the main standby code memory switching circuit is powered on again (powered on again after power failure) or the switch 120 is manually operated to reset the main standby code memory switching circuit, and / or an alarm is issued to notify the maintenance personnel to inspect whether the standby code memory 30 is damaged. Preferably, after the above situation occurs N times (for example, N=2), the processor 10 is allowed to always load the program from the main code memory 20, and the refresh action of the standby code memory 30 is stopped. For example, after the above situation occurs N times (for example, N=2), the main standby code memory switching circuit allows manual control of the processor 10 to always load the program from the main code memory 20, and stop the refresh action of the standby code memory 30. For another example, after the above situation occurs N times, the processor 10 always loads the program from the main code memory 20 when executing the program, and stops refreshing the backup code memory 30 .

[0053] When the main-standby code memory switching circuit is powered on, the processor 10 can read the code. According to the identifier in the code, the processor 10 can identify whether the read code is stored in the main code memory 20 or in the standby code memory 30. If the processor 10 identifies that the read code is stored in the standby code memory 30, the processor 10 reads the code in the main code memory 20 by switching the main selection switch pin SW_M and the standby switch pin SW_S to output different levels, and compares the code read from the main code memory 20 with the code read from the standby code memory 30. If the result of the comparison of the processor 10 is that the code stored in the main code memory 20 and the code stored in the standby code memory 30 are inconsistent, the main code memory 20 is refreshed, and the code in the standby code memory 30 is copied to the main code memory 20. Next, the main-standby code memory switching circuit is powered on again (powered on again after power failure) or reset through the switch 120. At this time, the processor 10 reads the code again. According to the identifier in the code, if the processor 10 recognizes that the read code is stored in the main code memory 20, the program is run. If the processor 10 still recognizes that the read code is stored in the standby code memory 30, an alarm is issued to notify the maintenance personnel to inspect whether the main code memory 20 is damaged. It can be understood that in order to reduce the probability of false alarms of the main-standby code memory switching circuit, the main code memory 20 can be refreshed more than twice.

[0054] According to one aspect of the present invention, the present invention provides the main-standby code memory switching circuit, which includes the processor 10, the main code memory 20, the standby code memory 30, the OR gate chip 110 and the D flip-flop 100, wherein the fifth pin 1Q and the sixth pin 1Q of the D flip-flop 100 are connected to the main code memory 20, the standby code memory 30, the OR gate chip 110 and the D flip-flop 100. The first pin 1A and the fourth pin 2A of the OR gate chip 110 are respectively connected, the third pin 1Y and the sixth pin 2Y of the OR gate chip 110 are respectively connected to the main code memory 20 and the backup code memory 30, the chip select pin EMIF_CS of the processor 10 is respectively connected to the second pin 1B and the fifth pin 2B of the OR gate chip 110, and the processor 10 is respectively connected to the main code memory 20 and the backup code memory 30, wherein: when the fifth pin 1Q of the D flip-flop 100 outputs a low level and the sixth pin 1Y is connected to the main code memory 20 and the backup code memory 30, When the output is high, the first pin 1A of the OR gate chip 110 is input with a low level and the fourth pin 2A is input with a high level, the chip select pin EMIF_CS of the processor 10 outputs a low level so that the second pin 1B and the fifth pin 2B of the OR gate chip 110 are respectively input with a low level, at this time, the third pin 1Y of the OR gate chip 110 outputs a low level and the sixth pin 2Y outputs a high level, and the processor 10 loads the program from the main code memory 20; when the fifth pin 1Q of the D flip-flop 100 outputs a high level and the sixth pin 2Y outputs a high level, the processor 10 loads the program from the main code memory 20; When outputting a low level, the first pin 1A of the OR gate chip 110 is input with a high level and the fourth pin 2A is output with a low level, and the chip select pin EMIF_CS of the processor 10 outputs a low level so that the second pin 1B and the fifth pin 2B of the OR gate chip 110 are respectively input with a low level. At this time, the third pin 1Y of the OR gate chip 110 outputs a high level and the sixth pin 2Y outputs a low level, and the processor 10 loads the program from the backup code memory 30.

[0055] In the above manner, when the processor 10 cannot load a program from the main code memory 20, for example, when the main code memory 20 is damaged due to too many read and write times or other reasons and cannot be started, or when a code running error occurs due to environmental problems and the processor 10 cannot load a program from the main code memory 20, the processor 10 can automatically load a program from the backup code memory 30 to achieve automatic restart of the main-backup code memory switching circuit, so as to achieve self-recovery and unattended equipment. In this way, the main-backup code memory switching circuit of the present invention has higher reliability and stability.

[0056] Furthermore, the main-standby code memory switching circuit further includes the AND gate chip 90, the main selection switch pin SW_M and the standby switch pin SW_S of the processor 10 are respectively connected to the fifth pin 2B and the tenth pin 3B of the AND gate chip 90, and the sixth pin 2Y and the eighth pin 3Y of the AND gate chip 90 are respectively connected to the first pin 1 of the D flip-flop 100. and the fourth pin , wherein: the main selection switch pin SW_M and the alternative switch pin SW_S of the processor 10 respectively input a high level to the fifth pin 2B and the tenth pin 3B of the AND gate chip 90, when the fourth pin 2A of the AND gate chip 90 is input with a low level and the ninth pin 3A is input with a high level, the sixth pin 2Y of the AND gate chip 90 outputs a low level and the eighth pin 3Y outputs a high level, and the first pin of the D flip-flop 100 The input is low level and the fourth pin A high level is input, and at this time the fifth pin 1Q of the D flip-flop 100 outputs a low level and the sixth pin Output high level; when the fourth pin 2A of the AND gate chip 90 is input with high level and the ninth pin 3A is input with low level, the sixth pin 2Y of the AND gate chip 90 outputs high level and the eighth pin 3Y outputs low level, the first pin of the D flip-flop 100 The input high level and the fourth pin A low level is input, and at this time the fifth pin 1Q of the D flip-flop 100 outputs a high level and the sixth pin Output low level.

[0057] By setting the AND gate chip 90, the processor 10 can selectively access the main code memory 20 and the standby code memory 30 in the process of normally loading a program from the main code memory 20 by means of the main selection switch pin SW_M and the standby switch pin SW_S outputting different levels. For example, when the main selection switch pin SW_M of the processor 10 outputs a high level and the standby switch pin SW_S outputs a low level, the processor 10 switches from loading a program from the main code memory 20 to loading a program from the standby code memory 30. When the main selection switch pin SW_M of the processor 10 outputs a high level and the standby switch pin SW_S outputs a low level, the processor 10 switches from loading a program from the main code memory 20 to loading a program from the standby code memory 30. When the switch pin SW_M outputs a low level and the alternative switch pin SW_S outputs a high level, the processor 10 switches from loading the program from the backup code memory 30 to loading the program from the main code memory 20, so that the processor 10 selectively accesses the main code memory 20 and the backup code memory 30. In this way, the main-backup code memory switching circuit can detect and / or update the code stored in the main code memory 20 and the backup code memory 30, and can also detect whether the hardware of the main code memory 20 and the backup code memory 30 is damaged.

[0058] According to another aspect of the present invention, the present invention further provides a method for switching between a primary and a standby code memory, wherein the switching method comprises the following steps: S1, the first pin 1A and the fourth pin 2A of the OR gate chip 110 are respectively connected to the fifth pin 1Q and the sixth pin 1Q of the D flip-flop 100. When the processor 10 inputs a low level and a high level, and the second pin 1B and the fifth pin 2B of the OR gate chip 110 are respectively input with a low level, the third pin 1Y of the OR gate chip 110 connected to the main code memory 20 is allowed to output a low level and the sixth pin 2Y connected to the backup code memory 30 is allowed to output a high level, so that the processor 10 loads a program from the main code memory 20; S2, the first pin 1A and the fourth pin 2A of the OR gate chip 110 are respectively connected to the fifth pin 1Q and the sixth pin 1Q of the D flip-flop 100. When a high level and a low level are input and the second pin 1B and the fifth pin 2B of the OR gate chip 110 are respectively input with a low level by the processor 10, the third pin 1Y of the OR gate chip 110 connected to the main code memory 20 is allowed to output a high level and the sixth pin 2Y connected to the backup code memory 30 is allowed to output a low level, so that the processor 10 can load a program from the backup code memory 30.

[0059] Preferably, a high level is input to the fourth pin 2A and the fifth pin 2B of the AND gate chip 90 to allow the sixth pin 2Y of the AND gate chip 90 to connect to the first pin of the D flip-flop 100. Output high level, at this time, the fifth pin 1Q of the D flip-flop 100 outputs high level to the first pin 1A of the OR gate chip 110, and inputs high level to the ninth pin 3A and the tenth pin 3B of the AND gate chip 90, so as to allow the eighth pin 3Y of the AND gate chip 90 to output high level to the fourth pin 1A of the D flip-flop 100. Input low level, at this time the sixth pin of the D flip-flop 100 A low level is input to the fourth pin 2A of the OR gate chip 110 to enable the processor 10 to switch from loading a program from the main code memory 20 to loading a program from the backup code memory 30 .

[0060] Preferably, a high level is input to the fourth pin 2A of the AND gate chip 90 and a low level is input to the fifth pin 2B to allow the sixth pin 2Y of the AND gate chip 90 to connect to the first pin of the D flip-flop 100. Output low level, at this time, the fifth pin 1Q of the D flip-flop 100 outputs low level to the first pin 1A of the OR gate chip 110, and inputs high level to the ninth pin 3A and the tenth pin 3B of the AND gate chip 90, so as to allow the eighth pin 3Y of the AND gate chip 90 to output high level to the fourth pin 1A of the D flip-flop 100. Input high level, at this time the sixth pin of the D flip-flop 100 A high level is input to the fourth pin 2A of the OR gate chip 110 to enable the processor 10 to switch from loading a program from the backup code memory 30 to loading a program from the main code memory 20 .

[0061] It should be understood by those skilled in the art that the embodiments of the present invention described above and shown in the accompanying drawings are only examples and do not limit the present invention. The purpose of the present invention has been fully and effectively achieved. The functional and structural principles of the present invention have been demonstrated and explained in the embodiments, and the embodiments of the present invention may be deformed or modified in any way without departing from the principles.

Claims

1. A method for switching between a primary and a standby code memory, characterized in that: The switching method comprises the following steps: S1, allowing the third pin of the OR gate chip connected to the main code memory to output a low level and the sixth pin connected to the backup code memory to output a high level, so that the processor can load a program from the main code memory; S2, allowing the third pin of the OR gate chip to output a high level and the sixth pin to output a low level, so that the processor can load a program from the backup code memory.

2. The switching method according to claim 1, wherein in the step S1, when the first pin and the fourth pin of the OR gate chip are respectively input with a low level and a high level by the fifth pin and the sixth pin of the D flip-flop, and the second pin and the fifth pin of the OR gate chip are respectively input with a low level by the processor, the third pin of the OR gate chip is allowed to output a low level and the sixth pin is allowed to output a high level; wherein in the step S2, when the first pin and the fourth pin of the OR gate chip are respectively input with a high level and a low level by the fifth pin and the sixth pin of the D flip-flop, and the second pin and the fifth pin of the OR gate chip are respectively input with a low level by the processor, the third pin of the OR gate chip is allowed to output a high level and the sixth pin is allowed to output a low level.

3. The switching method according to claim 2, wherein in the above method, a high level is input to the fourth pin and the fifth pin of the AND gate chip to allow the sixth pin of the AND gate chip to output a high level to the first pin of the D flip-flop, and at this time, the fifth pin of the D flip-flop outputs a high level to the first pin of the OR gate chip, and a high level is input to the ninth pin and the tenth pin of the AND gate chip to allow the eighth pin of the AND gate chip to input a low level to the fourth pin of the D flip-flop, and at this time, the sixth pin of the D flip-flop inputs a low level to the fourth pin of the OR gate chip, so that the processor switches from loading the program from the main code memory to loading the program from the backup code memory.

4. The switching method according to claim 2, wherein in the above method, a high level is input to the fourth pin of the AND gate chip and a low level is input to the fifth pin to allow the sixth pin of the AND gate chip to output a low level to the first pin of the D flip-flop, and at this time, the fifth pin of the D flip-flop outputs a low level to the first pin of the OR gate chip, and a high level is input to the ninth pin of the AND gate chip and a low level is input to the tenth pin to allow the eighth pin of the AND gate chip to input a high level to the fourth pin of the D flip-flop, and at this time, the sixth pin of the D flip-flop inputs a high level to the fourth pin of the OR gate chip, so that the processor switches from loading the program from the backup code memory to loading the program from the main code memory.

5. The switching method according to claim 3, wherein in the above method, the main selection switch pin of the processor keeps outputting a high level, and the alternative switch pin of the processor is switched to outputting a low level. At this time, the fifth pin of the AND gate chip is input with a high level and the tenth pin is input with a low level, so that the sixth pin of the AND gate chip outputs a high level and the eighth pin outputs a low level.

6. The switching method according to claim 4, wherein in the above method, the main selection switch of the processor is switched to output a low level, and the alternative switch pin of the processor keeps outputting a low level. At this time, the fifth pin of the AND gate chip is input with a low level and the tenth pin is input with a high level, so that the sixth pin of the AND gate chip outputs a low level and the eighth pin outputs a high level.

7. The switching method according to claim 5, wherein in the above method, when the dog feeding signal output pin of the processor cannot output a high pulse to the twelfth pin of the counter within a time period, resulting in failure to feed the dog, the counter reaches a set counting time and causes the third pin of the counter to output a high level, the thirteenth pin of the inverter is input with a high level, and after being reversed by the inverter, the twelfth pin of the inverter outputs a low level, at this time, the second pin and the ninth pin of the AND gate chip are input with a low level, when the first pin of the AND gate chip is input with a low level and the second pin is input with a high level, the third pin of the AND gate chip outputs a low level, and the power-on reset of the processor, the main code memory and the backup code memory is realized, and when the fourth pin of the AND gate chip is input with a high level and the fifth pin is input with a high level, the sixth pin of the AND gate chip outputs a high level. level, at this time, the first pin of the D trigger is input with a high level, when the ninth pin of the AND gate chip is input with a low level and the tenth pin is input with a high level, the eighth pin of the AND gate chip outputs a low level, at this time, the fourth pin of the D trigger is input with a low level, when the first pin of the D trigger is input with a high level and the fourth pin is input with a low level, the fifth pin of the D trigger outputs a high level and the sixth pin outputs a low level, at this time, the first pin of the OR gate chip is input with a high level and the fourth pin is input with a low level, when the first pin of the OR gate chip is input with a high level and the second pin is input with a low level, the third pin of the OR gate chip outputs a high level, when the fourth pin of the OR gate chip is input with a low level and the fifth pin is input with a low level, the sixth pin of the OR gate chip outputs a low level, and at this time, the processor switches to loading the program from the standby code memory.

8. The switching method according to any one of claims 1 to 7, wherein the switching method further comprises the step of: upon power-on, the processor identifies the location where the read code is stored according to an identifier in the read code; if the processor identifies that the read code is stored in the main code memory, the processor reads the code in the standby code memory by switching the main selection switch pin and the standby switch pin to output different levels, and compares the code read from the main code memory with the code read from the standby code memory; if the result of the comparison by the processor is that the code stored in the main code memory is inconsistent with the code stored in the standby code memory , then refresh the spare code memory and copy the code in the main code memory to the spare code memory. If the processor recognizes that the read code is stored in the spare code memory, the processor reads the code in the main code memory by switching the main selection switch pin and the spare switch pin to output different levels, and compares the code read from the main code memory with the code read from the spare code memory. If the result of the comparison by the processor is that the code stored in the main code memory and the code stored in the spare code memory are inconsistent, refresh the main code memory and copy the code in the spare code memory to the main code memory.

9. A main-standby code memory switching circuit, characterized in that: include: Main code memory; Backup code memory; A processor, wherein the processor has a chip selection pin, wherein the main code memory and the backup code memory are respectively connected to the processor; An OR gate chip, wherein the OR gate chip has a first pin, a second pin, a third pin, a fourth pin, a fifth pin and a sixth pin, the third pin of the OR gate chip is connected to the main code memory, the sixth pin of the OR gate chip is connected to the backup code memory, and the second pin and the fifth pin of the OR gate chip are respectively connected to the chip select pin of the processor; A D flip-flop, wherein the D flip-flop has a fifth pin and a sixth pin, the fifth pin of the D flip-flop is connected to the first pin of the OR gate chip, and the sixth pin of the D flip-flop is connected to the fourth pin of the OR gate chip.

10. The main-standby code memory switching circuit according to claim 9, wherein the main-standby code memory switching circuit further comprises an AND gate chip, a counter, an oscillator and an inverter with a Schmitt trigger function, wherein the processor has a main selection switch pin, an alternative switch pin and a dog feeding signal output pin, and the D flip-flop has a first pin and a fourth pin, wherein the AND gate chip has a second pin, a third pin, a fifth pin, a sixth pin, an eighth pin, a ninth pin and a tenth pin, the fifth pin of the AND gate chip is connected to the main selection switch pin of the processor, the tenth pin of the AND gate chip is connected to the alternative switch pin of the processor, and the sixth pin of the AND gate chip is connected to the The first pin, the eighth pin of the AND gate chip is connected to the fourth pin of the D flip-flop; wherein the counter has a third pin, a ninth pin, a tenth pin, an eleventh pin and a twelfth pin, the inverter has a twelfth pin and a thirteenth pin, the twelfth pin of the counter is connected to the dog feeding signal output signal of the processor, the third pin of the counter is connected to the thirteenth pin of the inverter, the oscillator is connected to the ninth pin, the tenth pin and the eleventh pin of the counter, the twelfth pin of the inverter is connected to the second pin and the ninth pin of the AND gate chip, and the third pin of the AND gate chip is respectively connected to the main code memory, the backup code memory and the processor.