No programmer needed to program an MCU? This circuit allows for automatic one-click downloading!
Article Overview
This article introduces a debugger design scheme for one-click automatic downloading of MCU programs using a USB -to -TTL serial port . It focuses on elaborating on the online programming of blank circuit board components through ISP ( In-System Programming ) technology. Taking the STM32F103 microcontroller as an example, the article designs a one-click download circuit, introduces its various components and the specific implementation method, and verifies the feasibility and practicality of the circuit through experiments.
In daily development and debugging, we often use programmers like J-Link to download programs to the MCU . Today, General Circuits is sharing a debugger that can automatically download programs with one click, which is also a USB to TTL serial port automatic download circuit.
What is automatic download? Automatic download is ISP ( In-System Programming ), which means that blank devices with boot code on the circuit board can be programmed with end-user code. This is achieved by online programming of the MCU 's internal user area Flash memory through a dedicated programming interface (usually a serial port) .
Besides its use in scheduled debugging, this automatic download method is more suitable for mass production programming and remote OTA firmware upgrades. Familiar MCUs such as the STM32 series, ESP32/ESP8266 , Arduino , NXP LPC series, and many domestic MCUs are all supported.
Taking the STM32F103 microcontroller as an example, the STM32 microcontroller's datasheet describes the boot module as implementing three different modes by configuring the BOOT[1:0] pins:
The last one is the ISP automatic download mode.
Knowing the ISP startup conditions, we can design a one-click download circuit.
Our circuit design uses a USB- to -TTL serial port converter. On a PC , a serial port download tool is used to download the firmware to the MCU . The MCU is then set to ISP boot mode via BOOT1/0 . The MCU runs its built-in bootloader, which is factory-written and cannot be modified; it can only be read. This program writes the hex file received from the serial port to the Flash memory starting with 0 × 08000000 in the user area, thus enabling the user firmware download function.
The serial port auto-downloader mainly consists of the following circuits:
1. Power supply circuit :
The VBUS-5V output from the J1 TYPE-C interface provides a stable 5V DC voltage to the FT232RL through the resettable fuse F1 and filter capacitors C2 and C3 . R1 and D1 are LED indicator lights for easy observation of whether there is a 5V input. The resettable fuse F1 here is the first-level power protection. The first-level power conversion is that the VBUS-5V is converted to 3.3V through the AMS1117-3.3 LDO to provide a stable DC power to the peripherals.
2. USB to TTL-UART circuit :
The familiar FT232 interface chip is used. This chip is stable and has built-in RXD/TXD transmit/receive pin status outputs. We can use this transmit/receive status output function to add serial port data transmit/receive LED indicators D2/D3 , making it easier for us to see the received and transmitted data more intuitively. D4/D5 is a BAV99 diode protection circuit, which plays a clamping protection role here to prevent the voltage of the RXD/TXD pins from being too high and avoid damage to the interface chip due to excessive voltage.
3. External interface:
This component has three 2.54mm header pins (J2, J4, J6) used to connect to peripherals such as the STM32 development board or core board's power supply , BOOT0 , and RESET pins to complete the serial program download for the microcontroller .
4. One-click automatic download circuit :
Composed of Q1/Q2/D4/R10/R11 , this circuit controls the one-click download circuit via the DTR# and RTS# pins of the FT232 serial-to- USB interface chip . This, in turn, controls the high and low levels of the RESET and BOOT0 pins of the STM32 connected to the circuit, guiding the STM32's built-in BootLoader program into ISP mode. Combined with the STM32 's BOOT0 and RESET pins, it achieves one-click download and execution via serial port, eliminating the need to purchase an emulator and making program downloading simple and convenient.
The principle is as follows : The development board defaults to BOOT1 being 0 and BOOT0 being 0. To enable the STM32 serial port ISP download mode, BOOT0 needs to be set to 1. When RTS is low, the SS8550 transistor Q1 meets the conduction condition and turns on. The 3.3V voltage is pulled high through Q1 to the BOOT0 pin, so BOOT0 outputs a high level ( 1) . The reset circuit NRST is high by default, resetting the STM32 via DTR , putting the system into ISP mode. The STM32 system memory then starts the BootLoader . The BootLoader program , ST 's built-in bootloader, downloads the program from the serial port to the Flash memory. Thus, the program is actually downloaded to the Flash memory via the serial port . The host computer automatically controls the RTS and DTR pins, controlling BOOT0 and NRST . BOOT0 is set to 0 , and NRST is set to 1 , allowing the program to boot from the Flash memory .
Next, we will use experiments to verify whether the circuit we designed is feasible.
First, open the software:
Prepare to download the program:
① Select "Port " ( FlyMcu will automatically search for the port corresponding to the FT232RL serial port), and set it to " 115200bps ".
② Select the program file to download ( the .hex file generated by compilation).
③ Check "Reload files before programming". FlyMcu will reload the .hex files before each programming session , which is useful when debugging code.
④ Check "Execute after programming" to automatically run the code after the program is downloaded, eliminating the need to press the reset button to run the code, which facilitates code debugging.
Special Note: Do not select "Use RamIsp ", as using RamIsp may cause download failures. Do not select " Write option bytes when programming to FLASH ".
⑤ In the lower left corner, select " Reset DTR low level, enter BootLoader high level ". FlyMCU will control the onboard one-click download function circuit through the DTR and RTS signals to realize the one-click download function. This is a necessary option ( provided that BOOT0 is connected to GND ).
Once the settings are complete, you can start downloading.
Due to time constraints, we will only demonstrate this one application. This serial port module can also download programs to Arduino with one click, and has many other functions such as serial port debugging!
Editor's Note
"Star" us to stay updated on fresh case studies and industry insights.











京公网安备 11010802033920号