Key switching circuit for realizing STM32 serial port downloading / communication

By designing a button switching circuit that includes dual-channel D-type flip-flops and inverters, the problem of cumbersome download/communication mode switching on the STM32 development board was solved, realizing convenient button control and simplifying the operation process.

CN223758257UActive Publication Date: 2026-01-02JIANGSU MARITIME INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202423085655.1
Authority / Receiving Office
CN · China
Patent Type
Utility models(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2026-01-02
Estimated Expiration
2034-12-13

AI Technical Summary

Technical Problem

The existing STM32 development board has a cumbersome operation when switching between download and communication modes, requiring manual switching of the shorting key or reliance on host computer software control, lacking a convenient automated switching method.

Method used

Design a key switching circuit that includes a dual-channel D-type flip-flop, an inverter integrated chip, and a button. Utilize an RC charging and discharging circuit and an inverter to achieve automatic switching between BOOT0 and NRST signals, and use the SW button to switch between download and communication modes of the STM32.

Benefits of technology

It enables button switching without relying on standard serial port signals and host computer software control, simplifying the download/communication mode switching process of STM32. Users only need two button operations to switch between download and communication modes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN223758257U_ABST
    Figure CN223758257U_ABST
Patent Text Reader

Abstract

The utility model discloses a key switching circuit for realizing STM32 serial port downloading / communication. The key switching circuit comprises a double-path D-type trigger U1, a phase inverter integrated chip U2, a resistor R3 and a key SW, the phase inverter integrated chip U2 comprises a phase inverter U2: A, a phase inverter U2: B and a phase inverter U2: C; a second pin of the key SW is connected in series to a resistor R3 and is connected to a third pin CLK of the double-path D-type trigger U1 through an RC charging and discharging circuit; a Q output of a fifth pin of the double-path D-type trigger U1 is connected with a phase inverter U2: B, is reversed and then is input into a D input of the double-path D-type trigger U1, and a sixth pin of the double-path D-type trigger U1 is used as a BOOT0 to be transmitted to an NRST pin of the STM32; the phase inverter U2: A inverts a low level signal generated by the key SW and then transmits the signal to a BOOT0 pin of the STM32 single-chip microcomputer. According to the utility model, the STM32 serial port downloading / communication function can be realized through the key.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The utility model relates to the singlechip development auxiliary technical field, concretely relates to a key switching circuit for realizing STM32 serial port download / communication. BACKGROUND

[0002] The development board is a powerful carrier for learning embedded systems and debugging power electronic devices, and its core is a microcontroller. Currently, the development boards popular at home and abroad generally use 51 series microcontrollers or STM32 series microcontrollers.

[0003] The STM32 series microcontroller has three startup modes, which are selected and controlled through the level state of two pins, BOOT0 and BOOT1. Generally, BOOT1 is pulled low by default, and only BOOT0 is used to select two of them: download mode and normal working mode. When BOOT0 is high, the STM32 enters the download mode after resetting, and the program can be downloaded through UART1; when BOOT0 is low, the STM32 starts normally from the ROM after resetting. Most STM32 development boards (also known as target boards) have two designs when using serial port download: one is to use a short key cap to manually set the BOOT0 level; the other is to control the NRST and BOOT0 of the microcontroller by means of the DTR and RTS pins of the CH340 chip, and the development board is designed to support one-key automatic download circuit. The former is more troublesome and needs to manually switch the short key cap back and forth; the latter needs to be designed specifically for the development board, and it may be necessary to set the state of the CH340 chip through software on the host computer, and it does not particularly reduce the operation steps.

[0004] Therefore, the mode switching between download and communication for the STM32 chip needs to be improved. UTILITY MODEL CONTENTS

[0005] 1. The technical problem to be solved is:

[0006] To solve the above technical problems, the utility model provides a key switching circuit for realizing STM32 serial port download / communication. With this scheme, the DTR# and RTS# signals of the standard serial port are not occupied, the host computer software does not need to be additionally controlled, and the download / communication key switching can be realized without starting the microcontroller by unplugging the STM32 power supply.

[0007] 2. Technical scheme:

[0008] A key switching circuit for realizing STM32 serial port download / communication, characterized by: comprising a two-way D flip-flop U1, an inverter integrated chip U2, a resistor R3, and a key SW; the inverter integrated chip U2 is integrated by an inverter U2:A, an inverter U2:B, and an inverter U2:C.

[0009] The first pin of the key SW is connected to the power supply VCC, the second pin is connected to one end of the protection resistor R3 in series, the other end of the resistor R3 is connected to the third pin CLK of the dual D flip-flop U1 through the RC charging and discharging circuit.

[0010] The Q output of the fifth pin of the dual D flip-flop U1 is connected to the inverter U2:B, and the inverted input is input into the inverter D input of the dual D flip-flop U1, and the sixth pin of U1 is used as the BOOT0 level signal and is input into the NRST reset pin of the STM32 single-chip microcomputer; the input end of the inverter U2:A is connected to the other end of the resistor R3, and the low-level signal generated by the key SW is inverted and input into the BOOT0 pin of the STM32 single-chip microcomputer as the NRST signal; the inverter U2:C is connected with the resistor R2 to form a driving circuit of the LED light indicator D1, which is used to drive the LED light indicator D1 to emit light to indicate the current working state.

[0011] Further, the model of the dual D flip-flop U1 is 74HC74, and two rising edge D flip-flops are contained; the model of the inverter integrated chip U2 is 74HC04, and six independent inverters are contained.

[0012] Further, the RC charging and discharging circuit is a circuit formed by connecting the resistor R1 and the capacitor C1 in series.

[0013] Further, the driving circuit of the LED light indicator D1 is that the fifth pin of the inverter U2:C is connected to the sixth pin of the D flip-flop, and the output pin is connected to the resistor R2 and the LED light indicator D1 in series, so as to drive the LED light indicator D1 to emit light.

[0014] Further, the voltage of the power supply VCC is 3.3V.

[0015] 3. Beneficial effects:

[0016] The key switching circuit for realizing STM32 serial port download / communication provided by the utility model, after the key SW is pressed every time during switching, the input end of the inverter integrated chip U2 is maintained at high level for a period of time, a low-level signal sufficient for the reset requirement of the STM32 is generated at the output end of U2, the signal is transmitted to the reset pin NRST of the STM32, and the STM32 single-chip microcomputer is restarted. The working state after the reset of the STM32 single-chip microcomputer depends on the level value of the BOOT0 pin. It is assumed that the current state of the dual D flip-flop U1 is Q=0 and D=1; in state (1), after the key SW is pressed and released for the first time, the rising edge trigger is received at the input end CLK of U1, then Q=1 and D=0, and the output end , the BOOT0 pin of the chip STM32 is low level, the STM32 resets to enter the normal working mode, and the serial port UART1 can be used for serial communication with the host computer; state (2) when the key SW is pressed and popped up for the second time, the U1 input end CLK receives a rising edge trigger, then Q=0, D=1, and the output end , the BOOT0 pin of the chip STM32 is high level, the STM32 resets to enter the BOOT download mode, and the serial port UART1 can be used for firmware download. Repeatedly pressing the key SW will repeatedly be in state (1) and state (2). Therefore, the user can select the starting state of the STM32 through no more than two key actions, and the serial port UART1 will also be switched between the download mode and the debugging mode. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 It is the hardware circuit design schematic of the utility model;

[0018] Figure 2 The hardware schematic used in the verification example is used to verify the switching function of the utility model. DETAILED DESCRIPTION

[0019] The utility model will be specifically explained in connection with the drawings.

[0020] As shown in the accompanying Figure 1 A key switching circuit for realizing STM32 serial port download / communication, characterized in that: it comprises a two-way D flip-flop U1, an inverter integrated chip U2, a resistor R3 and a key SW; the inverter integrated chip U2 is integrated by an inverter U2:A, an inverter U2:B and an inverter U2:C.

[0021] The first pin of the key SW is connected to the power supply VCC, the second pin is connected to the first pin of the protection resistor R3 in series, the second pin of the resistor R3 is connected to the third pin CLK of the two-way D flip-flop U1 through an RC charging and discharging circuit;

[0022] The Q output of the fifth pin of the two-way D flip-flop U1 is connected with the inverter U2:B, and after being reversed, it is input into the inverter D input of the two-way D flip-flop U1, and the sixth pin of U1 is used as a BOOT0 level signal and is input into the NRST reset pin of the STM32 single-chip microcomputer; the input end of the inverter U2:A is connected with the other end of the resistor R3, reverses the low level signal generated by the key SW and inputs it into the BOOT0 pin of the STM32 single-chip microcomputer as an NRST signal; the inverter U2:C is connected with the resistor R2 to form a driving circuit of the LED light indicator D1, which is used to drive the LED light indicator D1 to emit light and indicate the current working state.

[0023] Furthermore, the dual-channel D-type flip-flop U1 is model 74HC74, containing two rising-edge D-type flip-flops; the inverter integrated chip U2 is model 74HC04, containing 6 independent inverters.

[0024] Furthermore, the RC charging and discharging circuit is a circuit consisting of a resistor R1 and a capacitor C1 connected in series.

[0025] Furthermore, the driving circuit for the LED indicator D1 is specifically configured such that the 5th pin of inverter U2:C is connected to the 6th pin of D flip-flop, and its output pin is connected in series with resistor R2 and LED indicator D1 to drive LED indicator D1 to light up.

[0026] Furthermore, the voltage of the power supply VCC is 3.3V. Specific Implementation

[0027] The specific embodiment is illustrated in the attached figure. Figure 1 As shown, the implementation includes a 74HC74 dual-channel D-type flip-flop chip U1; a 74HC04 inverter integrated chip U2 containing 6 independent inverters, of which only 3 are used in this solution; a mechanical push-button switch SW; an RC charging and discharging circuit used to adjust the delay between the D flip-flop output and the output connected to the NRST inverter; a working status indicator consisting of an inverter, resistors, and LEDs; and some protective resistors and filter capacitors; the connection method between the push-button switching circuit and the STM32 development board, with four signal lines on the board: VCC, GND, NRST, and BOOT0 via DuPont wires.

[0028] In this embodiment, the button SW of the button switching circuit is connected to VCC on one side and R3 protection resistor on the other side. Each time SW is pressed, the high level of VCC is sent to two paths: 1) through the RC charging and discharging circuit composed of R1 and C1, to the U1:A CLK terminal of the 74HC74 dual-channel D-type flip-flop; 2) to the U2:A terminal of the 74HC04 inverter integrated chip.

[0029] The output of U2:A of the 74HC04 inverter integrated chip is connected to the NRST reset pin of the target board microcontroller. When SW is not pressed, the input voltage is 0 and the output is high. When SW is pressed / released each time, a high level appears at the output, which is inverted by U2:A to generate a low level of a certain width, forming a reset signal, which causes the STM32 microcontroller to start resetting.

[0030] The output terminal of U1:A of the 74HC74 dual-channel D-type flip-flop Connected to the BOOT0 of an STM32 microcontroller; the initial state of input CLK is 0, and the voltage at the output of Q is 0. The output voltage value is 3.3V, and Q is input to D through the inverter U2:B; when SW is pressed and lifted each time, a rising edge is generated, the flip-flop completes output once, and the voltage at the output end of Q is reversed on the previous state, and a high level 3.3V is output, The output voltage value is 0;

[0031] The STM32 single-chip microcomputer starts to reset after NRST is pulled low to meet the reset condition, and enters the BOOT mode or the normal starting mode according to the level state of BOOT0, so that the function of TOGGLE of the key SW for switching the single-chip microcomputer between the two starting modes is realized.

[0032] D1, R2, U2:C constitute an LED signal indicator lamp for indicating the mode of the current STM32 BOOT0 pin (that is, the voltage value of BOOT0). When the D1 lamp is off (D1=1), it indicates that the current target board is in the download BOOT mode; when the D1 lamp is on (D1=0), it indicates that the current target board is in the normal starting mode.

[0033] Verification example:

[0034] In order to verify that the switching circuit of the utility model can realize the switching of the serial port download and communication of the STM32 chip through the key, the hardware principle diagram shown in the accompanying Figure 2 is simulated and verified in Protues.

[0035] The download / debugging board used in this verification example has a power supply VCC of 3.3V and a GND of 0V; U1 74HC74 is a double D-type positive edge trigger flip-flop with high-speed performance and balanced output; U2 74HC04 is a high-speed CMOS six-inverter, compatible with low-power Schottky TTL, and contains six independent inverters.

[0036] The verification steps are as follows:

[0037] S1, connect the 3V3, GND, NRST, BOOT0 interfaces of the download communication switching circuit board and the 3V3, GND, NRST, BOOT0 interfaces of the target board with DuPont wires, as shown in Figure 1 ;

[0038] S2, when initially powered on, the input of the 74HC04 inverter integrated chip U2:A is low, and the output is high after being reversed to NRST;

[0039] S3, when initially powered on, the input state of the 74HC74 double D-type trigger U1:A is D=1 and Q=0, ​=1, the BOOT0 pin of the STM32 microcontroller is at a high level;

[0040] S4. Based on S2 and S3, the STM32 microcontroller enters BOOT download mode after initial power-on; Indicator D1 status: U1: Output terminal of A. After passing through inverter U2:C, the output is low, and LED D1 is off, indicating that the STM32 chip is currently in BOOT download mode.

[0041] S5. After pressing and releasing the SW button, a high-level signal will be output to R3.

[0042] S6. According to the S2 state, S5 operation and technical description, the 74HC04 inverter integrated chip U2:A will generate a low-level signal sufficient to satisfy the SMT32 microcontroller reset condition to the NRST pin of the STM32.

[0043] S7. Based on the S2 state, S5 operation, and technical description, a rising edge signal is sent to the CLK input of the dual-channel D-type flip-flop U1:A. The new output of the D flip-flop is D=0, Q=1. =0, the BOOT0 pin of the STM32 microcontroller is at a low level;

[0044] S8. Based on the results of S6 and S7, the STM32 chip is reset and enters normal startup mode; Indicator D1 status: U1: Output terminal of A After passing through inverter U2:C, the output is high level, and LED D1 lights up, indicating that the STM32 chip is in normal startup mode.

[0045] S9. Repeat S5~S8. Each time SW is pressed and released, the STM32 chip will switch between normal startup and BOOT mode. After each program download, R&D or learning personnel can press the SW key to restart and enter the normal working mode. Pressing the key again will enter the serial port download mode, and the firmware can be downloaded using the serial port download tool on the host computer.

[0046] Although the present invention has been disclosed above with reference to preferred embodiments, these are not intended to limit the present invention. Anyone skilled in the art can make various changes or modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the scope of protection of the claims of this application.

Claims

1. A key switching circuit for implementing STM32 serial port download / communication, characterized in that: It includes two-way D flip-flop U1, inverter integrated chip U2, resistance R3, button SW; the inverter integrated chip U2 is integrated by inverter U2:A, inverter U2:B, inverter U2:C; The first pin of the button SW is connected to the power supply VCC, the second pin is connected to the first pin of the protection resistance R3 in series, the second pin of the resistance R3 is connected to the third pin CLK of the two-way D flip-flop U1 through the RC charging and discharging circuit; The Q output of the fifth pin of the two-way D flip-flop U1 is connected to the inverter U2:B, and then input to the D input of the two-way D flip-flop U1 after reversing, the sixth pin of U1 is used as BOOT0 level signal and delivered to the NRST reset pin of STM32 single-chip microcomputer; the input end of the inverter U2:A is connected to the second pin of the resistance R3, and the low-level signal generated by the button SW is reversed and delivered to the BOOT0 pin of the STM32 single-chip microcomputer as the NRST signal; the inverter U2:C is connected with the resistance R2 to form the driving circuit of the LED light indicating lamp D1, which is used to drive the LED light indicating lamp D1 to emit light to indicate the current working state.

2. The key switching circuit for implementing STM32 serial port download / communication according to claim 1, characterized in that: The model of the two-way D flip-flop U1 is 74HC74, which contains two rising edge D flip-flops; the model of the inverter integrated chip U2 is 74HC04, which contains six independent inverters.

3. The key switching circuit for implementing STM32 serial port download / communication according to claim 1, characterized in that: The RC charging and discharging circuit is a circuit formed by the series connection of resistance R1 and capacitor C1.

4. The key switching circuit for implementing STM32 serial port download / communication according to claim 1, characterized in that: The driving circuit of the LED light indicating lamp D1 is that the fifth pin of the inverter U2:C is connected to the sixth pin of the D flip-flop, and the output pin is connected to the resistance R2 and the LED light indicating lamp D1 in series, which is used to drive the LED light indicating lamp D1 to emit light.

5. The key switching circuit for implementing STM32 serial port download / communication according to claim 1, characterized in that: The voltage of the power supply VCC is 3.3V.