Detailed Explanation of STM32 Microcontroller Minimum System

STM32F103RCT6:

STM32F103RCT6 is an embedded microcontroller integrated circuit (IC) with a 32-bit Cortex-M3 core processor, a speed of 72MHz, a program memory capacity of 256KB, program memory type of FLASH, RAM capacity of 48K, and package LQFP64.

Detailed Explanation of STM32 Microcontroller Minimum System

Detailed Explanation of STM32 Microcontroller Minimum System

STM32 Microcontroller Naming Rules:

Detailed Explanation of STM32 Microcontroller Minimum System

Minimum System of STM32 Microcontroller:

The so-called minimum system of the microcontroller is a system composed of the least and essential components that allow the microcontroller to operate normally.
After powering up the minimum system, the microcontroller can reset normally and download programs; apart from that, there are no other functions.
Based on the correctness of the minimum system, other functional modules or components can be added sequentially to give the microcontroller practical functions.
The minimum system of the STM32 microcontroller includes a reset circuit and a clock circuit, as shown in Figure 1.
The reset circuit in the figure uses a power-on reset circuit; if the NRST pin of the STM32 microcontroller inputs a low level, a reset occurs.

Detailed Explanation of STM32 Microcontroller Minimum System

Figure1: STM32F103Microcontroller Minimum System

Power Pins:

VDD is the positive terminal of the digital power supply for the microcontroller, and VSS is the negative terminal of the digital power supply, with 5 VDD pins and 5 VSS pins in total. VDDA is the positive terminal of the analog power supply for the microcontroller, responsible for powering the internal ADC and DAC modules, while VSSA is the negative terminal of the analog power supply.
There is also a power pin, VBAT, which connects to the positive terminal of the battery. The STM32 has RTC (Real-Time Clock) functionality, hence the presence of the VBAT pin.
The schematic reserves a CR1220 button lithium battery; when the main power supply is present, VCC3.3 from the system supplies power to VBAT;
When the main power is cut off, the CR1220 button battery powers the STM32’s built-in RTC module, ensuring that the real-time clock module can continue to function normally even when the main power is down.
However, this design presents a contradiction that needs to be addressed. If the VBAT pin is directly connected to VCC3.3 and CR1220, the following issues arise:
1. When the battery voltage is higher than 3.3V, the battery will output current to AMS1117, causing the chip to overheat and rapidly depleting the battery.
2. If the battery voltage is lower than 3.3V, the 3.3V produced by AMS1117 will charge the battery, which is not rechargeable.
To solve the above issues, we designed the power supply circuit of the VBAT pin as follows:

Detailed Explanation of STM32 Microcontroller Minimum System

D1 prevents current from the battery from flowing to AMS1117, and D2 prevents the 3.3V produced by AMS1117 from flowing to the battery.
This design utilizes the “unidirectional conduction property of diodes”.
In normal product design, it is best to place a 0.1uF capacitor filter next to each power pin to filter out power noise and ripple.

Reset Pin NRST:

A reset is a restart. The STM32 reset pin is low-level reset; in normal operating state, the reset pin is high-level.

Detailed Explanation of STM32 Microcontroller Minimum System

The purpose of setting and resetting the microcontroller is to initialize the circuit to a defined state.During reset, the microcontroller will load the storage devices and some registers with values preset by the manufacturer.
Generally speaking, the role of the microcontroller reset circuit is to initialize a state machine to an empty state.

The principle of achieving power-on reset for the microcontroller:

External capacitor and resistor are connected to the reset pin NRST.
When the reset level (low level) lasts for more than two machine cycles, the reset is valid; after the system powers on, the low level will be maintained for a period due to the charging of the capacitor to reset the microcontroller.
Immediately after powering on, the voltage across the capacitor is 0, i.e., low-level reset; the RC circuit has a charging curve (i.e., the voltage change curve across the capacitor), and the microcontroller recognizes the external level with a connecting voltage, ensuring that the time for the capacitor voltage to charge to the microcontroller’s critical voltage is greater than two machine cycles to meet the microcontroller’s reset condition;
When the 3.3V power is applied to VCC3.3, the RC circuit is turned on, and the potential difference between NRST and ground is the potential difference between the capacitor and ground. The potential difference between NRST and ground will only reach 3.3V after the capacitor is fully charged, so during the charging process of the capacitor, the signal to the chip pins is low level.
According to the RC circuit charging equation V(t)=U+A*e-(t/RC), as long as the values of R and C are chosen reasonably, the charging time can be guaranteed to be greater than the time required for the chip reset. We generally choose a 10K resistor for R and a 0.1uF capacitor for C.

Crystal Oscillator Pins:

STM32 has two sets of crystal oscillators, one set provides the main clock for the microcontroller (5: OSC_IN, 6: OSC_OUT), using an 8MHz crystal oscillator (to facilitate internal frequency multiplication, an 8MHz crystal is generally selected).
The other set provides the clock for the RTC (3: OSC32_IN, 4: OSC32_OUT), where the RTC clock crystal needs to connect to a 32.768K crystal. You can look up why 32.768KHz is used online.
In practical applications, if the RTC function is not used, the RTC crystal does not need to be connected.
The clock circuit of the STM32 is divided into internal and external clock modes.
An external clock is added between OSC_IN and OSC_OUT with a crystal oscillator, allowing the internal oscillator of the microcontroller to generate self-excited oscillation to produce clock signals, with 20-30pF ceramic capacitors added on both sides of the crystal oscillator to fine-tune the clock frequency and stabilize it.
The internal clock is generated by the STM32’s internal clock, so if an external crystal oscillator is not used, it can also be left unconnected. The internal clock uses the chip’s internal oscillation circuit, which has low precision and large temperature drift, and does not require external oscillation components.

Detailed Explanation of STM32 Microcontroller Minimum System

BOOT Pins:

STM32 has two BOOT pins, BOOT0 and BOOT1. The high and low levels of these two pins determine the startup and running modes of the microcontroller.

Detailed Explanation of STM32 Microcontroller Minimum System

The first startup mode (BOOT1=X, BOOT0=0) is the most commonly used user FLASH startup.This is the default startup mode.
The second startup mode (BOOT1=0, BOOT0=1) is the system memory startup mode. The BootLoader built into the STM32 (commonly referred to as the ISP program) operates in this startup mode; if a hardware error occurs in the program, switching BOOT0 to 1 allows reprogramming of Flash to restore normal operation. The content in the BootLoader area cannot be modified or erased after the chip leaves the factory, making it a ROM area.
The third startup mode (BOOT1=1, BOOT0=1) is the embedded SRAM startup of the STM32. This mode is used for debugging.

Detailed Explanation of STM32 Microcontroller Minimum System

Detailed Explanation of STM32 Microcontroller Minimum System

Generally, I always connect BOOT0 and BOOT1 to ground.
The above covers all the contents of the minimum system; of course, the above parts alone are not enough, and a general minimum system also includes the following components:

Power Circuit:

Since STM32 microcontrollers generally operate at 3.3V, while commonly available power supplies in daily life are 5V (such as USB ports on computers, mobile phone chargers, power banks…), an AMS1117-3.3V voltage regulator chip is generally used to step down 5V to 3.3V; this chip is typically packaged in SOT223.

Detailed Explanation of STM32 Microcontroller Minimum System

Download Circuit:

In addition to the above parts, a download circuit is also required. The STM32 has several download methods:
(1) Serial Download
Using serial download requires the microcontroller to have corresponding program support, and a program is placed in the system memory, written by ST on the production line, to allow reprogramming of the flash memory through the available serial interface.
In system memory startup mode, the firmware provided in the manufacturer’s BootLoader supports serial download programs, allowing programs to be downloaded to the system Flash. The program is burned into FLASH.
Note: Using this method requires BOOT0=1, meaning that external circuit support is needed to achieve serial download.
(2) JLINK or STLINK Download
Generally, we use JTAG or SWD mode to download programs, but hereit is recommended to use SWD mode for downloading, which only requires three pins (GND, SWCLK, SWDIO) to achieve program download functionality.

Detailed Explanation of STM32 Microcontroller Minimum System

END
Source: Programmer Xiao Ha
Copyright belongs to the original author, if there is infringement, please contact for deletion.
Recommended Reading
Why is Russia not worried about chip embargo?
Highlights of several software written by Russian masters: the last one is my childhood
Huawei’s “Genius Boy” homemade cute robot: GitHub has gained 317 stars!
→ Follow for updates ←

Leave a Comment

×