Automatic STC download circuit design

This article introduces the STC download process and designs a fully automatic STC download circuit, so that the entire download process does not require human intervention, which greatly improves the efficiency of program development and enables the program to be developed through the download-run-test mode.

 

Introduction to STC download mode

STC microcontroller ISP download process has a very certain process, through the following three steps.

  1. The PC sends two connected 0xff bytes every 10ms in TXD;
  2. The MCU is powered on and sent to the relevant information;
  3. After the PC shakes hands again, it continues to complete the chip erase and download procedures.

Among them, the one-chip computer is powered on and cold start is a necessary link. Often when the microcontroller is designed. This part powers on the microcontroller through a manual mechanical switch. The fully automatic download circuit is designed to replace the manual power-on link.

In order to avoid the MCU obtaining power from the download serial port pin, it is necessary to perform effective isolation through resistors and diodes.

For related download experiments, see the following blog post:

  1. STC microcontroller download experiment

STC download program interface. The minimum baud rate is set to 19200, and the maximum baud rate is set to 115200. The download success rate is relatively high. As for the other settings why the MCU cannot be downloaded, it cannot be explained.

▲ STC-ISP (V6.87C) download program interface

▲ STC-ISP(V6.87C)下载程序界面

 

Fully automatic download circuit

1. Basic Principles

When the computer downloads the program, a low-level pulse will appear on the TXD pin of the serial port (or USB to serial port), and during the entire download process, the TXD will have a low-level pulse. The designed circuit board can detect the low pulse to generate the power-on control pulse of the single-chip microcomputer power supply, make the single-chip microcomputer power off, and then power on again. Simulate the process of the original manual operation.

The power supply part of the single-chip microcomputer was originally passed through a switch, and now it is completed through a controlled relay switch.

2. Functional description of the circuit

According to the principle described above, the fully automatic download circuit includes two parts:

  1. USB to serial circuit: This part is completed by PL2303 (SOP-8);
  2. Power supply control circuit: This part includes two monostable time timing circuits and relay circuits;

The circuit function framework is shown in the following figure:

▲ Block diagram of automatic download circuit

▲ 全自动下载电路框图

For the USB to serial port part, please refer to the blog post " Prolific PL2303SA Debugging ", which is omitted here.

In the power control circuit, the monostable timer can be triggered repeatedly to combine the pulses on the serial port TXD of the microcomputer into one large pulse. The pulse then drives the following monostable timer to form a power switch pulse signal, and drives the relay to complete the power switch of the single chip microcomputer.

Observing the waveform of the STC download program, you can see that the maximum time interval in the pulse is 0.5 to 1 second during the entire download process, so the time constant of the monostable timer that needs to be designed to be triggered repeatedly needs to be greater than one second.

▲ STC download process

▲ STC下载程序过程

Considering that the power storage filter capacitor is included in the circuit during the power-off of the single-chip microcomputer, it needs to be discharged. According to manual testing, the power-down time of more than 1 second can basically ensure the reliable power-down of the single-chip circuit. So the time of the second monostable timer is set to 1 second.

The use of relays to control the power supply of the single-chip computer can adapt to the different current ranges of the single-chip circuit work. This has a more reliable control effect than using semiconductor switching devices. In addition, this can also effectively isolate the working power of the debugging circuit from the working power of the download board.

3. Circuit schematic

Project directory: AD \ Test \ 2020 \ STCTest \ AutoDL

(1) Circuit diagram

The schematic diagram of the fully automatic program download interface board is shown in the figure below.
▲ Fully automatic program download interface board

▲ 全自动程序下载接口板

(2) Circuit function description

The timer is designed using Schmidt inverter 74HC14. Since HC14 includes six identical inverters, only three are required in practice. Therefore, in order to ensure the reliability of the work and close to the ideal state, the six inverters in HC14 are connected in parallel into three inverters.

The first group of inverters isolates the TXD signal and drives the diode + RC circuit behind. Diode D1, resistor R11, capacitors C1, C2 form a repeatable monostable circuit. After the second group of inverters are shaped, the latter monostable timer is driven.

The second group of timers is composed of capacitor C20, resistors R12 and D3, and finally forms a switching pulse through the third group of inverters, and drives the relay RL1 through the transistor T1 to complete the disconnection and access of the microcontroller power supply.

The RXD signal output by the PL2303 is also connected to the microcontroller through another set of switches in the relay RL1. This also ensures that when the microcontroller is powered off, RXD will not power the microcontroller. The TXD of the PL2303 is still connected to the microcontroller through the diode D2, which can not supply power to the microcontroller when the microcontroller is powered off.

(3) Auxiliary circuit function

In addition to the above main circuit functions, the button BTN1 can realize the manual control of the switch of the relay, and manually control the download process when necessary.

The light-emitting diode LED shows the state of the monostable circuit that can be triggered repeatedly. When it is off, the next program download can be performed; when the LED is on, it means that the previous download process has not been completed, and the download program cannot be performed at this time.

4. PCB board

Draw the experimental circuit, in order to be suitable for rapid single-sided plate making, the layout and wiring of circuit components are considered. If you use a commercial plate, you can consider arranging components on both sides to further reduce the circuit area.

▲ Fully automatic program download interface PCB board

▲ 全自动程序下载接口PCB板

After rapid plate making and welding, the test version of the circuit is downloaded automatically. As shown below:

▲ Test circuit board after rapid plate making

▲ 快速制版后的测试电路板

According to the schematic design, the function definition of the five leads of the download board is shown in the following table:

Serial number Features symbol
1 Working power +5V
2 MCU power supply + 5VC
3 Bottom line GND
4 Serial input RXD
5 Serial output TXD

 

function test

1. Test SCM system

Use the experimental board of STM15W415AS single-chip microcomputer as the test, and use the breadboard to fix the single-chip microcomputer circuit board. Connect the interface of the download board to the power supply of the test MCU board and the download serial port line through the breadboard.

▲ Fully automatic download board and test circuit

▲ 全自动下载板与测试电路

2. Test process

Set up STC's ISP program, select the MCU model, and load into the test program. Set the minimum baud rate to 19200 and the maximum baud rate to 115200.

(1) Test download program

Press the download / program button to start downloading the program. At this time, the relay on the download board will automatically turn off for one second, and then power on again. After the ISP program completes the handshake signal, the MCU is erased and programmed. When the operation is successful, the LED on the download board goes out after about 2 seconds. Then you can download the next program.

▲ Automatic download program

▲ 自动下载程序

(2) Test "detect MCU option"

Press "Check MCU options", you can automatically complete the MCU option test.

 

summary

In the development of single chip microcomputer, in order to simplify the debugging process, the development and verification process of the program can be completed through an iterative " download-run " process. Using a fully automatic download circuit board can avoid manual switches during program download and improve the efficiency of program development.

The STC-ISP program includes the option " Automatically load and send download commands when the target file changes ". With this option, you can automatically trigger the ISP program to download after the program development IDE finishes compiling the project file. At this time, the automatic download board omits the original manual control of the power supply, realizing the automatic process of program modification-compile-download-observation, which improves the efficiency of program development.

The AltiumDesign project file of the circuit board involved in this article can be downloaded from CSDN.

Published 438 original articles · praised 515 · 120,000 views

Guess you like

Origin blog.csdn.net/zhuoqingjoking97298/article/details/105457285