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:
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:
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:
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:
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:
- Using Lead-acid Battery as Power Source for Walkman
- Step-down power supply for driving relays
- Visible laser digital control modulation driver
- Principles and precautions of active discharge circuit
- LNK304 non-isolated LED light string driver circuit
- Low cost and high performance LED constant current power supply
- Miniature polarity reversal power supply using MAX1721
- Adjustable voltage power socket
- Homemade home inverter circuit diagram
- Lead-acid battery overcharge and over-discharge protection circuit
- Excellent performance household inverter power supply circuit
- Portable device charging power circuit design
- 2-phase CPU power supply circuit using HIP6302 and HIP6602 chips
- KGDS type single-phase low temperature iron plated power supply circuit
- 300A-18V three-phase thyristor voltage regulating electrolytic power supply circuit
- Transistor stabilized current power supply circuit 2
- Diamond differential input power amplifier power circuit
- Industrial four-way programmable controller power circuit
- Household emergency power circuit 02
- CASPER TM-5158 VGA color display power supply circuit