[Embedded Basics & Common Sense] MCU

1. Common sense that should be known

1. ARM (core)

  • ARM: It is a vague word, which can represent ARM company, ARM core = ARM processor.
  • Core and frame: the frame is like a schematic diagram, and the core is like a PCB. A frame can draw multiple versions of PCB.
  • ARM processor: The British ARM company designed the ARM processor. The ARM we usually refer to refers to the ARM processor. ARM processors are just one of many central processing units - (CPUs).
  • Cortex processor: Cortex is the name of a series of processors from ARM. For example: cortex M0 M3 M4 M7

2. Single-chip microcomputer = MCU = microcontroller (chip)

  • Single-chip microcomputer: It is an integrated circuit chip. Contains the central processing unit CPU (for example, 32 single-chip microcomputer contains ARM processor), RAM, ROM...
  • STM32 microcontroller: It is an embedded microcontroller designed by STMicroelectronics. (MCU models are: STM32 F0 F1 F2 F3 F4 F7 H7). What CPU adopts is ARM processor. (STM32F1 adopts cortex-M3 core, F4 adopts cortex-M4 core, F7 adopts cortex-M7 core, H7 adopts dual-core M7+M4)

3. Circuit board (board card)

4. Embedded system (application)

  • The biggest feature of the embedded system is to design functions according to the needs of the product, without too many functions, and to minimize the cost. Low cost + high performance, so there are so many low-end single-chip microcomputers, which are low in cost but can meet product needs.
  • Embedded system = microcontroller board + embedded operating system. (It doesn't have to be an operating system, everything is developed for low cost)

5. CPU performance

  • DMIPS, MIPS: There are several different methods and programs used to test the CPU. They are for reference only and cannot be trusted.

8. Frequency multiplication and frequency division

  • Frequency multiplication: Increase the frequency of the external crystal oscillator to the high frequency required by the CPU.
  • Frequency division: reduce the high frequency and provide different frequencies to other parts of the single product machine.
  • PLL: frequency multiplier. PLL.
  • Prescaler: Prescaler.

9.TTL and CMOS level

  • The level is a rule artificially stipulated, and the 01 logic signal is used to represent the high and low voltage signals.
  • Common level types: TTL, CMOS, LVTTL, LVCOMS, RS232, RS485, etc.
  • TTL:VCC=5V。
  • LVTTL(Low Voltage):VCC=3.3V。VIH>=2V,VIL<=0.8V。
  • When the TTL input pin is floating, the default high level.
  • CMOS:VCC=+5~+15
  • Different systems are connected, such as single-chip microcomputer, DSP, FPGA, etc., you need to check the manual to see the level definition.

10. Common compilation errors?

11. Emulator

  • The program is downloaded to the emulator, not Flash. Not used

12. Reduced Instruction Set

  • Instruction Set: The point of transition between software and hardware.
  • Reduced instruction set and complex instruction set, the computer is a complex instruction set, the hardware is relatively large and complex, and consumes a lot of power.
  • ARM processors are 32-bit (compatible with 16-bit) RISC.

13. ST, ARM official website

  • ST official website: link
  • By looking at the company's official website, you can see what he does and who the customers are.
  • ST is for developers, the official website has more information, and the page is more friendly. ARM is aimed at chip factories, and the official website does not feel very friendly.

14. STM32 naming rules

  • ST stands for company name. M stands for microprocessor. 32 represents the ARM32-bit processor. F stands for performance. 103 series. The next few digits indicate the number of pins, memory size, package type, and operating temperature.
  • Summary: A few bits of STM32F103 determine a chip. Several bits of C8T6 determine its pin count and memory size, etc.

15. Read the chip manual

  • Browse through the directory titles first to see what's there.
  • mainly charts
    • Page 11: block diagram of the internal modules of the MCU
    • Page 12: Clock Tree
    • Page 13 and following: Pin Diagrams
  • Read the picture: the trapezoid is the selector, the thick line is the bus, the thin line is the single pin, and the inside of the line is the inside of the microcontroller.
    insert image description here

16. How software and hardware are related

  • Software refers to user programs, currently there are three types of registers, library functions, and HAL libraries. No matter which one, the address and state are finally operated, and the microcontroller is finally operated.
  • There are function configuration registers built into the single-chip microcomputer in the SRAM, and finally operate the hardware.
  • See the memory map and register address table in the data sheet for details.

17. Download the program to SRAM or FLASH

  • At the beginning, codes, constants, and global variables are all downloaded to flash.
    Then after the program starts running, the global variables go to the sram, and the code and constants are still in the flash
  • Refer to the big guy article: https://blog.csdn.net/yangkuiwu/article/details/78219995

Second, the internal functions of the microcontroller

(Put the pictures in the first part at the end. Try inserting the second part in the middle of the article. Before, I felt that inserting pictures would be messy, but now I feel that there are no pictures that are too abstract)

0. Divide the internal functions of the microcontroller into three parts

  • Core functions: core, memory, clock. (similar to computer CPU, memory stick, hard disk)
  • Important functions: Peripherals.
  • Additional functions: CRC, chip number.

1. Core function: Kernel

  • Using ARM32-bit processor, cortex-M3. The highest operating frequency is 72MHz.

2. Core function: memory

  • SRAM and FLASH. STM32F103 medium capacity series, 64K or 128K FLASH, 20K SRAM.
  • The main difference between the two is: whether it can be saved after power failure, and the speed.

3. Core function: clock

  • HSE external high-speed crystal oscillator: 4~16MHz, used as system clock.
  • LSE external low-speed crystal oscillator: 32khz, used for RTC.
  • HSI internal high-speed RC oscillator: 8MHz, used as system clock.
  • LSI internal low-speed RC oscillator: 40KHz, used for RTC.
  • Summary: The external connection is accurate, but expensive.
  • Clock classification: core and peripheral clocks, independent clocks

4. Important function: low power consumption

5. Important function: ADC

  • 2 12-bit ADCs sharing 16 external channels.
  • Can use DMA

6. Important function: DMA

  • 7-channel DMA, supporting peripherals with timers, ADC, USART, I2C, and SPI.

7. Important function: GPIO

  • I/O: input and output. Pins are not equal to IO. IO refers to pins that can input and output, and pins also include power pins and the like. C8T6 has 48 pins, 37 of which are IO ports.
  • GPIO: Definition in 32. It is the general IO port.
  • Maximum output current: 8ma, maximum input current: 20ma. Therefore, there are push-pull drive and current sink drive for LED drive, and the current drive will be brighter.
  • 32 input and output methods are:
    • Four inputs: analog, floating, pull-up.
    • Four kinds of output: push-pull, open-drain, multiplexing push-pull, open-drain. (Push-pull is a high-current output with drive capability, while open-drain has no drive capability.)

8. Important function: debugging

  • There are SWD and JTAG, which are embedded in the ARM core.

9. Important function: timer

  • 7 timers, 3 ordinary 16-bit, 1 advanced 16-bit, 2 open-door dogs 12-bit, 7-bit, 1 tick timer.

10. Important function: communication interface

  • 9 communication interfaces, 3 USARTs, 2 I2Cs, 2 SPIs, 1 CAN, 1 USB2.0.
  • The communication rate of USART1 is 4.5M per second, and the other two are 2.25.
  • I2C communication speed:
  • The SPI communication speed is 18M per second.
  • CAN communication speed 1M per second.
  • USB communication speed 12M per second.

11.RTC

12.NVIC

13. OUT

14. Bootstrap mode

  • Normally, it starts from FLASH. Boot from system when ISP downloads. Start from SRAM when debugging, download the program quickly, but lose it when the power is off.

11. Additional function: CRC

  • CRC is used to verify the correctness of data.

12. Additional function: chip number

  • Each chip has a unique 96-bit serial number.

3. Actual programming

0. Software preparation

  • keil5, Jlink driver

1. C knowledge is required

  • #if #endif
    enum
    char8 int16 long float32
    typedef
    struct
  • Under 32-bit MCU, word = 4 bytes

2. Engineering documents

3.

Guess you like

Origin blog.csdn.net/weixin_44029896/article/details/126760894