Power switching circuit and microcontroller

By using an analog circuit structure with a dual threshold voltage comparison mechanism, the problem of frequent switching caused by response delay and voltage fluctuation in existing power switching schemes is solved, achieving fast and reliable power switching and ensuring system stability.

CN121546783APending Publication Date: 2026-02-17GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511533414.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-24
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing power switching solutions are difficult to cope with sudden drops or instantaneous drops in main power supply voltage due to large delays in software interrupt response and digital control logic, which can lead to system power outages or abnormal restarts. In addition, hardware switching circuits are prone to frequent switching oscillations when voltage fluctuates.

Method used

The analog circuit structure employs a dual-threshold voltage comparison mechanism. It detects the upper and lower limits of the power supply voltage through a voltage detection module and a comparator module, and uses a hysteresis comparison mechanism to achieve fast power switching without CPU intervention, thus avoiding frequent switching caused by voltage fluctuations.

Benefits of technology

It achieves fast, reliable, and seamless power switching, reduces switching latency and power consumption, prevents power oscillations, and ensures stable system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121546783A_ABST
    Figure CN121546783A_ABST
Patent Text Reader

Abstract

The invention discloses a power supply switching circuit and a microcontroller, the power supply switching circuit comprises a first power supply, a second power supply, a voltage detection module, a comparator module and a switching module, the comparator module is used for receiving a first voltage or a second voltage and comparing the first voltage or the second voltage with a reference voltage; the switching module is respectively connected with the first power supply and the second power supply, and is used for controlling the first power supply or the second power supply to supply power according to the comparison signal. According to the embodiment of the invention, the first voltage or the second voltage is compared with the reference voltage, and the first power supply or the second power supply is controlled to supply power according to the comparison signal. The power supply is switched through the dual-threshold voltage comparison mechanism, the switching realized by the analog circuit structure does not need CPU intervention and digital control, the response speed is high, and the switching delay is remarkably reduced, so that efficient and reliable seamless power supply switching is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of chip technology, specifically relating to a power switching circuit and a microcontroller. Background Technology

[0002] In the power supply system of electronic devices, power switching technology is a key component to ensure the continuous and stable operation of the system. Most existing power switching solutions employ digital control logic or rely on a central processing unit (CPU) to implement the switching through software programs. Specifically, the system periodically collects the voltage signals of the main power supply and the backup power supply through an analog-to-digital converter (ADC), which is then judged by the processor and executes the corresponding switching logic to control the switching circuit to complete the power switching.

[0003] However, this type of solution involves software interrupt response, data processing and control command execution, which results in large response delays and high power consumption. It is difficult to cope with emergencies such as sudden drops or instantaneous drops in main power supply voltage, which can easily lead to system power outages or abnormal restarts. Summary of the Invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a power switching circuit and microcontroller that overcomes or at least partially solves the above problems.

[0005] In a first aspect, embodiments of the present invention provide a power switching circuit, the power switching circuit including a first power supply, a second power supply, a voltage detection module, a comparator module, and a switching module; The voltage detection module is connected to the first power supply and the comparator module respectively; it is used to detect a first voltage and a second voltage based on the voltage of the first power supply; the ratio of the first voltage to the voltage of the first power supply is a first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply is a second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio. The comparator module is connected to the voltage detection module and the switching module respectively; it is used to receive the first voltage or the second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module, and select to receive the first voltage or the second voltage based on the comparison signal. The switching module is connected to the first power supply and the second power supply respectively, and is used to control whether to supply power through the first power supply or the second power supply according to the comparison signal.

[0006] Optionally, when the comparison signal indicates that the first voltage is greater than the reference voltage, or the second voltage is greater than the reference voltage, the switching module controls the power supply to be supplied through the first power source; When the comparison signal indicates that the first voltage is less than or equal to the reference voltage, or the second voltage becomes less than or equal to the reference voltage, the switching module controls the power supply to be supplied through the second power source.

[0007] Optionally, the comparator module includes a multiplexer and a comparator; The multiplexer is connected to the voltage detection module and the comparator, and is used to select to receive the first voltage or the second voltage based on the comparison signal, and to send the first voltage or the second voltage to the comparator. The comparator is connected to the switching module and is used to compare the first voltage or the second voltage with a reference voltage and send a comparison signal to the switching module. When the comparison signal indicates that the first voltage is greater than the reference voltage or the second voltage is greater than the reference voltage, the comparison signal is at a first level. When the comparison signal indicates that the first voltage is less than or equal to the reference voltage or the second voltage becomes less than or equal to the reference voltage, the comparison signal is at a second level.

[0008] Optionally, the voltage detection module includes a first resistor, a second resistor, and a third resistor connected in series. One end of the first resistor is grounded, and one end of the third resistor is connected to the first power supply. The first voltage is the voltage of a first node, which is located between the first resistor and the second resistor. The second voltage is the voltage of a second node, which is located between the second resistor and the third resistor.

[0009] Optionally, the first input terminal of the multiplexer is connected to the first node; the second input terminal of the multiplexer is connected to the second node; and the enable terminal of the multiplexer is connected to the output terminal of the comparator. When the comparison signal is at the second level, the multiplexer selects to receive the first voltage and sends the first voltage to the comparator; when the comparison signal is at the first level, the multiplexer selects to receive the second voltage and sends the second voltage to the comparator.

[0010] Optionally, the first input terminal of the comparator is connected to the output terminal of the multiplexer, and the second input terminal of the comparator is connected to the reference circuit; When the comparison signal is at the second level, the multiplexer selects to receive the first voltage and sends the first voltage to the comparator. The comparator compares the first voltage with the reference voltage sent by the reference circuit. If the first voltage is less than or equal to the reference voltage, the comparison signal remains at the second level. If the first voltage is greater than the reference voltage, the comparison signal changes to the first level. When the comparison signal is at the first level, the multiplexer selects to receive the second voltage and sends the second voltage to the comparator. The comparator compares the second voltage with the reference voltage. If the second voltage is greater than the reference voltage, the comparison signal remains at the first level. If the second voltage is less than or equal to the reference voltage, the comparison signal changes to the second level.

[0011] Optionally, the switching module includes a first switching transistor, a second switching transistor, and a switching control module; The input terminal of the first switching transistor is connected to the first power supply; The input terminal of the second switching transistor is connected to the second power supply; the output terminal of the second switching transistor is connected to the output terminal of the first switching transistor; the power output node is located between the output terminal of the second switching transistor and the output terminal of the first switching transistor. One end of the switch control module is connected to the comparator, and the other end is connected to the control terminals of the first switch and the second switch, respectively. It is used to send switch control signals to the control terminals of the first switch and the second switch according to the comparison signal, so as to control the working state of the first switch and the second switch, so that the power output node is powered by the first power supply or the power output node is powered by the second power supply.

[0012] Optionally, when the comparison signal is at the first level, the switch control module sends a switch control signal at the second level to the control terminal of the first switch transistor, the first switch transistor is turned on, and the switch control module sends a switch control signal at the second level to the control terminal of the second switch transistor, the second switch transistor is turned off, and the power output node is powered by the first power supply. When the comparison signal is at the second level, the switch control module sends a switch control signal at the first level to the control terminal of the first switch transistor, the first switch transistor is turned off, and the switch control module sends a switch control signal at the first level to the control terminal of the second switch transistor, the second switch transistor is turned on, and the power output node is powered by the second power supply.

[0013] Optionally, the switch control module includes a first inverter, a second inverter, a first NAND gate, and a second NAND gate; The input terminal of the first inverter is connected to the output terminal of the comparator; The input terminal of the second inverter is connected to the output terminal of the first inverter; The first input terminal of the first NAND gate is connected to the output terminal of the second inverter; the second input terminal of the first NAND gate is connected to the output terminal of the second NAND gate; the output terminal of the first NAND gate is connected to the control terminal of the first switching transistor. The first input terminal of the second NAND gate is connected to the output terminal of the first NAND gate; the second input terminal of the second NAND gate is connected between the first inverter and the second inverter; the output terminal of the second NAND gate is connected to the control terminal of the second switching transistor. When the comparison signal is at the second level, the first inverter outputs the first level, the second inverter outputs the second level, the first NAND gate outputs the first level, the first switch is off, the second NAND gate outputs the second level, and the second switch is on; when the comparison signal is at the first level, the first inverter outputs the second level, the second inverter outputs the first level, the first NAND gate outputs the second level, the first switch is on, the second NAND gate outputs the first level, and the second switch is off.

[0014] Secondly, embodiments of the present invention provide a microcontroller, which includes the power switching circuit described above.

[0015] In an embodiment of the present invention, the power switching circuit includes a first power supply, a second power supply, a voltage detection module, a comparator module, and a switching module. The voltage detection module is connected to both the first power supply and the comparator module, and is used to detect a first voltage and a second voltage based on the voltage of the first power supply. The ratio of the first voltage to the voltage of the first power supply is a first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply is a second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio. The comparator module is connected to both the voltage detection module and the switching module, and is used to receive either the first voltage or the second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module, and select to receive either the first voltage or the second voltage based on the comparison signal. The switching module is connected to both the first power supply and the second power supply, and is used to control power supply via the first power supply or the second power supply according to the comparison signal. This embodiment of the present invention compares the first voltage or the second voltage with a reference voltage and controls power supply via the first power supply or the second power supply according to the comparison signal. By switching the power supply through this dual-threshold voltage comparison mechanism, this analog circuit structure achieves switching without CPU intervention or digital control, with a fast response speed and significantly reduced switching latency, thereby realizing efficient, reliable, and seamless power switching.

[0016] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0017] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a schematic diagram of the structure of a power switching circuit according to an embodiment of the present invention; Figure 2 This is a schematic diagram of another power switching circuit according to an embodiment of the present invention.

[0018] Reference numerals: First power supply 10, Second power supply 11, Voltage detection module 12, First resistor 121, Second resistor 122, Third resistor 123, Comparator module 13, Multiplexer 131, Comparator 132, Reference circuit 1321, Switching module 14, First switching transistor 141, Second switching transistor 142, Switch control module 143, First inverter 1431, Second inverter 1432, First NAND gate 1433, Second NAND gate 1434, First node 20, Second node 21, Enable terminal 22, Power output node 23. Detailed Implementation

[0019] Embodiments of the present invention will now be described in detail. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0020] In the power supply systems of electronic devices, power switching technology is a crucial element in ensuring the continuous and stable operation of the system. Most existing power switching solutions employ digital control logic or rely on a central processing unit (CPU) implemented through software programs. Specifically, the system periodically collects voltage signals from the main power supply and backup power supply via an analog-to-digital converter (ADC), which the processor then determines and executes the corresponding switching logic to control the switching circuit and complete the power switching. However, this type of solution involves software interrupt response, data processing, and control command execution, resulting in significant response delays and high power consumption. It is ill-suited to handle emergencies such as sudden drops or instantaneous voltage fluctuations in the main power supply, easily leading to system power outages or abnormal restarts.

[0021] On the other hand, while some hardware-implemented power switching circuits use voltage comparators for autonomous detection and switching, avoiding delays caused by software intervention, their voltage judgment mechanisms typically only set a single threshold, lacking hysteresis characteristics or dual-threshold designs. When the input voltage fluctuates frequently around the switching threshold due to load changes or grid fluctuations, the comparator output is prone to multiple flips, causing the power supply to repeatedly switch between the main and backup circuits, resulting in oscillations. This unstable switching behavior not only increases the stress on the power supply path and affects the lifespan of switching devices, but may also cause malfunctions in subsequent circuits, reducing the overall reliability of the system.

[0022] Reference Figure 1 The diagram shows a schematic of a power switching circuit according to an embodiment of the present invention. The power switching circuit includes a first power supply 10, a second power supply 11, a voltage detection module 12, a comparator module 13, and a switching module 14.

[0023] For example, the first power supply 10 is the main power supply VCC, and the second power supply 11 is the backup power supply VBK. The second power supply 11 is activated in time when the first power supply 10 fails or the voltage is lower than the normal operating threshold, so as to continue to provide reliable power supply to the circuit.

[0024] The voltage detection module 12 is connected to the first power supply 10 and the comparator module 13 respectively; it is used to detect a first voltage and a second voltage based on the voltage of the first power supply 10; the ratio of the first voltage to the voltage of the first power supply 10 is the first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply 10 is the second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio.

[0025] The voltage detection module 12 detects the voltage change of the first power supply 10 by dividing the voltage of the first power supply 10, and obtains a first voltage and a second voltage. The ratio of the first voltage to the voltage of the first power supply 10 is the first voltage division ratio, and the ratio of the second voltage to the voltage of the first power supply 10 is the second voltage division ratio. Since the first voltage division ratio is less than the second voltage division ratio, the first voltage is less than the second voltage. The first voltage is used to detect whether the voltage of the first power supply 10 is lower than the falling threshold, and the second voltage is used to detect whether the voltage of the first power supply 10 is higher than the rising threshold. The falling threshold is less than the rising threshold. By using the first voltage and the second voltage obtained, the upper and lower limits of the first power supply 10 are detected using dual threshold voltages, providing a reliable judgment basis for subsequent power switching control.

[0026] The comparator module 13 is connected to the voltage detection module 12 and the switching module 14 respectively; it is used to receive a first voltage or a second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module 14, and select to receive the first voltage or the second voltage based on the comparison signal.

[0027] The comparator module 13 selects to receive a first voltage or a second voltage based on the output comparison signal, compares the received first voltage or second voltage with a reference voltage to obtain a comparison signal, and sends the comparison signal to the switching module 14. By comparing the first voltage with the reference voltage, or comparing the second voltage with the reference voltage, the upper and lower limits of the voltage of the first power supply 10 are detected using a dual threshold voltage comparator based on a hysteresis comparison mechanism, which can effectively prevent frequent switching caused by voltage fluctuations.

[0028] The switching module 14 is connected to the first power supply 10 and the second power supply 11 respectively, and is used to control whether to supply power through the first power supply 10 or the second power supply 11 according to the comparison signal.

[0029] The switching module 14 controls the power supply to be supplied through the first power supply 10 or the second power supply 11 according to the comparison signal. It uses dual threshold voltage to detect the upper and lower limits of the first power supply 10 and switches the power supply according to the detection results. This hysteresis comparison mechanism can prevent frequent switching caused by voltage fluctuations. Furthermore, the use of analog circuit structure can realize automatic power supply switching without CPU intervention.

[0030] In an embodiment of the present invention, the power switching circuit includes a first power supply, a second power supply, a voltage detection module, a comparator module, and a switching module. The voltage detection module is connected to both the first power supply and the comparator module, and is used to detect a first voltage and a second voltage based on the voltage of the first power supply. The ratio of the first voltage to the voltage of the first power supply is a first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply is a second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio. The comparator module is connected to both the voltage detection module and the switching module, and is used to receive the first voltage or the second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module, and select to receive the first voltage or the second voltage based on the comparison signal. The switching module is connected to both the first power supply and the second power supply, and is used to control power supply via the first power supply or the second power supply according to the comparison signal. This embodiment of the present invention compares the first voltage or the second voltage with a reference voltage and controls power supply via the first power supply or the second power supply according to the comparison signal. By switching the power supply through this dual-threshold voltage comparison mechanism, switching oscillations caused by voltage fluctuations can be avoided. Furthermore, the switching process requires no CPU intervention or digital control, has a fast response speed, and significantly reduces switching latency, thereby achieving efficient, reliable, and seamless power switching.

[0031] In this embodiment of the invention, when the comparison signal indicates that the first voltage is greater than the reference voltage, or the second voltage is greater than the reference voltage, the switching module 14 controls the power supply to be supplied through the first power supply 10. When the comparison signal indicates that the first voltage is less than or equal to the reference voltage, or the second voltage becomes less than or equal to the reference voltage, the switching module 14 controls the power supply through the second power supply 11.

[0032] When the voltage of the first power supply 10 is sufficiently low or even zero, and the second power supply 11 outputs a normal voltage, both the first and second voltages are zero. Therefore, both the first and second voltages are less than or equal to the reference voltage. The switching module 14 controls the power supply to be supplied through the second power supply 11, i.e., through the backup power supply VBK. At the same time, the comparator module 13 selects to receive the first voltage, compares the first voltage with the reference voltage, obtains a comparison signal, and sends the comparison signal to the switching module. When the comparison signal indicates that the first voltage is greater than the reference voltage, i.e., the voltage of the first power supply 10 starts to rise and rises to the rise threshold, the switching module 14 controls the power supply to be supplied through the first power supply 10, i.e., switching from the backup power supply VBK to the main power supply VCC. At the same time, the comparator module 13 selects to receive the second voltage, compares the second voltage with the reference voltage, obtains a comparison signal, and sends the comparison signal to the switching module. When the comparison signal indicates that the second voltage is less than or equal to the reference voltage, i.e., the voltage of the normally powered first power supply 10 starts to fall and falls to the fall threshold, the switching module 14 controls the power supply to be supplied through the second power supply 11, i.e., switching from the main power supply VCC to the backup power supply VBK.

[0033] A comparison signal is obtained by comparing a first voltage with a reference voltage, or a second voltage with a reference voltage. When the first voltage is greater than the reference voltage, the control is to supply power through the first power supply 10. When the second voltage is less than or equal to the reference voltage, the control is to supply power through the second power supply 11. By adopting a dual threshold voltage comparison mechanism, the switching to the second power supply 11 is triggered when the voltage of the first power supply 10 is lower than the falling threshold, and the switching back to the first power supply 10 is triggered when it is higher than the rising threshold. This avoids switching oscillations caused by voltage fluctuations. By adopting a pure analog circuit structure, the switching process does not require CPU intervention and digital control, which can achieve fast response and achieve a low-latency and high-reliability power switching effect.

[0034] Reference Figure 2 The diagram shows another power switching circuit according to an embodiment of the present invention. The comparator module 13 includes a multiplexer 131 and a comparator 132. Multiplexer 131 is connected to voltage detection module 12 and comparator 132, and is used to select to receive a first voltage or a second voltage based on comparison signal, and send the first voltage or the second voltage to comparator 132. Comparator 132 is connected to switching module 14 and is used to compare the first voltage or the second voltage with the reference voltage and send a comparison signal to switching module 14. When the comparison signal indicates that the first voltage is greater than the reference voltage or the second voltage is greater than the reference voltage, the comparison signal is at the first level. When the comparison signal indicates that the first voltage is less than or equal to the reference voltage or the second voltage becomes less than or equal to the reference voltage, the comparison signal is at the second level.

[0035] Multiplexer 131 can select one voltage from a first voltage or a second voltage based on a comparison signal and output it to comparator 132. Comparator 132 compares the first voltage or the second voltage output by multiplexer 131 with a reference voltage to obtain a comparison signal and sends the comparison signal to switching module 14. When the first voltage or the second voltage is greater than the reference voltage, the comparison signal is at a first level. When the first voltage or the second voltage is less than or equal to the reference voltage, the comparison signal is at a second level. For example, the first level is a high level and the second level is a low level.

[0036] The multiplexer 131 selects one of the first voltage or the second voltage and outputs it to the comparator 132. The comparator 132 compares the first voltage or the second voltage output by the multiplexer 131 with the reference voltage to obtain a comparison signal. This dual threshold voltage comparison mechanism can realize the upper and lower limit detection of the voltage of the first power supply 10, thereby avoiding switching oscillations caused by voltage fluctuations. In this embodiment of the invention, the voltage detection module 12 includes a first resistor 121, a second resistor 122, and a third resistor 123 connected in series. One end of the first resistor 121 is grounded, and one end of the third resistor 123 is connected to the first power supply 10. The first voltage is the voltage of the first node 20, which is located between the first resistor 121 and the second resistor 122. The second voltage is the voltage of the second node 21, which is located between the second resistor 122 and the third resistor 123.

[0037] The first resistor 121, the second resistor 122, and the third resistor 123 are connected in series between the first power supply 10 and ground, forming a voltage divider network. This network generates a first voltage and a second voltage proportional to the voltage of the first power supply 10. Since one end of the first resistor 121 is grounded and one end of the third resistor 123 is connected to the first power supply 10, the first node 20 is located between the first resistor 121 and the second resistor 122, and the second node 21 is located between the second resistor 122 and the third resistor 123. Therefore, the voltage division ratio of the first voltage at the first node 20 is less than the voltage division ratio of the second voltage at the second node 21. The first voltage is less than the second voltage. The first voltage is used to detect whether the voltage of the first power supply 10 is below a drop threshold, and the second voltage is used to detect whether the voltage of the first power supply 10 is above a rise threshold. By detecting the first and second voltages generated by the voltage divider network, the upper and lower limits of the voltage of the first power supply 10 are detected, thus providing a reliable basis for subsequent power switching.

[0038] In this embodiment of the invention, the first input terminal of the multiplexer 131 is connected to the first node 20; the second input terminal of the multiplexer 131 is connected to the second node 21; and the enable terminal 22 of the multiplexer 131 is connected to the output terminal of the comparator 132. When the comparison signal is at the second level, the multiplexer 131 selects to receive the first voltage and sends the first voltage to the comparator 132; when the comparison signal is at the first level, the multiplexer 131 selects to receive the second voltage and sends the second voltage to the comparator 132.

[0039] The enable terminal 22 of the multiplexer 131 is connected to the output terminal of the comparator 132. When the comparison signal output by the comparator 132 is at the second level, that is, when the comparison signal is at a low level, the multiplexer 131 selects the first input terminal as the input terminal, receives the first voltage, and outputs the first voltage, so that the comparator 132 compares the first voltage with the reference voltage and outputs the comparison signal. When the comparison signal output by the comparator 132 is at the first level, that is, when the comparison signal is at a high level, the multiplexer 131 selects the second input terminal as the input terminal, receives the second voltage, and outputs the second voltage, so that the comparator 132 compares the second voltage with the reference voltage and outputs the comparison signal.

[0040] When the comparison signal is low, on the one hand, the switching module 14 controls the power supply through the second power supply 11, and on the other hand, the multiplexer 131 selects the second voltage as the input voltage so that the comparator 132 compares the second voltage with the reference voltage when the second power supply 11 is powered. If the second voltage is greater than the reference voltage, the comparison signal becomes high, that is, the voltage of the first power supply 10 is greater than the rising threshold. On the other hand, the switching module 14 controls the power supply through the first power supply 10, and the multiplexer 131 selects the first voltage as the input voltage so that the comparator 132 compares the first voltage with the reference voltage when the first power supply 10 is powered. The multiplexer 131 selects the voltage to be sent to the comparator 132 according to the comparison signal of the comparator 132, and the comparator 132 compares it with the reference voltage and outputs a comparison signal. This hysteresis comparison mechanism can realize the upper and lower limit detection of the voltage of the first power supply 10 and avoid switching oscillations caused by voltage fluctuations.

[0041] In this embodiment of the invention, the first input terminal of comparator 132 is connected to the output terminal of multiplexer 131, and the second input terminal of comparator 132 is connected to reference circuit 1321. When the comparison signal is at the second level, the multiplexer 131 selects to receive the first voltage and sends the first voltage to the comparator 132. The comparator 132 compares the first voltage with the reference voltage sent by the reference circuit 1321. If the first voltage is less than or equal to the reference voltage, the comparison signal remains at the second level. If the first voltage is greater than the reference voltage, the comparison signal changes to the first level. When the comparison signal is at the first level, the multiplexer 131 selects to receive the second voltage and sends the second voltage to the comparator 132. The comparator 132 compares the second voltage with the reference voltage. If the second voltage is greater than the reference voltage, the comparison signal remains at the first level. If the second voltage is less than or equal to the reference voltage, the comparison signal changes to the second level.

[0042] For example, the first input terminal of comparator 132 is a positive input terminal, and the second input terminal of comparator 132 is a negative input terminal. When the voltage of the first power supply 10 is sufficiently low or even 0, and the second power supply 11 outputs a normal voltage, the first input terminal of comparator 132 is 0 regardless of whether the input is the first voltage or the second voltage. Therefore, the voltage of the first input terminal of comparator 132 is less than the voltage of the second input terminal, and the comparison signal output by comparator 132 is low. Based on the low-level comparison signal, the switching module 14 controls the power supply to be supplied through the second power supply 11. At the same time, the multiplexer 131 selects to receive the first voltage and outputs the first voltage to the first input terminal of comparator 132. When the first voltage is greater than the reference voltage, the voltage of the first input terminal of comparator 132 is greater than the voltage of the second input terminal, and the comparison signal output by comparator 132 is high. Based on the high-level comparison signal, the switching module 14 controls the power supply to be supplied through the first power supply 10. At the same time, the multiplexer 131 selects to receive the second voltage and outputs the second voltage to the first input terminal of comparator 132. By employing a dual-threshold voltage comparison mechanism, the system triggers a switch to the backup power supply when the main power supply voltage is below the first threshold and switches back to the main power supply when it is above the second threshold. This avoids switching oscillations caused by voltage fluctuations. Furthermore, by using a pure analog circuit structure, the switching process does not require CPU intervention or digital control, enabling a fast response and achieving a low-latency, high-reliability power switching effect.

[0043] In this embodiment of the invention, the switching module 14 includes a first switching transistor 141, a second switching transistor 142, and a switching control module 143; The input terminal of the first switching transistor 141 is connected to the first power supply 10; The input terminal of the second switch transistor 142 is connected to the second power supply 11; the output terminal of the second switch transistor 142 is connected to the output terminal of the first switch transistor 141; the power output node 23 is located between the output terminal of the second switch transistor 142 and the output terminal of the first switch transistor 141. One end of the switch control module 143 is connected to the comparator 132, and the other end is connected to the control terminal of the first switch transistor 141 and the control terminal of the second switch transistor 142 respectively. It is used to send switch control signals to the control terminals of the first switch transistor 141 and the second switch transistor 142 respectively according to the comparison signal, so as to control the working state of the first switch transistor 141 and the second switch transistor 142 respectively, so that the power output node 23 is powered by the first power supply 10 or the power output node 23 is powered by the second power supply 11.

[0044] The first switching transistor 141 is used to control the power supply state of the first power supply 10, and the second switching transistor 142 is used to control the power supply state of the second power supply 11. The switching control module 143 is used to control the conduction state of the first switching transistor 141 and the second switching transistor 142 respectively according to the comparison signal output by the comparator 132, so as to control the power supply state of the first power supply 10 and the power supply state of the second power supply 11 respectively, and realize seamless switching between the main power supply VCC and the backup power supply VBK.

[0045] In this embodiment of the invention, when the comparison signal is at the first level, the switch control module 143 sends a switch control signal at the second level to the control terminal of the first switch tube 141, the first switch tube 141 is turned on, the switch control module 143 sends a switch control signal at the second level to the control terminal of the second switch tube 142, the second switch tube 142 is turned off, and the power output node 23 is powered by the first power supply 10. When the comparison signal is at the second level, the switch control module 143 sends a switch control signal at the first level to the control terminal of the first switch transistor 141, and the first switch transistor 141 is turned off. The switch control module 143 sends a switch control signal at the first level to the control terminal of the second switch transistor 142, and the second switch transistor 142 is turned on. The power output node 23 is powered by the second power supply 11.

[0046] For example, the first switch 141 and the second switch 142 are PMOS (P-channel Metal-Oxide-Semiconductor). The control terminal of the first switch 141 is the gate. When the comparison signal is high, that is, when the second power supply 11 is powered, the voltage of the first power supply 10 starts to rise. When the voltage rises until the first voltage is greater than the reference voltage, the switch control module 143 sends a low-level switch control signal to the control terminal of the first switch 141, and the first switch 141 is turned on. The power output node 23 is powered by the first power supply 10. The switch control module 143 sends a low-level switch control signal to the control terminal of the second switch 142, and the second switch 142 is turned off, shutting off the power supply of the second power supply 11. This realizes the switching to the main power supply voltage when the main power supply voltage is restored.

[0047] When the comparison signal is low, i.e., when the first power supply 10 is powered, the voltage of the first power supply 10 begins to drop. As the voltage drops until the second voltage is lower than the reference voltage, the switch control module 143 sends a high-level switch control signal to the control terminal of the first switch transistor 141, turning off the first switch transistor 141 and shutting off the power supply to the first power supply 10. The switch control module 143 then sends a low-level switch control signal to the control terminal of the second switch transistor 142, turning on the second switch transistor 142. The power output node 23 is then powered by the second power supply 11, thus enabling a switch to backup power supply when the main power supply voltage drops. The switch control module 143 controls the conduction state of the first switch transistor 141 and the second switch transistor 142 according to the comparison signal, thereby achieving a fast and stable automatic switch between the main power supply and the backup power supply when the main power supply voltage drops or recovers.

[0048] In this embodiment of the invention, the switch control module 143 includes a first inverter 1431, a second inverter 1432, a first NAND gate 1433, and a second NAND gate 1434; The input terminal of the first inverter 1431 is connected to the output terminal of the comparator 132; The input terminal of the second inverter 1432 is connected to the output terminal of the first inverter 1431; The first input terminal of the first NAND gate 1433 is connected to the output terminal of the second inverter 1432; the second input terminal of the first NAND gate 1433 is connected to the output terminal of the second NAND gate 1434; the output terminal of the first NAND gate 1433 is connected to the control terminal of the first switching transistor 141. The first input terminal of the second NAND gate 1434 is connected to the output terminal of the first NAND gate 1433; the second input terminal of the second NAND gate 1434 is connected between the first inverter 1431 and the second inverter 1432; the output terminal of the second NAND gate 1432 is connected to the control terminal of the second switch 142. When the comparison signal is at the second level, the first inverter 1431 outputs the first level, the second inverter 1432 outputs the second level, the first NAND gate 1433 outputs the first level, the first switch 141 is turned off, the second NAND gate 1434 outputs the second level, and the second switch 142 is turned on. When the comparison signal is at the first level, the first inverter 1431 outputs the second level, the second inverter 1432 outputs the first level, the first NAND gate 1433 outputs the second level, the first switch 141 is turned on, the second NAND gate 1434 outputs the first level, and the second switch 142 is turned off.

[0049] An inverter is used to "flip" or "invert" the logic level of the input before outputting the output. For example, if the input signal of the inverter is low, then the output signal is high. A NAND gate outputs a low level only when all inputs are high; if even one input is low, the output is high. The first inverter 1431, the second inverter 1432, the first NAND gate 1433, and the second NAND gate 1434 can switch the on / off state of the first switch 141 and the second switch 142 according to the high or low level of the comparison signal, thereby achieving fast and stable automatic switching between the main power supply and the backup power supply when the main power supply voltage drops or recovers.

[0050] When the main power supply VCC is sufficiently low, even 0, and the backup power supply VBK is at its normal output voltage, the voltage at both the first node 20 and the second node 21 is 0. At this time, the output voltage of the multiplexer 131 is also 0. The output of the multiplexer 131 is connected to the positive input of the comparator 132, and the negative input of the comparator 132 is connected to the reference voltage. Therefore, the comparison signal output by the comparator 132 is low. The output of comparator 132 is connected to the enable terminal 22 of multiplexer 131. When the enable terminal 22 of multiplexer 131 is low, multiplexer 131 selects the first voltage output. On the other hand, the output of comparator 132 is connected to the input of first inverter 1431. Because the comparison signal is low at this time, the output of first inverter 1431 is high, and the output of second inverter 1432 is low. The output of first inverter 1431 is simultaneously connected to the input of second inverter 1432 and one input of second NAND gate 1434. The output of second NAND gate 1434 is connected to one input of first NAND gate 1433. The other input of first NAND gate 1433 is connected to the output of second NAND gate 1434 and the gate of second switch 142. Because the output of second NAND gate 1434 is low at this time, regardless of the level of the other input of first NAND gate 1433, the output of first NAND gate 1433 is always high. The output of the first NAND gate 1433 is connected to the gate of the first switch transistor 141 and the other input of the second NAND gate 1434. When the gate of the first switch transistor 141 is high, the first switch transistor 141 is turned off, and the main power supply VCC is shut off. At the same time, since both inputs of the second NAND gate 1434 are high, the output of the second NAND gate 1434 is low, that is, the gate of the second switch transistor 142 is low, the second switch transistor 142 is turned on, and the backup power supply VBK is powered on. That is, the voltage of the power output node 23 is the voltage of the second power supply 11.

[0051] When the main power supply voltage starts to rise, the voltages of the first node 20 and the second node 21 also rise accordingly. The voltage of the first node 20 is less than the voltage of the second node 21. When the voltage of the first node 20 (the first voltage) is higher than the reference voltage, the voltage of the first power supply 10 is the second threshold voltage. The comparison signal switches from low level to high level. The multiplexer 131 selects to output the second voltage, and the first inverter 1431 outputs a low level, while the second inverter 1432 outputs a high level. Then the second NAND gate 1434 outputs a high level, the second switch 142 is turned off, and the backup power supply VBK is turned off. At the same time, the first NAND gate 1433 outputs a low level, the first switch 141 is turned on, and the main power supply VCC is restored. At this time, the power output node 23 is instantly changed from being powered by the backup power supply VBK to being powered by the main power supply VCC, and then rises together with the main power supply VCC until it rises to the normal supply voltage (such as 3.3V).

[0052] When the main power supply VCC is in normal operation, if the main power supply VCC voltage suddenly starts to drop, the voltage of power output node 23 will drop along with the main power supply VCC. The voltages of the first node 20 and the second node 21 will also drop. Since the multiplexer 131 selects the second voltage output at this time, and the second voltage is higher than the first voltage, the main power supply VCC needs to drop to a lower potential to make the second voltage potential low enough compared to when the multiplexer 131 selects the first voltage output, until it is lower than the reference voltage. At this time, the voltage of the main power supply VCC is called the first threshold voltage, which causes the comparison signal of the comparator 132 to change from high level to low level. At this time, the multiplexer 131 reselects the first voltage output, the switching module 14 disconnects the first switch 141 and turns on the second switch 142, so that the voltage of the power output node 23 jumps from the first threshold voltage of the main power supply VCC to 3.3V of the backup power supply VBK.

[0053] During the switching process between the main power supply VCC and the backup power supply VBK, the multiplexer 131 selects between the voltages of the first node 20 and the second node 21. When switching from VCC to VBK, VCC starts to drop from a high voltage. At this time, the multiplexer 131 selects the second voltage output. Since the voltage of the second node 21 is higher than that of the first node 20, VCC needs to drop to a lower voltage to make the voltage of the second node 21 lower than the reference voltage, triggering the comparison signal level to flip from high to low. At this time, the VCC voltage is the first threshold voltage (drop threshold). When... During the switch from VBK to VCC, VCC starts from a low voltage and gradually increases. At this time, the multiplexer 131 selects the first voltage output. Since the voltage at the first node 20 is lower than that at the second node 21, VCC needs to rise to a higher voltage to make the first node 20 higher than the reference voltage, triggering the comparison signal level to flip from low to high. The VCC voltage at this time is the second threshold voltage (rising threshold). A reasonable threshold voltage is obtained by setting the ratio of the first resistor 121, the second resistor 122, and the third resistor 123. At the same time, the resistors should be as large as possible within a reasonable area to reduce the current consumption. Furthermore, this circuit does not rely on the CPU for voltage detection and switching decisions, nor is it controlled by digital circuits. It achieves automatic switching entirely through analog circuits. The circuit structure is simple, the response speed is fast, and it is suitable for applications with high real-time requirements.

[0054] This invention utilizes a dual-threshold voltage comparator to detect the upper and lower limits of the main power supply voltage. An analog circuit structure enables automatic power switching without CPU intervention. A hysteresis comparison mechanism prevents frequent switching caused by voltage fluctuations. The switching circuit structure is simple and responds quickly, making it suitable for low-power embedded systems. By employing a dual-threshold voltage comparison mechanism, switching to the backup power supply is triggered when the main power supply voltage falls below the first threshold, and switching back to the main power supply when it rises above the second threshold, avoiding switching oscillations caused by voltage fluctuations. The use of a pure analog circuit structure eliminates the need for CPU intervention and digital control during the switching process, achieving rapid response and low-latency, high-reliability power switching. This enables fast and stable automatic switching between the main power supply and the backup power supply when the main power supply voltage drops or recovers in the MCU power management system.

[0055] This invention also provides a microcontroller, which includes the power switching circuit described above.

[0056] In an embodiment of the present invention, the power switching circuit includes a first power supply, a second power supply, a voltage detection module, a comparator module, and a switching module. The voltage detection module is connected to both the first power supply and the comparator module, and is used to detect a first voltage and a second voltage based on the voltage of the first power supply. The ratio of the first voltage to the voltage of the first power supply is a first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply is a second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio. The comparator module is connected to both the voltage detection module and the switching module, and is used to receive the first voltage or the second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module, and select to receive the first voltage or the second voltage based on the comparison signal. The switching module is connected to both the first power supply and the second power supply, and is used to control power supply via the first power supply or the second power supply according to the comparison signal. This embodiment of the present invention compares the first voltage or the second voltage with a reference voltage and controls power supply via the first power supply or the second power supply according to the comparison signal. This dual-threshold voltage comparison mechanism switches the power supply. This analog circuit structure achieves switching without CPU intervention or digital control, has a fast response speed, significantly reduces switching latency, and thus achieves efficient, reliable, and seamless power switching.

[0057] The terms "first" and "second" in the specification and claims of this invention may explicitly or implicitly include one or more of those features. In the description of this invention, unless otherwise stated, "a plurality of" means two or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0058] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0059] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0060] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0061] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A power switching circuit, characterized in that, The power switching circuit includes a first power supply, a second power supply, a voltage detection module, a comparator module, and a switching module; The voltage detection module is connected to the first power supply and the comparator module respectively; it is used to detect a first voltage and a second voltage based on the voltage of the first power supply; the ratio of the first voltage to the voltage of the first power supply is a first voltage division ratio; the ratio of the second voltage to the voltage of the first power supply is a second voltage division ratio, and the first voltage division ratio is less than the second voltage division ratio. The comparator module is connected to the voltage detection module and the switching module, respectively. The device is configured to receive the first voltage or the second voltage, compare the first voltage or the second voltage with a reference voltage, send a comparison signal to the switching module, and select to receive the first voltage or the second voltage based on the comparison signal. The switching module is connected to the first power supply and the second power supply respectively, and is used to control whether to supply power through the first power supply or the second power supply according to the comparison signal.

2. The power switching circuit according to claim 1, characterized in that, When the comparison signal indicates that the first voltage is greater than the reference voltage, or the second voltage is greater than the reference voltage, the switching module controls the power supply to be supplied through the first power source; When the comparison signal indicates that the first voltage is less than or equal to the reference voltage, or the second voltage becomes less than or equal to the reference voltage, the switching module controls the power supply to be supplied through the second power source.

3. The power switching circuit according to claim 1, characterized in that, The comparator module includes a multiplexer and a comparator; The multiplexer is connected to the voltage detection module and the comparator, and is used to select to receive the first voltage or the second voltage based on the comparison signal, and to send the first voltage or the second voltage to the comparator. The comparator is connected to the switching module and is used to compare the first voltage or the second voltage with a reference voltage and send a comparison signal to the switching module; the comparison signal indicates that when the first voltage is greater than the reference voltage, or the second voltage is greater than the reference voltage, the comparison signal is at a first level; The comparison signal is at a second level when the comparison signal indicates that the first voltage is less than or equal to the reference voltage, or when the second voltage becomes less than or equal to the reference voltage.

4. The power switching circuit according to claim 3, characterized in that, The voltage detection module includes a first resistor, a second resistor, and a third resistor connected in series. One end of the first resistor is grounded, and one end of the third resistor is connected to the first power supply. The first voltage is the voltage of a first node, which is located between the first resistor and the second resistor. The second voltage is the voltage of a second node, which is located between the second resistor and the third resistor.

5. The power switching circuit according to claim 4, characterized in that, The first input terminal of the multiplexer is connected to the first node; the second input terminal of the multiplexer is connected to the second node; the enable terminal of the multiplexer is connected to the output terminal of the comparator. When the comparison signal is at the second level, the multiplexer selects to receive the first voltage and sends the first voltage to the comparator; when the comparison signal is at the first level, the multiplexer selects to receive the second voltage and sends the second voltage to the comparator.

6. The power switching circuit according to claim 5, characterized in that, The first input terminal of the comparator is connected to the output terminal of the multiplexer, and the second input terminal of the comparator is connected to the reference circuit; When the comparison signal is at the second level, the multiplexer selects to receive the first voltage and sends the first voltage to the comparator. The comparator compares the first voltage with the reference voltage sent by the reference circuit. If the first voltage is less than or equal to the reference voltage, the comparison signal remains at the second level. If the first voltage is greater than the reference voltage, the comparison signal becomes the first level. When the comparison signal is at the first level, the multiplexer selects to receive the second voltage and sends the second voltage to the comparator. The comparator compares the second voltage with the reference voltage. If the second voltage is greater than the reference voltage, the comparison signal remains at the first level. If the second voltage is less than or equal to the reference voltage, the comparison signal changes to the second level.

7. The power switching circuit according to claim 3, characterized in that, The switching module includes a first switching transistor, a second switching transistor, and a switching control module; The input terminal of the first switching transistor is connected to the first power supply; The input terminal of the second switching transistor is connected to the second power supply; the output terminal of the second switching transistor is connected to the output terminal of the first switching transistor; the power output node is located between the output terminal of the second switching transistor and the output terminal of the first switching transistor. One end of the switch control module is connected to the comparator, and the other end is connected to the control terminals of the first switch and the second switch, respectively. It is used to send switch control signals to the control terminals of the first switch and the second switch according to the comparison signal, so as to control the working state of the first switch and the second switch, so that the power output node is powered by the first power supply or the power output node is powered by the second power supply.

8. The power switching circuit according to claim 7, characterized in that, When the comparison signal is at the first level, the switch control module sends a switch control signal at the second level to the control terminal of the first switch transistor, the first switch transistor is turned on, and the switch control module sends a switch control signal at the second level to the control terminal of the second switch transistor, the second switch transistor is turned off, and the power output node is powered by the first power supply. When the comparison signal is at the second level, the switch control module sends a switch control signal at the first level to the control terminal of the first switch transistor, the first switch transistor is turned off, and the switch control module sends a switch control signal at the first level to the control terminal of the second switch transistor, the second switch transistor is turned on, and the power output node is powered by the second power supply.

9. The power switching circuit according to claim 7, characterized in that, The switch control module includes a first inverter, a second inverter, a first NAND gate, and a second NAND gate; The input terminal of the first inverter is connected to the output terminal of the comparator; The input terminal of the second inverter is connected to the output terminal of the first inverter; The first input terminal of the first NAND gate is connected to the output terminal of the second inverter; the second input terminal of the first NAND gate is connected to the output terminal of the second NAND gate; the output terminal of the first NAND gate is connected to the control terminal of the first switching transistor. The first input terminal of the second NAND gate is connected to the output terminal of the first NAND gate; the second input terminal of the second NAND gate is connected between the first inverter and the second inverter; the output terminal of the second NAND gate is connected to the control terminal of the second switching transistor. When the comparison signal is at the second level, the first inverter outputs the first level, the second inverter outputs the second level, the first NAND gate outputs the first level, the first switch is off, the second NAND gate outputs the second level, and the second switch is on; when the comparison signal is at the first level, the first inverter outputs the second level, the second inverter outputs the first level, the first NAND gate outputs the second level, the first switch is on, the second NAND gate outputs the first level, and the second switch is off.

10. A microcontroller, characterized in that, The microcontroller includes the power switching circuit as described in any one of claims 1-9.