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 > Introduction to STM32 Microcontroller and How to Program 2023

Introduction to STM32 Microcontroller and How to Program 2023

Date: 25-05-2023 ClickCount: 934

The STM32 microcontroller series, developed by STMicroelectronics, is a highly popular and widely used family of microcontrollers in the embedded systems industry. Renowned for their versatility, performance, and extensive range of features, STM32 microcontrollers have become the go-to choice for a diverse range of applications, including consumer electronics, industrial automation, Internet of Things (IoT) devices, and more.

 

 

In this article, we will explore the key features, capabilities, and advantages of STM32 microcontrollers, highlighting their significance in driving innovation and powering advanced electronic systems.

 

Part 1. Introduction to STM32 Microcontroller

 

The STM32 microcontroller is a popular family of microcontrollers developed by STMicroelectronics. It is based on the ARM Cortex-M processor cores and is widely used in various embedded systems applications. The STM32 microcontrollers offer a wide range of performance, features, and peripherals to cater to different application requirements.

 

stm32

The STM32 microcontrollers are known for their low power consumption, high processing capabilities, and extensive peripheral options. They come in different series, such as STM32F, STM32L, STM32H, and STM32G, targeting different market segments and applications.

 

Description of STM32 model: Take the STM32F103RBT6 model chip as an example, the model consists of seven parts, and its naming rules are as follows:

1

STM32 

STM32 stands for the 32-bit microcontroller with ARM Cortex-M core

2 F

F stands for chip sub-series

3 103

103 represents the enhancement series

4 R

R This item represents the number of pins, where T stands for 36 pins, C stands for 48 pins, R stands for 64 pins, V stands for 100 pins, Z stands for 144 pins, and I stands for 176 pins.

5 B

B represents the embedded Flash capacity, where 6 represents 32K bytes of Flash, 8 represents 64K bytes of Flash, B represents 128K bytes of Flash, C represents 256K bytes of Flash, D represents 384K bytes of Flash, E represents 512K bytes of Flash, and G represents 1M bytes of Flash.

6 T

T This item represents package, where H represents BGA package, T represents LQFP package, and U represents VFQFPN package.

7 6

6 This item represents the operating temperature range, where 6 represents -40 to 85°C and 7 represents -40 to 105°C.

 

1. STM32 Series Features

 

-High performance: The STM32 family of microcontrollers features the ARM Cortex-M core for excellent processing performance and runtime. In addition, they have large Flash memory and SRAM memory to easily handle complex applications.

 

-Rich peripherals: STM32 series microcontrollers have rich peripherals, including multiple timers, counters, PWM outputs, ADCs, DACs, communication interfaces, and more. These peripherals can help developers achieve a variety of different application requirements.

 

-Low power consumption: The STM32 family of microcontrollers uses advanced low-power technology to reduce power consumption without compromising performance. This makes them ideal for use in devices that need to run for long periods of time, or need to be battery powered.

 

-Easy to develop: STM32 provides a rich set of software and hardware tools to help developers quickly develop embedded applications. Some of the easy-to-use tools are as follows:

 

  • STM32CubeIDE: Integrated Development Environment (IDE), including debugger and code generator, for developing STM32-based embedded systems. It provides an easy-to-use method to create, configure and generate C code, as well as debug and test embedded applications.
  • STM32CubeMX: A graphical configuration tool for the STM32 family of microcontrollers that helps developers quickly generate initialization code and configuration files.

 

-HAL Library: The HAL (Hardware Abstraction Layer) library is a low-level driver for the STM32 family of microcontrollers that provides a set of reusable APIs to speed up the development process and improve code reusability.

In addition, STMicroelectronics provides a variety of support documentation and training courses to help developers better use the STM32 family of microcontrollers.

 

2. STM32 Family Performance Metrics

 

#1. Cores

The STM32 family uses a variety of ARM Cortex-M cores, including Cortex-M0, Cortex-M3, Cortex-M4, etc., with different performance and functional characteristics, which can be selected according to the needs of the application scenario.

 

#2. Clocking

The STM32 family supports a variety of clock sources, including internal RC oscillators, internal crystal oscillators, external crystal oscillators, etc., which can be selected according to the needs of the application scenario. Various clock dividers and clock outputs are also supported.

 

#3. Memory

The STM32 family supports a variety of memory types, including Flash memory, RAM memory, EEPROM memory, etc., which can be selected according to the needs of the application scenario. Various memory protection and memory mapping functions are also supported.

 

#4. STM32 Series Supports Multiple Communications

The STM32 family also supports a variety of communication protocols such as SPI, I2C, CAN, USART, and more. This makes the STM32 family ideal for a variety of applications, especially those that require communication with other devices or modules.

 

#5. SPI: Serial Peripheral Interface (SPI) is a serial communication bus. the STM32 family supports unidirectional and bidirectional SPI communication, as well as multiple host and slave configurations of SPI. SPI is typically used to communicate with devices such as sensors, memories, and displays.

 

#6. I2C: The I2C (Inter-Integrated Circuit) bus is a bi-directional serial bus. the STM32 family supports standard mode, fast mode, and high-speed mode I2C communications, as well as host and slave configurations of I2C. I2C is typically used to communicate with a variety of sensors, memories, and other digital devices.

 

#7. CAN: Controller Area Network (CAN) is a high-speed, robust bus protocol typically used for control and communication in automotive and industrial applications. the STM32 family supports standard and extended CAN communication with multiple filter and receive FIFOs.

 

#8. USART: Universal Synchronous/Asynchronous Receiver/Transmitter is a universal serial communication interface.The STM32 family supports various USART modes, including asynchronous, synchronous, unidirectional and bidirectional communication.

 

These communication protocols make the STM32 family very flexible and can be adapted to a variety of different application requirements.

 

3. Applications of STM32

 

The STM32 family of microcontrollers is used in a wide range of applications, mainly in industrial automation, home appliances, communications, automotive electronics, medical devices, aerospace and other fields. The following are some common application scenarios:

 

Industrial Automation

The STM32 family of microcontrollers is used in a wide range of industrial automation applications, such as controlling various types of robots, PLCs, inverters, motor controllers, electronic scales, and so on. These applications usually require high precision, high speed, high reliability and rich peripheral resources, and the STM32 series microcontrollers can meet these needs.

 

Home Appliances

The STM32 family of microcontrollers is also widely used in home appliances, such as smart homes, smart TVs, smart stereos, smart door locks, air conditioners, and more. These applications require low power consumption, high performance, multi-interface and multi-protocol support, and the STM32 family of microcontrollers can meet these needs.

 

Communication

The STM32 family of microcontrollers also has a wide range of applications in the field of communications, such as wireless communication modules, Bluetooth modules, GPS modules, and so on. These applications require high speed, low power consumption, multi-interface and multi-protocol support, and the STM32 family of microcontrollers can meet these needs.

 

Automotive Electronics

The STM32 family of microcontrollers is also widely used in automotive electronics, such as car control units, car navigation, car audio, and so on. These applications require high temperature, low power consumption, anti-interference and multi-protocol support, and the STM32 family of microcontrollers can meet these needs.

 

Medical Devices

STM32 series microcontrollers are also widely used in medical devices, such as blood glucose meters, electrocardiographs, blood pressure meters, thermometers, and so on. These applications require high accuracy, high reliability, low power consumption and multi-interface support, and the STM32 family of microcontrollers can meet these needs.

 

Aerospace

The STM32 family of microcontrollers also has a wide range of applications in the aerospace field, such as aircraft control, navigation, communications, and more. These applications require high reliability, high tolerance, high performance and low power consumption, and the STM32 family of microcontrollers can meet these needs.

 

You may like:  ESP32 vs STM32, Which is Better and How to Choose 2022

 

Part 2. Difference between STM32 microcontroller and 51 microcontroller

 

1. 51 Microcontroller Introduction

 

The 51 microcontroller is a microcontroller chip designed based on the Intel 8051 instruction set architecture. The chip is manufactured with CMOS technology and has built-in 4K to 64K bytes of Flash program memory, 128 to 256 bytes of RAM data memory and various peripheral modules, including timers, counters, serial ports, parallel ports, etc. It can be widely used in various control and embedded systems.

 

The 51 microcontroller is easy to learn, resourceful, and easy to expand, and is widely used in various industrial control, instrumentation, home appliances, communication devices, electronic games, electronic toys, medical devices, and other fields. Its instruction set is simple, easy to master, and the program writing is relatively simple, so it has been widely promoted and applied.

 

At present, 51 microcontrollers have developed into a series of product lines, including basic, enhanced, high performance, low power consumption and other series to meet the needs of different fields. At the same time, there are also many third-party vendors that provide a wealth of development tools and supporting equipment, making it easier for developers to use the microcontroller for development and debugging.

 

2. Difference between STM32 and 51 Microcontroller

 

STM32 and 51 microcontrollers are two different kinds of microcontrollers, which have the following differences:

 

Architecture: The 51 microcontroller is based on the Intel 8051 architecture, while the STM32 is based on the ARM Cortex-M architecture. the ARM Cortex-M architecture is more advanced than the Intel 8051 architecture, offering higher performance and more powerful features.

 

Performance: Due to the difference in architecture, the STM32 offers higher performance than the 51 microcontroller. STM32 can run faster clock frequencies and supports more memory capacity and peripherals.

 

Development environment: STM32 provides more complete development tools and environment, such as Keil and STM32CubeMX, which can help developers to develop and debug more easily. The development tools and environment of 51 microcontrollers are relatively simple, requiring manual program writing and burning using a microcontroller programmer.

 

Price: Due to the higher performance of STM32, the price is relatively higher, while the price of 51 microcontroller is relatively lower.

 

 

Application Scenario: Due to the difference in performance and functionality, STM32 is more suitable for use in application scenarios that require high performance and complex functionality, such as smart home, industrial control, and robotics. While 51 microcontroller is more suitable for use in some simple embedded control scenarios, such as electronic piano, electronic clock and other fields.

 

Part 3. How to Program STM32 Microcontroller

 

1. Preface

 

This blog is aimed at readers who have no experience in programming STM32.

The chip used in this post is STM32F103VET6, the programming software is MDK, and the downloader is J-link.

 

2. Chip

 

STM32F103VET6 chip peripheral interfaces are as follows: (the following figure)

 STM32F103VET6

  • Timer: four general-purpose timers, two advanced timers, two basic timers.
  • Communication: two SPI, two I2C, five USART, one USB, one CAN communication, one SDIO.
  • GPIO: 112 .
  • ADC: 12-bit ADC three channels totaling 16 channels.
  • DAC: 12-bit DAC two channels with 2 channels.
  • CPU: 72MHz .
  • Operating voltage: 2.0-3.6V.
  • Maximum power dissipation: 434mW.

 

3. Programming Software

 

3.1 Software installation (version 4.72)

 

1. mdk472 is the installation tool and keil_lic is the cracking software (we recommend to buy the genuine version).

2. Double click to install, select next step, enter any string when the following screen appears.

 keil

 

3. Install successfully

4. crack, run the keil uVision4 and KEIL_Lic as administrator. in the keil software, select file->license manager to appear the following interface.

 keil uVision4

Assign the above CID number to KEIL_Lic, and fill in the rest of the options as shown, then click generate to generate the activation code 47GJJ-UGXHR-7R9X3-A70L1-6MJ37-SF9RD (everyone's is different), then fill in the generated activation code to the New license ID of the keil software. code in the keil software, and click Add lic.

 click Add lic

The following screen appears to indicate successful activation

 successful activation

Note: Readers can also install the STM32CubeMX software, which is a programming tool for image words, but for beginners it is recommended to follow this article to install it, which is more conducive to the understanding of this STM32 chip.

 

3.2 Creating a project

 

1. Create the template

 

After installing the driver, we can write the application, but then we have to write it file by file, but for STM32, the peripheral device registers have the same address, so here we will use the library made by ST. Get:

 

After logging in, you can download this firmware library, so how to create a project based on the firmware library area that? This process has been a lot on Baidu, so I won't elaborate here, after creating the project, the following interface will appear

 Create the template

2. Software compilation and download

 

Compile: click the third button from the left

 Software compilation and download

Download: click on the last button to

 

4. Download

 

Readers need to download the code before the following j-link burner, get the burner after inserting the PC to install the corresponding driver, and then directly click the icon to download the compiled code.

 

Note: Different microcontrollers have different programming methods, but the steps are these steps, I hope the reader can apply this programming model on their own and adapt their own microcontrollers.

 

Conclusion

 

In conclusion, STM32 microcontrollers have established themselves as a leading force in the embedded systems domain, offering a rich set of features and unparalleled performance. With their extensive range of options, from low-power devices to high-performance ones, the STM32 series caters to a wide spectrum of applications.

 

As the demand for more sophisticated and intelligent electronic systems continues to grow, STM32 microcontrollers are poised to play a vital role in shaping the future of technology. Whether you are a professional developer or an electronics enthusiast, exploring the vast possibilities offered by STM32 microcontrollers can unlock a world of innovation and empower you to bring your ideas to life.

 

  • The Latest Development of Automotive MCU Market 2023
  • 8051 Microcontroller Block Diagram and Pinout

FAQ

  • Are STM32 microcontrollers suitable for beginners?
  • STM32 microcontrollers are widely used by both beginners and experienced developers. While they offer advanced features and performance, they also provide a user-friendly development ecosystem with easy-to-use tools, documentation, and community support. Beginners can start with entry-level STM32 microcontrollers and gradually explore more advanced features as they gain experience.
  • Are there different series or families of STM32 microcontrollers?
  • Yes, STM32 microcontrollers are available in different series or families, each targeting specific application requirements. Some popular series include STM32F, STM32L, STM32H, and STM32G, among others. These series offer variations in terms of performance, power consumption, memory size, peripheral options, and connectivity features. The selection of a specific series depends on the specific application needs.
  • How can I get started with STM32 microcontrollers?
  • To get started with STM32 microcontrollers, you can begin by selecting a suitable development board based on your application requirements. STMicroelectronics offers a range of development boards like Nucleo, Discovery, and Evaluation boards. Then, you can download the necessary software tools, such as STM32CubeIDE or STM32CubeMX, to develop and program your STM32 microcontroller. STMicroelectronics provides documentation, application notes, tutorials, and examples that can help you get started with STM32 development.
  • What programming languages can be used with STM32 microcontrollers?
  • STM32 microcontrollers can be programmed using different programming languages. The most common language is C or C++, which is widely supported by development tools and software libraries provided by STMicroelectronics. Additionally, some STM32 models also support other languages like Python or JavaScript through specific frameworks or development environments.

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

  • TMS320C6743CZKB3

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 176HLQFP

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320C6748BZCED4E

    Manufacturer: Texas Instruments

    IC FIXED-POINT DSP 361NFBFA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320DM8148BCYE1

    Manufacturer: Texas Instruments

    IC DGTL MEDIA PROCESSR 684FCBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320DM8166BCYG0

    Manufacturer: Texas Instruments

    IC DGTL MEDIA PROCESSR 1031FCBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty