Hands to teach you pure hardware STC microcontroller automatically download

Summary:STC MCU has a convenient ISP serial download program function, no need to buy a dedicated programmer; however, in the process of repeatedly debugging the program, each download requires a cold start is boring, and also shortens the switch original Lifetime; for this reason, the author developed a circuit that completely realizes the automatic cold start of the single-chip microcomputer by hardware, realizes one-click downloading procedure, obviously reduces the hardware cost, reduces the operation difficulty, and does not occupy the serial port of the single-chip microcomputer.

Basic principle

For STC download, you need to use the official STC-ISP software; use the domestic ch340g chip as a USB to TTL chip, the pin is shown below. The 13th and 14th pins are the MODEM contact signal output pin, which is controlled by the STC-ISP download software. The default is high level. When the download is clicked, it becomes a continuous low level, and the download is completed and goes back to high level.

Hands to teach you pure hardware STC microcontroller automatically download

Use the falling edge of the MODEM contact signal pin as the trigger signal. When the hardware circuit detects the falling edge, the microcontroller is powered off for a period of time, and then power-on, that is, automatic cold start.

2. Specific hardware circuit

The download circuit of Ch340g will not be described here. It is worth noting that diode D1 uses Schottky diode or switch tube 1n4148 to ensure that the microcontroller is completely powered off.

The following mainly explains the automatic cold start part. The RTS or DTR pin is used as the input of the signal. Since both pins will jump to low level during download, one pin can be arbitrarily selected; a 10uf tantalum capacitor is used. C4 is used to couple the input signal. Only the signal is passed when the level jumps. The latter circuit is mainly composed of three NPN transistors. The author uses the SS8050 transistor of the patch to allow the current to pass 1.5A. The demand; two of the triodes as a component of the monostable oscillator circuit, a triode as an electronic switch, control the on and off of the microcontroller.

The circuit is analyzed. When the download is not clicked, RTS/DTR is high, no signal passes through the coupling capacitor C4, the monostable multivibrator is in steady state, 3Q1 is saturated and Q2 is off, and the output of the monostable oscillator circuit ( R8) is high level, Q3 is saturated and turned on, and the MCU is in the power supply state; when downloading, RTS/DTR quickly jumps to low level, when the level jumps, it is equivalent to AC power, and through the coupling capacitor R4, input a negative To the b-pole of the pulse signal to Q1, Q1 is turned off, Q2 is turned on, the oscillation circuit outputs a low level, Q3 is turned off, the single-chip microcomputer is powered off, and the pulse signal is coupled by the capacitor C6 to lower the b-pole voltage of Q1 to form a positive feedback and oscillate. The circuit is in an unsteady state; it is discharged through resistor R6 through capacitor C6 and the circuit returns to steady state.

Analysis of the unsteady time, that is, the power outage time is affected by the size of R6 and C6, the calculation formula is:

Unsteady time T=0.7*R6*C6

According to the parameter in the figure, the power-off time is about 0.5 second.

The following picture shows the ch340g download circuit diagram

Hands to teach you pure hardware STC microcontroller automatically download

The following picture shows the automatic cold start circuit diagram

Hands to teach you pure hardware STC microcontroller automatically download

3. Advantages and disadvantages

There are two common problems with automatic download methods:

*1 Use STC15F014W MCU to detect the serial port download command stream - the circuit is large, the automatic download part of the hardware cost is high, about 1.3 yuan, because the STC15 MCU does not have a native serial port, you need to use the software to simulate the serial port, the code is more complicated, for downloading baud The rate is limited and there is a certain failure rate;

*2 Use the serial port detection of 51 MCU to download the command stream - every time you write a program, you must add the automatic download detection code. The operation is complicated and takes up the serial port function of the MCU. It is often a complicated program that requires repeated debugging and takes up the serial port. The use of the single chip caused a big problem;

The advantage of this design is that the use of pure hardware circuit to achieve automatic cold start, hardware system work is more reliable than software, the automatic download part of the hardware cost is very low, about 0.4 yuan (the tantalum capacitor can be replaced by ordinary ceramic capacitor), the circuit is small, use The triodes are common SS8050 triodes, the materials are easy to get, the circuit is relatively simple, easy to DIY; the hardware circuit response speed is fast, do not wait to detect the download command, the success rate is high, the reliability is high, the author fails to download after a successful debugging rate is almost 0;

Design defect: Since the computer communicates with the ch340g when the download module is powered on, the RTS/DTR pin will repeatedly jump between high and low levels in about 4 seconds, which will also trigger the cold start circuit. If the circuit connection is automatically downloaded at this time. The single-chip microcomputer will cause the single-chip microcomputer to repeatedly turn on and off three times, affecting the use experience. The author did not achieve obvious results after optimizing the design, so it will not be processed here;

Attached to the author's automatic download module for soldering as shown below, the circuit is more compact

Hands to teach you pure hardware STC microcontroller automatically download

Reference: Yang Xin and other "electronic design from scratch" published in 2010

Pharmaceuticals

Pharmaceuticals,2-Methyl- Propanoic Acid Monohydrate Price,2-Methyl- Propanoic Acid Monohydrate Free Sample,Pure 2-Methyl- Propanoic Acid Monohydrate

Zhejiang Wild Wind Pharmaceutical Co., Ltd. , https://www.wild-windchem.com