Hello! Welcome to Embedic!
This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Embedded Events > The Overview of STM32F103 microcontroller Newly Updated 2023

The Overview of STM32F103 microcontroller Newly Updated 2023

Date: 04-02-2023 ClickCount: 697

STM32F103 Microcontroller Overview

 

ARM's products after ARM11 are named after Cortex and are divided into three main types, Cortex-M series, Cortex-R series and Cortex-A series.

 

The Cortex series belongs to the ARMv7 architecture, which is the latest instruction set architecture of ARM until 2010, where Cortex-M is mainly used in low-end embedded Cortex-M is mainly used in low-end embedded control systems, Cortex-R is mainly used in real-time systems, and Cortex-A series is used in operating systems, smart devices and cell phones, such as the common Cortex-A15 (used in Android, Ubuntu and other systems).

 

STM32 developed by ST belongs to Cortex-M architecture, which can be subdivided into M0, M0+, M3, H7, etc. Take the most common STM32F103 as an example, this chip belongs to Cortex-M3 architecture, with 72MHz CPU main frequency, built-in high-precision ADC, USART, CAN, USB, SDIO, etc. modules, which greatly facilitates the design of products.

 

The Clock Tree of STM32F103

 

The STM32F103 is a very cost-effective chip with a clock tree that looks like this.

clock tree of stm32f103

It has four clock sources, with different clocks for different scenarios:

  • HSE high-speed external clock source, i.e. the frequency comes from outside the chip
  • HSI high-speed internal clock source
  • LSI low-speed internal clock source
  • LSE low-speed external clock source, that is, the frequency from off-chip

Combined with the STM32CubeMX, it is much easier to understand.

 

stm32cubemx

 

The diagram is from STM32CubeMX, where the green oval box indicates the clock source and the red box indicates several internal logic implementations common to the clock tree.

 

From top to bottom are the clock selector, clock divider, and clock multiplier.

 

stm32cubemx1

If HSE or HSI is required, both need to be set up with their corresponding pins. After all, certain settings are different for the clock input pin and other pins.

 

Introduction of STM32F103ZET6

 

Take STM32F103ZET6 as an example, the chip package is LQFP-144, and the built-in resources are shown below.

 

stm32f103zet6

(1) one group of 17-channel high-precision ADC, one group of 15-channel ADC, and one group of 13-channel ADC with conversion speed up to 1us.

 

(2) 1 group of 2 DAC outputs.

 

(3) 8 groups of advanced timers (can do capacitor capture, PWM output, basic timing and other functions).

 

(4) high-precision RTC module, 2-way clock optional.

 

(5) 1 group of CAN, supporting any baud rate.

 

(6) 2 groups of hardware IIC.

 

(7) 3 groups of hardware SPI.

 

(8) 5 groups of serial ports

 

(9) 1 group SDIO module for external SD card communication

 

(10) 1 group of USB modules, can be the host, can be the slave

 

(11) 2 groups of I2S modules for I2S communication

 

(12) 1 group of CRC modules.

 

(13) 2 groups of watchdog modules.

 

(14) 1 group of DMA modules.

 

The STM32F103ZET6 physical picture is shown in the following figure.

 

STM32F103ZET6 minimum system

 

1. Schematic

 

stm32f103zet6 schematic

The STM32F103 minimal system consists of a backup power supply, download interface, filter capacitor, boot terminal and clock circuit, where the filter capacitor is mainly used to stabilize the CPU power port voltage, as there are 12 groups of CPU power ports, so the 12 100nF capacitors are used to stabilize the voltage of each port, when wiring, each capacitor is as close to the power supply port as possible.

 

2. Clock Circuit

stm32f103zet6 clock circuit

The microcontroller minimum system has two crystal oscillators, where 8MHz provides the main system operating clock pulse, which is the operating clock for the CPU core, system bus and other peripherals except the RTC clock, and the 32.768KHz clock is dedicated to the CPU internal RTC clock pulse.

 

3. Reset Circuit

stm32f103zet6 reset circuit

As the STM32F103 belongs to low-level reset, so the circuit shown above is designed to reset, the voltage across the capacitor in the initial state is 0, which is equivalent to low level, after power on, the capacitor starts to charge, with the rise of charging time, the voltage across the capacitor shows an exponential rise (this part is specially explained in the circuit analysis), as the capacitor is fully charged, the theoretical voltage across the capacitor gradually reaches 3.3 V, at this time the reset is over, if you want to reset without power, you only need to press button S1, after pressing the button, the capacitor discharges to ground, after discharging, it reaches low level, at this time it starts to reset, then repeat the process of power-on reset.

 

4. Start Select Port

 

The STM32 has three boot methods, selected by the levels of BOOT0 and BOOT1.

 

Generally the startup program is started in FLASH, if there is a chip into low power mode or the debug port is disabled, then serial port activation is the only way, so it is recommended to design the product with BOOT0 and BOOT1 pins led out with 0Ω resistors.

 

5. VBAT power supply

 

vbat power supply

VBAT power supply is mainly used for RTC and backup area data not to lose use, when the external 3.3V power failure, diode D1 is in the cut-off state, at this time D2 negative terminal is at the level, diode D2 positive conductor, through the 3V coin cell to VBAT power supply, to prevent RTC and backup area data loss.

 

6. Serial port download and SW simulation

 

STM32 download program in two ways, one is the traditional serial port mode, through BOOT0 and BOOT1 to start the system memory, and then burn the program into FLASH, then power off, set the FLASH to start the program, there is a special way, is SW mode, SW mode a single line FLASH burn mode, through CLK and DATA two lines, the program directly burned into FLASH, and through these two lines for online emulation, you can directly read all the values of all the registers in the CPU in real time, for simplifying the debugging process. This function is not available in 51 microcontroller.

 

7. Power Circuit

power circuit

The STM32F103 is powered by a 3.3V power supply, but generally the USB interface or rechargeable battery outputs DC5V, which requires an LDO to perform a voltage conversion to convert 5V to 3.3V for the STM32.

 

STM32 project creation

 

The STM32 program can also be written using the 51 IDE. KEIL, as an integrated development environment, is now available for most mainstream CPUs, such as the previous 51 series, the current ST series, and the NXP iMX series, etc. The following explains how to use KEIL to create STM32 programs.

 

STM32 project is different from 51 project, need several files to support, because this time to create a blank project, so only need to create the main function of the c file, start assembly file, and STM32 register file.

 

(1) Install the ARM version of KEIL, download the installation package from the KEIL website or the link attached to the text, remember that there can be no Chinese path when installing, just install it directly.

 

(2) Install the STM32F1 series firmware library, find the installation package from the KEIL official website, download and install (Note: KEIL version must be the ARM version, the C51 version can not be installed).

 

After downloading the firmware library, double click to install it.

 

(3) Create four sub-folders in the project folder, HEADERWARE, OBJECT, USER and SYSTEM, the contents of each folder are shown below.

 

USER: store the project files, assembly startup files and c files of main functions

 

SYSTEM: holds system files, serial port 1 files and ticking clock files

 

HEADERWARE: stores other driver files

 

OBJECT: holds the link file of the compilation process and the final HEX file

 

hex file

(4) Create a new project, enter the project save path and click save.

 

(5) Select the target chip model, the chip model we use is STM32F103ZET6

 

(6) Click project settings, add system folder

 

Click on the location selected in the red box to create a new folder, double click on the new folder to modify the name and create the same folder as the directory in step 3, as shown in the figure below.

 

(7) Create the startup assembly file

 

Click Save, enter the file name stm32f103x.s and save it into the User folder.

 

Enter the following code, as the following code is fixed, so you can copy it directly

 

(8) Modify the save path of link file and HEX file

 

Modify the save path of HEX

 

Modify the save path of the link file

 

(9) Create the c file of the main function, the steps are the same as step 7, except that when saving, the file suffix is changed to c, for example, 1.c. Save the c file of the main function to the User directory

 

(10) Enter the following code under the c file

 

(11) Add the two files you just created to the project

 

manage project items

  • [Solved] How to Reduce the Power Consumption of MCU 2023
  • Microcontroller-Based Machine Learning Use Cases

Author

Kristina Moyes is an experienced writer who has been working in the electronics industry for the past five years. With a deep passion for electronics and the industry as a whole, she has written numerous articles on a wide range of topics related to electronic products and their development. Kristina's knowledge and expertise in the field have earned her a reputation as a trusted and reliable source of information for readers interested in the latest advancements in electronics.

Hot Products

  • TMS320C6678XCYP25

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 841FCBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320C6748BZWTD4E

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 361NFBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320C6745CPTPD4

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 176HLQFP

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • PIC16F1939-I/MV

    Manufacturer: Microchip

    IC MCU 8BIT 28KB FLASH 40UQFN

    Product Categories: 8bit MCU

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty