Home > Power Circuits > Research on the one-click download circuit of CH340 in STM32

Research on the one-click download circuit of CH340 in STM32

Source: InternetPublisher:三月小雨 Keywords: Power supply regulated power supply Updated: 2020/03/21

When working on the project of a multi-functional MP3 player based on STM32, I used the one-click download circuit on the Zhengdian Atom development board for the program download part, and used the CH340G chip design.

When I was drawing the early PCB schematic diagram, I didn't know much about the one-click download circuit designed with CH340G, so I spent some time studying this circuit.

Quoting the one-click download circuit of punctual atoms:

 

Research on the one-click download circuit of CH340 in STM32

 

 

We use the two output signals RTS# and DTR# to control the BOOT0 and BOOT1 pins of the STM32 IC to select the startup mode, as shown in the following table:

 

Research on the one-click download circuit of CH340 in STM32

 

 

When programming the program, we hope that BOOT0=1 and BOOT1=0. When the programming is completed, we hope that BOOT0=0 and BOOT1=0 (in this mode, BOOT1 can be 0 or 1. Here we let BOOT1 be pulled low, that is, BOOT1 is grounded to L during the entire process, simplifying the circuit design). Here we only need to consider the level of BOOT0.

View the STM32 reference manual, as shown below:

 

Research on the one-click download circuit of CH340 in STM32

 

 

Pay attention to the first sentence at the bottom of Table 6: "After the system is reset, the value of the BOOT pin will be latched on the fourth rising edge of SYSCLK."

OK, to sum up the above, we can get:

1. When the system is powered on, BOOT0 needs to be L to enter mode one. After power-on reset, on the fourth rising edge of SYSCLK, the value of the BOOT pin will be latched and entered into the main flash memory to execute the code we programmed.

2. When we compile the program, a HEX file is generated. When programming HEX files, BOOT0 needs to be H to enter mode two. Then, the system must be reset once (because it is known from 1 that the system executes the code by default after power-on, that is, mode 1) to allow the system to re-latch the BOOT pin. The system enters mode two and begins to program the HEX file.

3. After programming is completed, we hope that the system will enter mode one again and execute the code. However, the one-click download circuit of Zhengdian Atom does not allow the system to reset and re-latch the BOOT pin to enter mode one after completing the programming process. The reason for this should be that the MCUISP software has configured it for us. After the programming is completed, there will be a report: "Successfully started running from 08000000." There is this passage in the reference manual:

 

Research on the one-click download circuit of CH340 in STM32

 

 

To understand it from another direction, we can say: the main flash memory is accessed from the address (0x0800 0000), whether it is automatic by the system or configured by software, as long as the system pointer jumps to the address of the main flash memory (0x0800 0000) and starts execution The code is fine and the result is what we want.

The above are the functions that need to be implemented in the one-click download circuit. Brother Atom helped us design it. If you don’t understand, you can refer to my explanation below.

We need to pay attention to one thing: DTR# and RTS# are both high level after CH340G is powered on. When using MCUISP to program the software, we select "DTR low level reset, RTS high level enter BootLoader" under the software, CH340G The pin changes of the IC during actual operation are "DTR# is pulled high and RTS# is pulled low", that is, the software setting and the actual situation are negligible and opposite.

Draw a timing diagram to be more intuitive:

 

Research on the one-click download circuit of CH340 in STM32

 

 

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号