[STM32 MCU learning] Lesson 1: STM32 things you should know

[Mr. Zhu's course summary intrusion]

The first part, chapter list

3.1.1. STM32 and STC51 development

3.1.2_3. The origin and background of STM32

3.1.4. STM32 simple Chinese manual with reading

3.1.5. What are the various emulator debuggers of STM32?

3.1.6. STM32 standard peripheral library, HAL library, LL library

3.1.7. Introduction to the development board used in this course


The second part, chapter introduction

3.1.1. Development
    of STM32 and STC51 This section gives an overall introduction to the three seasons of STM32 related courses, and a general summary of the differences between STM32 learning and 51 single-chip microcomputers, hoping to guide everyone in the future learning.
3.1.2. The origin and background of
    STM32 1 This section describes the characteristics of STM32 microcontrollers, manufacturer information, official website, selection, etc., so that everyone has an overview of STM32. Don't underestimate these things. Many people have studied for a few years and still don't know where to find basic information.
3.1.3. The origin and background of
    STM32 2 This section describes the characteristics of STM32 microcontrollers, manufacturer information, official website, selection, etc., so that everyone has an overview of STM32. Don't underestimate these things. Many people have studied for a few years and still don't know where to find basic information.
3.1.4.STM32 simple Chinese book with reading
    beginning of this section take you to read STM32 official version of a Chinese version of the simple chip development board in Cape manual provided, can have a more comprehensive understanding of the specific STM32 through the chip manual .
3.1.5. What are the various emulator debuggers of STM32?
    This section talks about the two concepts of emulator and debugger, and then introduces several debuggers that this course will involve.
3.1.6. What is the
    STM32 standard library and HAL (cubeMX) library? This section focuses on the two library function development modes of STM32, the standard library and the HAL library, and clarifies the concepts before arranging follow-up learning.
3.1.7. The development boards used in this course
    introduce the three development boards involved in the course introduced in this section. The course explanation will take care of the differences between the three development boards. You can learn the course no matter which development board you have Not affected.    

Part Three, Classroom Record

3.1.1. STM32 and STC51 development

3.1.1.2, difference

  • STM32 clock needs to be configured, STC51 does not need to be configured
  • GPIO control: STC51 only needs to use bit variables to assign values ​​to pins or ports, and STM32 needs to program registers!
  • And these peripherals are basically the same, so it will be easier to learn STC51 microcontroller first, and then STM32!
  • The main frequency of STM32 can reach 72MHz

3.1.2_3. The origin and background of STM32

3.1.2.1. From 51 to STM32
(1) There are many kinds of single-chip microcomputers, as we have talked about in the single-chip courses, such as STM32, AVR, 51, etc.
(2) STM32 is the current mainstream 32-bit high-performance single-chip microcomputer, with more than 20 each year the amount of one hundred million pieces of
(3) STM32 ARM processor core is, but not necessarily the ARM STM32 [like NXP (philips), TI, Atmel , OKI, ST, Samsung, Huawei, have ARM-core, do There are 32-bit MCUs with their own unique skills, like Huawei’s HiSilicon ]
(4) STM32 features: high cost performance, rich internal peripherals, high MIPS (MIPS is just a measure of CPU performance), and a broad mass base

3.1.2.2. Where does
STM32 come from? (1) STM32 uses ARM Cortex-M3 core processor, which is designed by ARM based on the 32-bit ARMv7 architecture, so it can also be called ARMv7-M . Regarding the history of ARM, You can take a look at the authoritative guide of CM3

(2) STM32 is  designed, implemented and produced by ST ( ST official website    STM32 official website )

(3) In addition to producing STM32, ST also produces self-designed 8-bit microcontroller STM8s
(4) STM32 There are multiple models, covering multiple series of Cortex-M, M0, M0+, M3, M4, M7, etc. You can simply look at the official website!

3.1.2.3. STM32 official website data browsing
(1) Different series of diagrams browsing

(2) Just find one to check the detailed selection information
link
(3) Model coding rules (take the STM32F103C8 configured on the development board as an example)

3.1.4. STM32 simple Chinese manual with reading

Manual download link

3.1.4.1, function introduction

  • Memory
  • clock
  • ADC
  • Debug mode
  • DMA: The English spelling of DMA is "Direct Memory Access". Chinese means direct memory access, which is a data exchange mode that directly accesses data from memory without going through the CPU. About DMA
  • Peripherals: USART, timer, ADC, SPI, I2C
  • The
    interrupt source of I/O port is not bound, it can be set by software for mapping!
  • Timer
  • Communication interface

3.1.4.2, specifications

1. List of devices

2. Overview

  • The Nested Vectored Interrupt Controller (NVIC)
    51 also has interrupt control, but it is implemented directly by manipulating the interrupt control register. STC51 has 8 terminal sources + 4 priority levels
  • External interrupt/event controller (EXTI)

  • The selection of the clock system clock is carried out at startup. The internal 8MHz RC oscillator is selected as the default CPU clock at reset, and then an external 4~16MHz clock with failure monitoring can be selected; when the external clock fails, it will Be isolated, and corresponding
    interruption will occur at the same time . Similarly, complete interrupt management of the PLL clock can be taken when needed (such as when an external oscillator fails). There are multiple prescalers for configuring AHB frequency, high-speed APB (APB2) and low-speed APB (APB1) areas. The highest frequency of AHB and high-speed APB is 72MHz, and the highest frequency of low-speed APB is 36MHz.
  • Boot mode (start mode)
  • Power supply scheme
    You can refer to the schematic diagram to see how VDD, VSSA, and VBAT provide different power supply schemes!
  • Low power consumption mode
    Sleep mode, shutdown mode, standby mode
  • DMA's
    flexible 7-channel general DMA can manage data transfer from memory to memory, device to memory, and memory to device; the DMA controller supports the management of the ring buffer, which avoids the interrupt generated when the controller transfer reaches the end of the buffer.
    DMA can be used for the main peripherals: SPI, I2C, USART, general and advanced timers TIMx and ADC.
  • RTC (real-time clock) and backup register
    RTC and backup register are powered by a switch. When VDD is valid, the switch selects VDD for power supply, otherwise it is powered by the VBAT pin
    . Backup registers (10 16-bit registers) can be used to save data when VDD disappears.
  • Independent watchdog
  • Window watchdog
  • System time base timer
  • Universal timer ( TIMx )
  • Advanced control timer ( TIM1 )
  • Communication interface: USART, I2C, SPI, CAN, USB, GPIO
  • ADC (Analog/Digital Converter)

The following content will be explained in detail in the following course!


3.1.5. What are the various emulator debuggers of STM32?

3.1.5.1, the difference and connection between emulator and debugger

  • Simulator
     Single-chip simulator refers to a set of dedicated hardware devices specially designed and manufactured for the purpose of debugging the software of the single-chip microcomputer. Like software simulation, you can set breakpoints, single-step execution, and execute at full speed, but every single-chip microcomputer must have an emulator, and the cost is still high!
  • The debugger is
       also an emulator, but as long as the debugging interface is the same, the debugger can simulate different types of single-chip microcomputers. When we learn STC51, the measurement of the running time of a piece of code is the debugger function!

3.1.5.2. STM32 debugging interface
(1) JTAG protocol: The standard JTAG interface is 4 wires: TMS, TCLK, TDI, TDO, which are respectively mode selection, clock, data input and data output lines. The definition of related JTAG pins is:

  • TMS: Test mode selection, TMS is used to set the JTAG interface in a specific test mode;
  • TCLK: Test clock input;
  • TDI: Test data input, data is input to JTAG interface through TDI pin;
  • TDO: Test data output, the data is output from the JTAG interface through the TDO pin;

JTAG also has its own JTAG debugger, but as shown in the figure below, JTAG requires a parallel port, and now most of them are USB ports, so the JTAG debugger is out of the stage, and the JTAG protocol is still widely used!
Write picture description here

(2) SWD: Serial Wire Debug, which should be regarded as a different debugging mode from JTAG, and the debugging protocol used should also be different, so it is most directly reflected in the debugging interface, which is the same as the 20 JTAG Compared with pins, SWD only needs 4 (or 5) pins, which is simple in structure, but it is not as widely used as JTAG. The mainstream debugger is also the SWD debugging mode that was added later. The biggest feature is that fewer GPIO pins are needed!
The following is the interface diagram of JTAG and SWD:


3.1.5.3, STM32 commonly used debugger
(1) JLINK V9 V11
J-Link is a JTAG-based emulator launched by the German SEGGER company. Simply put, it is a JTAG protocol conversion box, that is, a small USB to JTAG conversion box, which is to convert the JTAG parallel port into a USB port!
JLINK is a general development tool that can be used on platforms such as KEIL, IAR, and ADS. Speed, efficiency, and functions are all very good, and it is said to be the most powerful among many emulators. The Internet is pirated, thousands of genuine ones!
View source image
(2) STLINK
ST-LINK is an emulator specifically for STMicroelectronics STM8 and STM32 series chips.
Write picture description here
(3) The general ARM simulator

(4) There is now an STM32cubeprogrammer: Introduction link

3.1.5.4, Mr. Zhu has something to say about the debugger
(1) The debugger and its debugging ideas are helpful for learning and development
( 2) Don't care too much about the debugger
(3) If you want to go wider and higher, learn not to use a debugger


3.1.6. STM32 standard peripheral library, HAL library, LL library

3.1.6.1. Three programming methods for STM32
(1) Register operation
(2) Standard library (standard peripheral library)

  • The STM32 standard peripheral library is a firmware function package, which consists of programs, data structures and macros, including the performance characteristics of all peripherals of the microcontroller.
  • The function library also includes the driver description and application examples of each peripheral, and provides an intermediate API for developers to access the underlying hardware. By using the firmware function library, developers can easily apply each external hardware without having to master the details of the underlying hardware. Assume.

(3) STM32Cube (HAL library/LL library)

  • The HAL library is used to replace the previous standard peripheral library. Compared with the standard peripheral library, the STM32Cube HAL library exhibits a higher level of abstraction and integration. The HAL API focuses on the common function functions of each peripheral. This facilitates the definition of a set of universal user-friendly API function interfaces, which can be easily implemented from One STM32 product is transplanted to another different STM32 series product.
  • At present, ST mainly promotes the HAL library. Currently, the HAL library supports the full range of STM32 products.
  • ST has specially developed the supporting desktop software STMCubeMX for it. Developers can directly use the software for visual configuration, which greatly saves development time. ( I will show you tomorrow! )

Library
3.1.6.2. Where does the library come from the
ST official website link


3.1.7. Introduction to the development board used in this course

3.1.7.1. The principle of choosing a development board
(1) Just enough, don’t pursue new and high-end too much
(2) Cost performance (performance/price)
(3) There is a certain necessity for comparison and reference

  • If you want to learn from the teacher, it is best to use a development board that is different from him, so that it is the easiest to improve!

3.1.7.2, the current development board I have

(1) STM32F103C8

(2) STM32F407VET6

(3 ) Puzhong Science and Technology Development Board
3.1.7.3, the key to learning STM32
(1) Foundation: It is best to know SCM, as long as you know C language!
(2) Good course
(3) Combination of learning and practice + certain patience = inevitable learning

This lesson is over!


 

Guess you like

Origin blog.csdn.net/qq_27148893/article/details/111321089