MCU pin multiplexing circuit and method based on combination of charging line and button line
By merging charging cables with the button line, designing a MCU pin repeat circuit solves the problem of complex connection and pin occupation in existing technology, and realizes space saving, reduced cost, and improvement of circuit reliability.
Patent Information
- Application Number
- CN202411476723.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the line connection between the button and the charging port is complex, occupies a large number of MCU pins, increasing maintenance difficulty and cost, and occupies valuable internal space in space-constrained devices.
By merging the charging line and the button line, an MCU pin multiplexing circuit is designed. Only two lines are needed to connect the button board and the main control board. Resistors and charging management chips are used to detect and control the button and charging status.
The reuse of the pin is achieved, reducing the complexity of the wiring and maintenance difficulty, saving the internal space and cost, and at the same time improve the reliability and flexibility of the circuit.
Smart Images

Figure CN119341546A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip application technology, and in particular to an MCU pin multiplexing circuit and method based on merging a charging line and a button line. Background Art
[0002] In portable electronic devices, separating the button and main control functions into two independent circuit boards can improve the modularity of the system, facilitate maintenance and upgrades, and optimize space utilization and cost control.
[0003] In the prior art, buttons and charging ports often require four or three wires and occupy multiple pins of the main control chip. In this case, the connection of multiple wires increases the complexity of wiring, easily increases the difficulty of maintenance, and increases material and manufacturing costs; in portable devices with limited space, the connection of multiple wires occupies valuable internal space, and the occupation of multiple pins of the main control chip (MCU) will limit the realization of other functions. Summary of the invention
[0004] The object of the present invention is to provide an MCU pin multiplexing circuit and method based on merging a charging line and a button line to solve the problems existing in the above-mentioned prior art.
[0005] To achieve the above object, the technical solution adopted by the present invention is: In a first aspect, the present invention provides an MCU pin multiplexing circuit based on merging a charging line and a button line, comprising: A button board, comprising a charging port, a first resistor and a button, wherein a VCC terminal of the charging port is connected to a positive power supply terminal of the button board, a GND terminal of the charging port is connected to a negative power supply terminal of the button board, a first end of the first resistor is connected to the VCC terminal of the charging port, a first end of the button is connected to the GND terminal of the charging port, and a second end of the first resistor is connected to a second end of the button; A main control board, whose positive power pole and negative power pole are respectively connected to the positive power pole and negative power pole of the button board, the main control board includes a main control chip and a second resistor, the first end of the second resistor is connected to the positive power pole of the main control board, and the second end of the second resistor is connected to pin four of the main control chip.
[0006] In a possible implementation, the main control board further includes: The positive electrode of the battery is connected to the pin 1 of the main control chip, and the negative electrode of the battery is connected to the pin 8 of the main control chip.
[0007] In a possible implementation, the main control board further includes: The charging management chip has a pin 4 connected to the positive pole of the power supply of the main control board, a pin 3 connected to the positive pole of the battery, and a pin 2 connected to the negative pole of the battery.
[0008] In a possible implementation, the main control board also includes:
[0009] A first light emitting diode, a first end of which is connected to pin 5 of the main control chip, and a second end of which is connected to the positive electrode of the battery, wherein pin 5 of the main control chip is a charging indication pin; The second light emitting diode has a first end connected to pin six of the main control chip, and a second end connected to the positive electrode of the battery. Pin six of the main control chip is a working status indicating pin.
[0010] In a possible implementation, pin 1 of the charging management chip is connected to pin 7 of the main control chip, and pin 1 of the charging management chip is used to indicate the charging status.
[0011] In a possible implementation, the main control board further includes: A third resistor, a first end of which is connected to pin five of the charging management chip, and a second end of which is connected to the negative power supply of the main control board, and pin five of the charging management chip is used to program the charging current.
[0012] In a second aspect, the present invention provides an MCU pin multiplexing method based on merging a charging line and a button line, the method is applied to any of the above-described MCU pin multiplexing circuits based on merging a charging line and a button line, the method comprising: Button judgment, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 4 of the main control chip; if pin 4 of the main control chip is low level, perform sleep state detection; if pin 4 of the main control chip is high level, perform charging state detection; Charging state detection, set pin 4 of the main control chip to input pull-down, delay 2ms, and determine the signal state of pin 4 of the main control chip; if pin 4 of the main control chip is high level, execute the charging program and determine the signal state of pin 7 of the main control chip; if pin 4 of the main control chip is low level, perform sleep state detection; Sleep state detection, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 6 of the main control chip; if pin 6 of the main control chip is at a low level, execute button judgment; if pin 6 of the main control chip is at a high level, execute the sleep program.
[0013] In a possible implementation, the button determination includes: Set pin 4 of the main control chip to input pull-up, delay 2ms, and determine the signal state of pin 4 of the main control chip; If the pin 4 of the main control chip is at a low level, the button operation is performed; the pin 5 of the main control chip outputs a high level, indicating that the first light-emitting diode is off; the level of the pin 6 of the main control chip is inverted, indicating that the second light-emitting diode changes from off to bright or from bright to off; and the sleep state detection is performed; If the pin 4 of the main control chip is at a high level, the charging status detection is performed.
[0014] In a possible implementation, the charging status detection includes: Set pin 4 of the main control chip to input pull-down, delay 2ms, and determine the signal state of pin 4 of the main control chip; If the pin 4 of the main control chip is at a high level, the charging program is executed; the pin 6 of the main control chip outputs a high level, indicating that the second light-emitting diode is off; the signal state of the pin 7 of the main control chip is judged. If the pin 7 of the main control chip is at a low level, the pin 5 of the main control chip outputs a low level, indicating that the first light-emitting diode is on, and the button judgment is executed; if the pin 7 of the main control chip is at a high level, the pin 5 of the main control chip outputs a high level, indicating that the first light-emitting diode is off, and the button judgment is executed; If the pin 4 of the main control chip is at a low level, a sleep state detection is performed.
[0015] In a possible implementation, the sleep state detection includes: Set pin 4 of the main control chip to input pull-up, delay 2ms, and determine the signal state of pin 6 of the main control chip; If the pin 6 of the main control chip is at a low level, indicating that the second light emitting diode is on, the button judgment is executed; If the pin 6 of the main control chip is at a high level, the second light emitting diode is turned off and the sleep program is executed; In response to one of the pin 4 or the pin 7 of the main control chip becoming a low level, the sleep program is exited and the button judgment is executed.
[0016] The beneficial effects brought about by the technical solution provided by the present invention include at least: By connecting the positive and negative power poles of the main control board to the positive and negative power poles of the button board, the VCC end of the charging port is connected to the positive power pole of the button board, the GND end of the charging port is connected to the negative power pole of the button board, the first end of the first resistor is connected to the VCC end of the charging port, the first end of the button is connected to the GND end of the charging port, the second end of the first resistor is connected to the second end of the button, the first end of the second resistor is connected to the positive power pole of the main control board, and the second end of the second resistor is connected to pin 4 of the main control chip. In this case, the complexity of wiring and the difficulty of maintenance are reduced, the manufacturing cost is reduced, and the internal space of the product is saved; and only one pin of the main control chip is occupied, and the reliability and flexibility of the circuit are improved through pin multiplexing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0018] Figure 1 A schematic diagram of an MCU pin multiplexing circuit based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown.
[0019] Figure 2 A flowchart of an MCU pin multiplexing method based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown.
[0020] Figure 3 A logic block diagram of an MCU pin multiplexing method based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0023] Figure 1 A schematic diagram of an MCU pin multiplexing circuit based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown. The MCU pin multiplexing circuit based on merging a charging line and a button line includes a button board A and a main control board B. The positive power pole and the negative power pole of the main control board B are connected to the positive power pole and the negative power pole of the button board A, respectively.
[0024] In detail, the button board A includes a charging port USB1, a first resistor R1 and a button KEY1. The VCC end of the charging port USB1 is connected to the positive power supply of the button board A, the GND end of the charging port USB1 is connected to the negative power supply of the button board A, the first end of the first resistor R1 is connected to the VCC end of the charging port USB1, the first end of the button KEY1 is connected to the GND end of the charging port USB1, and the second end of the first resistor R1 is connected to the second end of the button KEY1.
[0025] Furthermore, the main control board B includes a main control chip U1, a second resistor R2, a battery B1, a charging management chip U2, a first light-emitting diode LED1, a second light-emitting diode LED2 and a third resistor R3, the first end of the second resistor R2 is connected to the positive pole of the power supply of the main control board B, and the second end of the second resistor R2 is connected to pin four of the main control chip U1; the positive pole of the battery B1 is connected to pin one of the main control chip U1, and the negative pole of the battery B1 is connected to pin eight of the main control chip U1; pin four of the charging management chip U2 is connected to the positive pole of the power supply of the main control board B, pin three of the charging management chip U2 is connected to the positive pole of the battery B1, and pin two of the charging management chip U2 is connected to the negative pole of the battery B1; the first end of the first light-emitting diode LED1 is connected to Pin five of the main control chip U1 is connected, the second end of the first light-emitting diode LED1 is connected to the positive electrode of the battery B1, and pin five of the main control chip U1 is a charging indication pin; the first end of the second light-emitting diode LED2 is connected to pin six of the main control chip U1, the second end of the second light-emitting diode LED2 is connected to the positive electrode of the battery B1, and pin six of the main control chip U1 is a working status indication pin; pin one of the charging management chip U2 is connected to pin seven of the main control chip U1, and pin one of the charging management chip U2 is used to indicate the charging status; the first end of the third resistor R3 is connected to pin five of the charging management chip U2, the second end of the third resistor R3 is connected to the negative electrode of the power supply of the main control board B, and pin five of the charging management chip U2 is used to program the charging current.
[0026] In the embodiment of the present application, by merging the charging line with the button line, only two lines, the +5v line and the GND line, are needed to connect the button board A and the main control board B, thus realizing pin multiplexing. Using fewer pins can reduce the cost of the MCU; fewer pins means fewer connection points and solder joints, thereby reducing potential failure points and improving system reliability; fewer pins make the circuit easier to debug and test, reducing the possibility of errors; the fewer pins are occupied, the more pins are left for other functions, which makes it easier for the system to expand new functions, such as adding sensors, display devices or communication interfaces, and more available pins can be used for other key tasks, such as real-time data acquisition, complex algorithm processing, etc.
[0027] In the embodiment of the present application, the first resistor R1 is connected in series with the button KEY1. When the button KEY1 is pressed, there will be a resistor between +5v and GND to limit the current. This resistor can prevent +5v and GND from being short-circuited.
[0028] In the embodiment of the present application, the second resistor R2 located between +5v and the main control chip U1 can protect the main control chip U1 from being damaged by the 5v voltage.
[0029] Figure 2 A flowchart of an MCU pin multiplexing method based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown. Figure 3 A logic block diagram of an MCU pin multiplexing method based on merging a charging line and a button line provided by an exemplary embodiment of the present invention is shown. The method is applied to the MCU pin multiplexing circuit based on merging a charging line and a button line as described above. The method includes: Step 201, button judgment, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 4 of the main control chip; if pin 4 of the main control chip is low level, perform sleep state detection; if pin 4 of the main control chip is high level, perform charging state detection.
[0030] Specifically, the button judgment includes: setting pin four of the main control chip as an input pull-up, delaying 2ms, and judging the signal state of pin four of the main control chip; if pin four of the main control chip is at a low level, it indicates that a button is pressed, and the button operation is executed; pin five of the main control chip outputs a high level, indicating that the first light-emitting diode is off; the level of pin six of the main control chip is inverted, indicating that the second light-emitting diode changes from off to bright or from bright to off; executing sleep state detection; if pin four of the main control chip is at a high level, it indicates that no button is pressed, and executing charging state detection.
[0031] In the embodiment of the present application, executing a button operation means pressing a button.
[0032] Step 202, charging status detection, set pin 4 of the main control chip to input pull-down, delay 2ms, and determine the signal status of pin 4 of the main control chip; if pin 4 of the main control chip is high level, execute the charging program and determine the signal status of pin 7 of the main control chip; if pin 4 of the main control chip is low level, perform sleep status detection.
[0033] Specifically, the charging status detection includes: setting pin 4 of the main control chip to input pull-down, delaying 2ms, and judging the signal status of pin 4 of the main control chip; if pin 4 of the main control chip is at a high level, it indicates that there is a 5V power input at this time, and the charging program is executed; pin 6 of the main control chip outputs a high level, indicating that the second light-emitting diode is off; judging the signal status of pin 7 of the main control chip, if pin 7 of the main control chip is at a low level, then the battery is charging, pin 5 of the main control chip outputs a low level, indicating that the first light-emitting diode is on, and a button judgment is executed; if pin 7 of the main control chip is at a high level, then the battery is fully charged, pin 5 of the main control chip outputs a high level, indicating that the first light-emitting diode is off, and a button judgment is executed; if pin 4 of the main control chip is at a low level, it indicates that there is no 5V power input to the port, and a sleep status detection is executed.
[0034] In the embodiment of the present application, executing the charging procedure means charging the battery.
[0035] Step 203, sleep state detection, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 6 of the main control chip; if pin 6 of the main control chip is low level, execute button judgment; if pin 6 of the main control chip is high level, execute the sleep program.
[0036] Specifically, the sleep state detection includes: setting pin four of the main control chip to an input pull-up, delaying 2ms, and judging the signal state of pin six of the main control chip; if pin six of the main control chip is at a low level, indicating that the second light-emitting diode is on, and executing a button judgment; if pin six of the main control chip is at a high level, indicating that the second light-emitting diode is off, executing a sleep program, and reducing the power consumption of the chip; in response to one of pin four or pin seven of the main control chip becoming a low level, exiting the sleep program and executing a button judgment.
[0037] In the embodiment of the present application, executing the sleep program means putting the main control chip into a sleep state.
[0038] It should be understood that the specific examples herein are only intended to help those skilled in the art to better understand the present disclosure, rather than to limit the scope of the present invention.
[0039] It is understood that in the various implementations of this specification, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the present disclosure.
[0040] It can be understood that the various implementation modes described in this specification can be implemented individually or in combination, and the present disclosure is not limited to this.
[0041] Unless otherwise stated, all technical and scientific terms used in this disclosure have the same meaning as those generally understood by those skilled in the art of the technical field of this specification. The terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the scope of this specification. The term "and / or" used in this specification includes any and all combinations of one or more related listed items. The singular forms of "a", "above", and "the" used in this disclosure and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0042] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this specification.
[0043] The above is only a specific implementation of this specification, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in this specification, which should be included in the protection scope of this specification. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. An MCU pin multiplexing circuit based on merging a charging line and a button line, characterized in that: include: A button board, comprising a charging port, a first resistor and a button, wherein a VCC terminal of the charging port is connected to a positive power supply terminal of the button board, a GND terminal of the charging port is connected to a negative power supply terminal of the button board, a first end of the first resistor is connected to the VCC terminal of the charging port, a first end of the button is connected to the GND terminal of the charging port, and a second end of the first resistor is connected to a second end of the button; A main control board, whose positive power pole and negative power pole are respectively connected to the positive power pole and negative power pole of the button board, the main control board includes a main control chip and a second resistor, the first end of the second resistor is connected to the positive power pole of the main control board, and the second end of the second resistor is connected to pin four of the main control chip.
2. The MCU pin multiplexing circuit based on merging the charging line and the button line according to claim 1, characterized in that: The main control board also includes: The positive electrode of the battery is connected to the pin 1 of the main control chip, and the negative electrode of the battery is connected to the pin 8 of the main control chip.
3. The MCU pin multiplexing circuit based on merging the charging line and the button line according to claim 2, characterized in that: The main control board also includes: The charging management chip has a pin 4 connected to the positive pole of the power supply of the main control board, a pin 3 connected to the positive pole of the battery, and a pin 2 connected to the negative pole of the battery.
4. The MCU pin multiplexing circuit based on merging the charging line and the button line according to claim 3, characterized in that: The main control board also includes: A first light emitting diode, a first end of which is connected to pin 5 of the main control chip, and a second end of which is connected to the positive electrode of the battery, wherein pin 5 of the main control chip is a charging indication pin; The second light emitting diode has a first end connected to pin six of the main control chip, and a second end connected to the positive electrode of the battery. Pin six of the main control chip is a working status indicating pin.
5. The MCU pin multiplexing circuit based on merging the charging line and the button line according to claim 3, characterized in that: Pin 1 of the charging management chip is connected to pin 7 of the main control chip, and pin 1 of the charging management chip is used to indicate the charging status.
6. The MCU pin multiplexing circuit based on merging the charging line and the button line according to claim 3, characterized in that: The main control board also includes: A third resistor, a first end of which is connected to pin five of the charging management chip, and a second end of which is connected to the negative power supply of the main control board, and pin five of the charging management chip is used to program the charging current.
7. A MCU pin multiplexing method based on merging a charging line and a button line, characterized in that: The method is applied to the MCU pin multiplexing circuit based on merging the charging line and the button line as described in any one of claims 1 to 6, and the method comprises: Button judgment, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 4 of the main control chip; if pin 4 of the main control chip is low level, perform sleep state detection; if pin 4 of the main control chip is high level, perform charging state detection; Charging state detection, set pin 4 of the main control chip to input pull-down, delay 2ms, and determine the signal state of pin 4 of the main control chip; if pin 4 of the main control chip is high level, execute the charging program and determine the signal state of pin 7 of the main control chip; if pin 4 of the main control chip is low level, perform sleep state detection; Sleep state detection, set pin 4 of the main control chip to input pull-up, delay 2ms, and judge the signal state of pin 6 of the main control chip; if pin 6 of the main control chip is at a low level, execute button judgment; if pin 6 of the main control chip is at a high level, execute the sleep program.
8. The MCU pin multiplexing method based on merging the charging line and the button line according to claim 7, characterized in that: The button judgment includes: Set pin 4 of the main control chip to input pull-up, delay 2ms, and determine the signal state of pin 4 of the main control chip; If the pin 4 of the main control chip is at a low level, the button operation is performed; the pin 5 of the main control chip outputs a high level, indicating that the first light-emitting diode is off; the level of the pin 6 of the main control chip is inverted, indicating that the second light-emitting diode changes from off to bright or from bright to off; and the sleep state detection is performed; If the pin 4 of the main control chip is at a high level, the charging status detection is performed.
9. The MCU pin multiplexing method based on merging the charging line and the button line according to claim 7, characterized in that: The charging state detection includes: Set pin 4 of the main control chip to input pull-down, delay 2ms, and determine the signal state of pin 4 of the main control chip; If the pin 4 of the main control chip is at a high level, the charging program is executed; the pin 6 of the main control chip outputs a high level, indicating that the second light-emitting diode is off; the signal state of the pin 7 of the main control chip is judged. If the pin 7 of the main control chip is at a low level, the pin 5 of the main control chip outputs a low level, indicating that the first light-emitting diode is on, and the button judgment is executed; if the pin 7 of the main control chip is at a high level, the pin 5 of the main control chip outputs a high level, indicating that the first light-emitting diode is off, and the button judgment is executed; If the pin 4 of the main control chip is at a low level, a sleep state detection is performed.
10. The MCU pin multiplexing method based on merging the charging line and the button line according to claim 7, characterized in that: The sleep state detection includes: Set pin 4 of the main control chip to input pull-up, delay 2ms, and determine the signal state of pin 6 of the main control chip; If the pin 6 of the main control chip is at a low level, indicating that the second light emitting diode is on, the button judgment is executed; If the pin 6 of the main control chip is at a high level, the second light emitting diode is turned off and the sleep program is executed; In response to one of the pin 4 or the pin 7 of the main control chip becoming a low level, the sleep program is exited and the button judgment is executed.