Embedded foundation of microcontroller development

A few good learning sites:

Embedded Development_Embedded Development Board_Embedded System- eefocus.com

electronic enthusiast

Teacher Zhu Youpeng's Embedded Linux Core Course Notes_yougogo's Blog-CSDN Blog_Zhu Youpeng Embedded

Learning how machine learning can help embedded: 5 reasons why embedded developers should care about machine learning (baidu.com) 

Embedded System Learning (5): Embedded and Deep Learning - Short Book (jianshu.com)

Gradient algorithm understanding: (1 message) Why is the opposite direction of the gradient the fastest direction in which the function value decreases? _Yizhen's Blog-CSDN Blog_Gradient Reverse Direction

1. Basic knowledge of single chip microcomputer

1.1  Basic composition and working principle of MCU | Renesas

1.2  Peripheral function circuit of MCU | Renesas 

1.3  Peripheral function circuit control | Renesas

 

  

1.4  Outage | Renesas

1.5 Crystal Oscillator

There are some electronic devices that require AC signals         with a highly stable frequency , while LC oscillators are less stable and the frequency is prone to drift (that is, the frequency of the generated AC signals is easy to change). A special component, a quartz crystal , is used in the oscillator to generate a highly stable signal. This oscillator using a quartz crystal is called a crystal oscillator.

        The role of the single-chip crystal oscillator is to provide the basic clock signal for the system. Usually a system shares a crystal oscillator so that all parts can be synchronized. Some communication systems use different quartz crystal oscillators for the base frequency and radio frequency, and keep them synchronized by electronically adjusting the frequency. The higher the clock frequency provided by the crystal oscillator of the single-chip microcomputer, the faster the running speed of the single-chip microcomputer. The execution of all instructions connected to the single-chip microcomputer is based on the clock frequency provided by the crystal oscillator.

Microcontroller Crystal Oscillator Circuit Principle

        The single-chip microcomputer generally adopts a three-terminal (Colpitts) AC equivalent oscillation circuit; in the actual crystal oscillator AC equivalent circuit, Cv is used to adjust the oscillation frequency, which is generally realized by adding different reverse bias voltages to varactor diodes. This is also the mechanism of voltage control; after replacing the crystal with the equivalent circuit of the quartz crystal. where Co, C1, L1, RR are the equivalent circuits of the crystal. When the microcontroller is working, it fetches instructions from the RoM one by one, and then executes them step by step. The time for a single-chip microcomputer to access a memory is called a machine cycle, which is a time reference.

The working principle of the clock crystal oscillator:

When a voltage is applied to the two electrodes of the quartz, the wafer will be deformed. Conversely, if the external force deforms the crystal, a voltage will be generated on the two electrodes. This is what we call the piezoelectric effect. We use this physical characteristic of quartz crystal to manufacture crystal oscillator products with different frequencies.

What is the difference between the internal and external crystal oscillators of the microcontroller? (baidu.com)

1.6 Clock cycle, instruction cycle, machine cycle

instruction cycle:

        Every time the CPU  fetches  and  executes  an instruction, it must complete a series of operations, and the time required for this series of operations is usually called an instruction cycle . In other words, an instruction cycle is the time it takes to fetch an instruction and execute it . Since the operation functions of each instruction are different, the instruction cycle of each instruction is different . For example, the instruction cycle of an addition instruction is different from the instruction cycle of a multiplication instruction.

Machine cycle:

        Machine cycles are also known as CPU cycles . In a computer, in order to facilitate management, the execution process of an instruction is often divided into several stages (such as fetching, decoding, executing, etc.), and each stage completes a basic operation. The time required to complete a basic operation is called a machine cycle . In general, a machine cycle consists of several clock cycles .

Clock cycle:

        The clock period T is also called the oscillation period, which is generated by the on-chip oscillator circuit OSC of the single-chip microcomputer. It is often defined as the reciprocal of the clock pulse frequency and is the smallest time unit in the sequence . For example, if the clock frequency of a microcontroller is 1MHz, its clock cycle T should be 1μs. Because the clock pulse is the basic working pulse of the computer, it controls the working rhythm of the computer, so that every step of the computer's work is unified to its pace. Obviously, for computers of the same type, the higher the clock frequency, the faster the computer will work . However, since different computer hardware circuits and devices are not exactly the same, the clock cycle frequency ranges they need are not necessarily the same.

        The clock period, also known as the oscillation period , is defined as the reciprocal of the clock frequency . A clock cycle is the most basic and smallest unit of time in a computer . In one clock cycle, the CPU only completes one of the most basic actions. A clock cycle is a quantity of time. The clock cycle represents the highest frequency at which the SDRAM can run. A smaller clock period means a higher operating frequency .

The relationship between the three:

        The instruction cycle consists of several machine cycles, and the machine cycle consists of several clock cycles, and the basic bus cycle consists of 4 clock cycles

2. Hardware knowledge 

(3 messages) Embedded Learning (1) - Basic Knowledge_Southern Chai Chai's Blog-CSDN Blog_Embedded Learning Materials

A must-have for hardware engineers, common component packaging quick reference table - Programmer's blog without hair loss - CSDN blog

2.1 Digital circuit

A digital signal, also known as a pulse signal, is a transition signal with a short duration. A circuit that processes digital signals is called a digital circuit, and it focuses on the logical relationship between input and output signals . In digital circuits, triodes generally work in the cut-off region and saturation region, and act as switches.

Features of digital circuits

  1. Signals are two discrete quantities that vary discontinuously with time.
  2. Transistors generally work in the on and off states.
  3. The main problem studied is the logic function of the circuit.
  4. The main methods are logic analysis and logic design, and the main tool is logic algebra.

(1 message) Digital circuit - gate circuit_Salted fish's blog-CSDN blog_Digital gate circuit

(3 messages) Basics of Digital Circuits_Ferry Blog-CSDN Blog

2.1.1 The difference between registers and memory

The difference between registers and memory includes three aspects: function, speed, and nature.

1. The nature of the register and the memory is different. From the literal meaning, it can be understood that one is a register and the other is a storage. Then their specific principle is that the memory needs to obtain a part of the space from the CPU to store data and some computer operation instructions; while the register is directly and temporarily storing data to perform operations.

2. In terms of function, registers can be used to point to random locations in memory; and can be used to read and write data to peripheral devices of the computer, while memory can only be read and stored. There is also a difference between the two in terms of storage and reading speed. Registers are faster than memories because there is limited space to read and store limited data.

3. The register is generally composed of a NAND gate, which is generally integrated in the cpu. Its performance is relatively good, but its cost is also quite expensive. Generally, many advanced CPUs only have a few megabytes of storage cache space. So the register brings the cache, and the memory brings the storage space.

the difference

1. Registers exist in the CPU, which are fast and limited in number; when a computer performs calculations, it must read data into the registers to perform calculations.

Storage is memory, a little slower, but a lot.

2. The memory includes registers, and the memory has ROM and RAM

2.1.2 ARM、DSP、FPGA

ARM has a relatively strong transaction management function, which can be used to run interfaces and applications, etc., and its advantages are mainly reflected in the control aspect; ARM is a 32-bit single-chip microcomputer, and its internal hardware resources have high performance, and it can load the operating system as its main function. Features, with the operating system, you can process multiple tasks in real time like a PC, that is, multiple tasks can be completed at the same time without affecting each other.

DSP is mainly used for calculations, such as encryption and decryption, modulation and demodulation, etc. Its advantages are powerful data processing capabilities and high operating speed.

FPGA can be programmed with VHDL or verilog HDL, and has strong flexibility. Because it can be programmed, debugged, reprogrammed and repeated operations, it can fully carry out design development and verification. When the circuit has a small change, it can show the advantages of FPGA. Its on-site programming ability can prolong the life of the product in the market, and this ability can be used for system upgrade or debugging.

Comparison of ARM, DSP, and FPGA - very detailed and in-depth - Programmer Sought

2.1.3 MCU and Embedded System

A detailed explanation of the relationship between single-chip microcomputer and embedded, operating system and RTOS

2.1.4 The difference between GPIO and IO port

1、I/O

        IO stands for Input Output, which is the input and output system in the computer, which is used for information exchange between the CPU and the outside world. For example, the CPU needs an I/O system to read memory data, and the I/O system is also required to output data from the CPU to the screen. Information can be transmitted in parallel or in parallel on the I/O system. That is, data is transmitted on multiple lines, that is, multiple bits are transmitted in parallel at a time, and one bit is transmitted serially at a time.

2、GPIO

        GPIO, the English full name is General-Purpose IO ports, that is, general-purpose I/O ports. A "general-purpose programmable I/O interface" is generally provided on the microcontroller chip. The interface has at least two registers, namely "control direction register" and "data register". Each bit of the data register is directly connected to the outside of the chip, and the function of each bit in the data register, that is, whether the signal flow direction of each bit is input or output, can be set independently through the corresponding bit in the control register. In this way, the presence or absence of an IO interface becomes a feature that distinguishes microcontrollers from microprocessors. (Different MCUs have different register configurations)

In the actual MCU, there are many forms of I/O. For example, some data registers can be addressed according to bits, but some cannot be addressed according to bits, which must be distinguished during programming. For example, the traditional 8051 series is divided into two registers that can be bit-addressed and non-bit-addressable. In addition, for the convenience of use, many MCUs integrate Glue Logic into the chip, which enhances the stability of the system. For example, in addition to the two standard registers required for the GPIO interface, it also provides pull-up registers, which can set I/O The output mode is high impedance, or level output with pull-up, or level output without pull-up. In the circuit design, the peripheral circuit can be simplified a lot.

If the line of GPIO is downward, it is the output mode. There is a circuit composed of a pair of MOS transistors. This structure makes GPIO have two modes: push-pull output and open-drain output.

Push-pull output mode : In this structure, a high level is input, the upper P-MOS is turned on, the lower N-MOS transistor is turned off, and a high level is output externally. In this structure, the low level is input, the upper P-MOS is turned off after the reverse, the lower N-MOS is turned on, and the low level is output externally. When the two levels are switched, the two MOS tubes are turned on in turn, which greatly improves the load capacity and switching speed compared with the ordinary method. The low level output in this mode is 0V, and the high level is 3.3V.

Open-drain output mode: In this mode, the upper P-MOS does not work at all. The most common argument for the difference between open-drain output and push-pull output is that the open-drain output cannot really output high levels, that is, there is no drive capability at high levels. External drive needs to be completed with the help of an external pull-up resistor.

The principle is: we control the output to be 0, then the P-MOS tube is turned off, the N-MOS tube is turned on, and the output is grounded. If the output is 1 (the above said that it cannot really output high level), both MOS tubes are turned off. , the pin is not outputting high level or low level, but it displays a high-impedance state externally. Normally, an external pull-up resistor is required for normal use. We also call this feature "wired and", that is, if There are multiple GPIO pins in open-drain mode connected together. Only when all pins are in a high-impedance state, the external pull-up resistor will provide a high level. If one pin is low, the entire line is low. level.

Because of this feature, we generally choose the push-pull output mode when we choose the output mode. We only use the open-drain output mode in bus circuits that require "wired-AND" characteristics such as C and SMBUS communications. In the case of provisioning, you can set the GPIO pin as an open-drain output, connect an external pull-up resistor, and the power supply is 5V. When the output is in a high-impedance state, the pull-up resistor and the power supply can output a voltage of 5V to the outside. How to choose pull-up or pull-down see below
 

3. Difference

        GPIO means a general-purpose input and output port, and its state can be determined by programming. The I/O of the MCU is GPIO, also known as a bidirectional input and output port, and I/O refers to all types of input and output ports, including unidirectional ports such as The input and output pins of logic gate circuits and bidirectional GPIO ports, while GPIO must be bidirectional, this is to avoid different contexts Part13--How to
distinguish between I/O and GPIO_Long Road Long 2021 Blog-CSDN Blog_ The difference between gpio and io

2.1.5 Pull-up and pull-down resistors

Internal pull-up means that there is a pull-up resistor inside the MCU. When this port line is not used, the I/O port is always at a high level (stable state). The pull-up of some MCUs should be defined by the user.
When the I/O port is used, define whether to pull it up (that is, define it in the program); pull up.

Pull-up (Pull Up) or pull-down (Pull Down) resistors, both of which are collectively referred to as "pull-down resistors", function: to clamp the signal line with an uncertain state to a high level (pull-up) or a low level (pull-down).

How to choose the correct value of pull-up and pull-down resistors? _The Blog of Ferry Vicissitudes-CSDN Blog

If the input pin is connected with a pull-up or pull-down resistor, the pin can be determined as a high level or a low level to prevent external interference.

Stm32 sets the internal pull-up resistor_comprehensive introduction to resistor pull-up and pull-down_miss waste wood blog-CSDN blog

TI's DSP chip, the internal pull-up of GPIO is enabled by default (except for GPIO that can be configured as PWM output, and the internal pull-up of such GPIO is disabled by default). For GPIO whose internal pull-up is enabled by default, in some cases, its register needs to be configured to disable the internal pull-up.

If the GPIO is configured as an output, whether the internal pull-up is enabled or not has little effect, because it mainly depends on whether the output is high or low.

If the GPIO is configured as an input, you should pay attention. Whether you need to disable the internal pull-up depends on the design of the external hardware circuit. For example, in the situation in the figure below, you should disable the internal pull-up. Internal pull-up is enabled, when the optocoupler output is open, because R813, R811 and DSP internal pull-up resistor form a voltage divider, the level of PWM_DSP will not be 0.

2.1.6 Bus

        Bus (Bus) is a public communication trunk line for transmitting information between various functional components of a computer. It is a transmission harness composed of wires. According to the type of information transmitted by a computer, the bus of a computer can be divided into a data bus , an address bus and a control bus . , which are used to transmit data, data address and control signals respectively . The bus is an internal structure, which is a common channel for the cpu, memory, input, and output devices to transmit information. The various components of the host are connected through the bus, and the external devices are connected to the bus through the corresponding interface circuits, thus forming computer hardware. system . In a computer system, the public channel for transmitting information between various components is called a bus, and a microcomputer uses a bus structure to connect various functional components .

 2.1.7 Semiconductor memory for sequential logic circuits

        Generally, there is a difference between level sensitivity and edge sensitivity. Level sensitivity refers to the high and low levels of the signal. For example, if a process is executed when the signal is 0, the process will be executed as long as the signal is 0, and if the edge is sensitive, the process will be executed. It will only be executed at the moment of rising or falling and will not be executed all the time.

  Basic knowledge of digital circuits - semiconductor memory of sequential logic circuits (D flip-flops, latches (D, RS, JK, T))
Before introducing this section, there are generally the following regulations:
Latches: level-sensitive
registers : Edge trigger
Trigger: Edge trigger

The relevant semiconductor memory devices in digital circuits are mainly D flip-flops, latches, memories, etc. Mainly used to store data. Storage circuits that store one bit of data are called registers, while those that can store large amounts of data are called memories.

(5 messages) Basic knowledge of digital circuits - semiconductor memory of sequential logic circuits (flip-flops, latches (D, RS, JK, T))_Ferry Vicissitudes Blog-CSDN Blog_jk Latch

2.1.8 RC step-down

        The working principle of the RC step-down is to use the capacitive reactance generated by the capacitor at a certain frequency of the AC signal to limit the maximum operating current. At the same time, a resistive element is connected in series with the capacitor, and the voltage obtained at both ends of the resistive element and the power consumption generated by it depend entirely on the characteristics of the resistive element. Therefore, the capacitive step-down actually uses the capacitive reactance to limit the current, and the capacitor actually plays a role of limiting the current and dynamically distributing the voltage across the capacitor and the load.

2.1.9 Crystal Oscillator

Analysis of crystal oscillator circuit principle - Zhihu (zhihu.com)

2.1.10 Active and passive components

        Simply put, devices that require energy (electricity) sources are called active devices, and devices that do not require energy (electricity) sources are passive devices. Active devices are generally used for signal amplification, transformation, etc., and passive devices are used for signal transmission, or "signal amplification" through directionality. Capacitors, resistors, and inductors are all passive devices, while ICs and modules are all active devices. (In layman's terms, those that require a power supply to display their characteristics are active components, such as triodes. Those that do not require a power supply to display their characteristics are called passive components). 

What is the meaning of passive components_What are the passive components_The difference between passive components and active components-and non network (eefocus.com)

2.1.11 Chopper circuit

        Chopper circuit (also called DC chopper circuit) means that in the application of electricity, part of the sine wave is "chopped" out of certain needs. (For example, when the voltage is 50V, electronic components are used to make the following 50V The ~0V part is cut off, and the output voltage is 0.) Later, it was borrowed into the DC-DC switching power supply, mainly because in the process of voltage regulation of the switching power supply, the original linear power supply was "chopped" by the line into a piece of pulse. Convert direct current to another direct current of fixed voltage or adjustable voltage. Also known as DC- DC Converter ( DC/DC  Converter). 

2.2 Analog circuit 

The following two documents are combined, one is the picture and the other is the analysis

20 classic analog circuits (detailed graphics)_eagle11235's Blog-CSDN Blog_Electronic Circuits

20 commonly used analog circuits (detailed analysis) - eagle11235's blog - CSDN blog

An analog signal is a signal that changes continuously with time, and an analog circuit refers to a circuit used to transmit, transform, process, amplify, measure, and display an analog signal . It mainly includes amplification circuit , signal operation and processing circuit, oscillation circuit, modulation and demodulation circuit and power supply. That is, circuits that process analog signals are called analog circuits. Such as rectifier circuits, amplifier circuits, operational amplifiers, etc., the research is on the magnitude and phase relationship between the input and output signals. In the amplifying circuit, the triode usually works in the amplifying area.

(3 messages) Hardware Basics - Analog Circuits

2.2.1 Operational amplifier

The method of judging the working area of ​​the op amp is:

If there is negative feedback, it works in the linear region;

If there is positive feedback or no feedback, it works in the nonlinear region;

PS:

When the op amp is in a non-linear state: the virtual short circuit does not hold, and the virtual circuit breaker can be used.

2.2.2 Comparator

2.2.2.1 Comparator concept 

1. Choose the power supply method according to whether the output needs negative voltage

2. When the voltage at the positive input terminal is greater than the voltage at the negative input terminal, the output of the comparator is high

3. When the voltage at the positive input terminal is less than the voltage at the negative input terminal, the output of the comparator is low

Comparator Basics - Comparator Circuits

2.2.2.2 Hysteresis comparator

        The hysteresis comparator is actually a comparator with positive feedback, and the output state is only two states, either high level or low level. The hysteresis comparator is characterized in that when the input voltage gradually increases or decreases hours, with two unequal thresholds, the transfer characteristic has the shape of a hysteresis curve. The focus is on two thresholds: Uth and Utl. Grasp the output state of the comparator to determine which threshold is currently used: low threshold Utl when the output is low, and high threshold Uth when the output is high.

The comparator is when VIN(+) > VIN(-), outputs high level; VIN(+) < VIN(-), then outputs low level. But when the signals at the two input terminals are very close, the output will jump continuously due to the burr of the input voltage, which is the so-called ringing effect.

Principle and Application of Comparator and Hysteresis Comparator_Jason's Blog-CSDN Blog_Hysteresis Comparator

2.2.2.3 Comparator Application

Comparator Application 1: Hysteresis Comparator

        The hysteresis comparator and the capacitor charge and discharge are used to generate a triangle wave and a square wave. The triangle wave is the charge and discharge waveform of the capacitor, and the square wave is the output waveform of the comparator during the capacitor charge and discharge process. 

Comparator Application 2: Square and Triangular Wave Generation  

Comparator Application 3: PWM Wave with Adjustable Duty Cycle

2.2.3 Common semiconductors

Hole-type semiconductors, also known as P-type semiconductors, are semiconductors dominated by positively charged holes . Also known as electronic semiconductor. N-type semiconductors are impurity semiconductors whose free electron concentration is much greater than the hole concentration . Using different doping processes, P-type semiconductors and N-type semiconductors are fabricated on the same semiconductor (usually silicon or germanium) substrate through diffusion , and a space charge region is formed at their interface called PN junction (English : PN junction). The PN junction has unidirectional conductivity , which is a characteristic used by many devices in electronic technology , such as the material basis of semiconductor diodes and bipolar transistors .

The difference between pnp and npn is: 1. Different output components; 2. Different output signals; 3. Different resistor connections. For NPN, when the obstacle approaches, the PLC detects a low level; for the PNP type proximity switch, when the obstacle approaches, the PLC detects a high level.

 What is the difference between pnp and npn?_Baidu Know(baidu.com)

What is the difference between the proximity switch pnp and npn - eefocus.com

Commonly used semiconductors include diodes, triodes, field effect transistors (MOS transistors), and operational amplifiers. Diodes, triodes, and MOS tubes are all transistors, which have functions such as detection, rectification, amplification, switching, voltage stabilization, and signal modulation, and constitute an amplification circuit.

One article to understand the design and use of triode and field effect tube drive circuits

Generally, the output current of a triode is controlled by the input current, but for a field effect tube, the output current is controlled by the input voltage (or electric field), and it can be considered that the input current is very small or there is no input current, so that the device has a high The input impedance, so it is called a field effect tube.

N-channel enhancement mode field effect transistor knowledge (ejiguan.cn)

2.2.4 Impedance

Impedance is the vector sum of resistance and reactance (capacitive and inductive)

Capacitors have the ability of "blocking DC and passing AC", while inductors have the function of "passing DC, blocking AC, passing low frequency, and blocking high frequency".

What is Impedance? _Programmer's blog without hair loss-CSDN blog_The relationship between impedance and resistance

2.2.5 Electrolytic and non-electrolytic capacitors

Electrolytic capacitors are a type of polar capacitors, and electrolytic capacitors generally have a relatively large capacity. It can achieve large capacity and small volume, and unidirectional conduction voltage. Although non-electrolytic capacitors conduct bidirectional conduction, if they are to be made with large capacity, they will result in a large volume.

A polarized capacitor is actually a capacitor that can only be used in one voltage direction. For non-polar capacitors, both voltage directions can be used.

What do non-electrolytic capacitors and electrolytic capacitors mean? What's the difference? Non-polarity - 131****8067's answer - understand (idongde.com)

2.3 Memory

Detailed explanation of the concept of SDRAM, DRAM and DDR FLASH ROM_Z Xiaoxuan's Blog-CSDN Blog_sdram and dram

2.4 Embedded Basics

Basic knowledge of commonly used components in embedded development - Baidu Library (baidu.com)

3. MCU development

(5 messages) Some concepts of embedded FMC/GPIO/MIO and EMIO/GTP, GTX, GTH and GTZ_sxy1993sxy2018's blog-CSDN blog_What does embedded fmc mean?

3.1 Peripherals

        The peripherals inside the single-chip microcomputer generally include: serial port control module, SPI module , I2C module, A/D module, PWM module, CAN module, EEP ROM , comparator module, etc., they are all integrated inside the single-chip microcomputer, there are corresponding The internal control registers can be directly controlled by MCU instructions.

3.1.1 GPIO

The microcontroller chip generally provides a "general programmable IO interface", that is, GPIO.

The interface has at least two registers , namely  "General IO Control Register"  and  "General IO Data Register" . One is the general-purpose IO port control register for control , and the other is the general-purpose IO port data register for storing data .

(5 messages) Basic knowledge of digital circuits - introduction to GPIO of IO peripherals_Ferry Blog-CSDN Blog_The difference between gpio and io

3.1.2 PWM

​ Pulse Width Modulation (PWM), the abbreviation of "Pulse Width Modulation" in English, referred to as Pulse Width Modulation, is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in measurement , communication to power control and conversion in many fields. ​The relevant parameters of PWM (Pulse Width Modulation) pulse width modulation include frequency, duty cycle, amplitude, etc. Frequency f = 1/T (period), duty cycle D (Duty) = H/T (ratio of high level time to period).

Principle of PWM

Taking the single-chip microcomputer as an example, we know that the IO port of the single-chip microcomputer outputs digital signals, and the IO port can only output high level and low level

Assuming that the high level is 5V and the low level is 0V, then we need to use PWM to output different analog voltages, and obtain analog voltage signals simulated by digital signals by changing the duty cycle of the square wave output by the IO port

We know that the voltage is clamped to the analog load (such as LED lights, DC motors, etc.) in a repetitive pulse sequence that connects 1 or disconnects 0. The connection is the output of the DC power supply, and the disconnection is the disconnection of the DC power supply. . By controlling the connection and disconnection time, theoretically speaking, any analog voltage not greater than the maximum voltage value (that is, any size between 0 and 5V) can be output

For example, if the duty cycle is 50%, it means half of the high-level time and half of the low-level time. At a certain frequency, an analog 2.5V output voltage can be obtained. Then the voltage obtained by a 75% duty cycle is 3.75V. , the adjustment function of pwm comes from the width control of the "occupancy period". narrow, the average voltage of the output voltage signal will decrease, and the average voltage value obtained through the resistance-capacitance conversion circuit will also decrease

That is, at a certain frequency, different output analog voltages can be obtained through different duty ratios. 

(3 messages) PWM principle PWM frequency and duty cycle detailed explanation_Z Xiaoxuan's Blog-CSDN Blog_pwm

(2 messages) PWM module and high-precision PWM application of DSP chip F2803x series_Zichen094's blog-CSDN blog_dsp pwm module

3.1.3 ePWM 

        ePWM, the enhanced pulse width modulation module, is used to generate square wave pulses with adjustable frequency, phase and duty cycle.

        The ePWM module contains 7 sub-modules, namely the time reference sub-module TB, the comparison function sub-module CC, the action limit sub-module AQ, the dead zone control sub-module DB, the chopper control sub-module PC, the event trigger sub-module ET and the fault Capture submodule TZ. (After the three links of TB, CC, and AQ, the basic shape of PWM has been produced) The ePWM module can output two PWMs, namely EPWMxA and EPWMxB, and the two PWMs can be output independently or complementary.

Time-base module (TB, Time-Base Module);
count comparison module (CC, Counter Compare Module);
action module (AQ, Action Qualifier Module);
dead zone module (DB, Dead-Band Generator Module);
chopping module ( PC, PWM Chopper Module);
brake module (TZ, Trip Zone Module), also known as joint defense module;
event trigger module (ET, Event Trigger Module);
digital comparison module (DC, Digital Compare);
 

The full name is the Time Base module. This module has two main functions: one is the synchronization of the clock signal, and the other is counting.

The counter compare function (Counter Compare) module has two comparison registers CMPA and CMPB, and its function is to compare the value of the counter register TBCTR with the values ​​of these two comparison registers, thereby generating a comparison event and generating a PWM wave.

When various events of the counter are sent to AQ, AQ decides how the pin should act, whether it becomes high level, low level, or does not take any action, or directly flips the previous level, so that Generate the desired PWM waveform.

The dead band control module (Dead Band) is used to avoid false triggering when the power switch control signal is reversed. 

ePWM learning experience_mlc_WTMOTW's Blog-CSDN Blog_epwm

3.2 Communication

The bus is a group of transmission channels, which is a channel for transmitting data composed of various logic devices, and generally consists of data lines, address lines, control lines, etc.

An interface is a connection standard and is often referred to as a physical interface.

Protocols are the rules for transferring data. In-depth Interpretation of the Differences between Buses, Interfaces, and Protocols

(3 messages) Embedded Learning (4) - Serial Port_Southern Chai Chai's Blog-CSDN Blog_Embedded Serial Port

How the serial port transmits data_Crazzy_M's blog-CSDN blog_How does the serial assistant send data

The basic principle of serial communication

3.2.1 I²C (board to board)

       The I2C bus is a simple, two-way two-wire synchronous serial bus developed by Philips . It requires only two wires to transfer information between devices connected to the bus.

The I2C bus is a half-duplex communication protocol. It consists of two lines, the clock line (SCL) and the data line (SDA). I2C can be divided into master and slave. There can only be one master on the same I2C bus, and there can be multiple slaves. It should be noted that the slave cannot issue a transmission request, and the data transmission of the slave is also controlled by the master.

The transfer rate of I2C is

Standard Mode: 100kHz,
Fast Mode: 400kHz,
High Speed ​​Mode: 3.4 MHz.
(5 messages) I2C protocol_yang. . Blog-CSDN blog_i2c protocol

(5 messages) I2C protocol_What is the blog-CSDN blog_i2c protocol

(1 message) Super detailed explanation of the principle of IIC --- worth a look_Z Xiaoxuan's Blog-CSDN Blog_iic

        The master device is used to start the bus to transmit data and generate the clock to open the transmitting device. At this time, any addressed device is considered as a slave device. The relationship between master and slave, send and receive on the bus is not constant, but depends on the direction of data transmission at this time. If the host wants to send data to the slave device, the host first addresses the slave device, then actively sends data to the slave device, and finally the host terminates the data transmission; if the host wants to receive data from the slave device, the master device first addresses the slave device. Then the host receives the data sent from the device, and finally the host terminates the receiving process. in this case. The host is responsible for generating the timing clock and terminating data transfers .

3.2.2 SPI (Board to Board)

        SPI is the abbreviation of Serial Peripheral Interface (Serial Peripheral Interface), which is a high-speed, full-duplex, synchronous communication bus, and only occupies four wires on the pins of the chip , saving the pins of the chip, At the same time, it saves space and provides convenience for PCB layout.

(5 messages) Super detailed explanation of the principle of SPI --- worth a look_Z Xiaoxuan's Blog-CSDN Blog_spi

SPI and SCI are different

SPI: SPI is the abbreviation of Serial Peripheral Interface (Serial Peripheral Interface). At the same time, it saves space and provides convenience for PCB layout. It is because of this easy-to-use feature that more and more chips integrate this communication protocol , such as AT91RM9200.

SCI: SCI (Serial Communication Interface) means "serial communication interface ", which is relative to parallel communication. It is a general term for serial communication technology, which was first proposed by Motorola. It is a universal asynchronous communication interface UART , which is basically the same as the asynchronous communication function of MCS‐51.

The difference between SPI and SCI - eefocus.com

"SPI transmission timing"

The clock of the slave device is provided by the master device through SCLK, and MOSI and MISO complete data transmission based on this pulse.

The working timing mode of SPI is determined by the phase relationship between CPOL (Clock Polarity, clock polarity) and CPHA (Clock Phase, clock phase). CPOL indicates the state of the initial level of the clock signal (that is, the idle state). CPOL is 0, indicating that the initial state of the clock signal is low level, and 1, indicating that the initial level of the clock signal is high level. CPHA indicates on which clock edge the data is sampled, CPHA being 0 means sampling data on the first clock change edge, and CPHA being 1 means sampling data on the second clock change edge.

According to different combinations of CPOL and CPHA, there are 4 working timing modes:

①CPOL=0,CPHA=0

②CPOL=0,CPHA=1

③CPOL=1,CPHA=0

④CPOL=1,CPHA=1

One article to understand the transmission timing of SPI

3.2.3 Serial communication RS232, RS485 (Board and PC)

 The difference between USB to serial port TTL RS-232 RS-485 COM port UART_Z Xiaoxuan's blog-CSDN blog_usb to serial port ttl

Synchronous communication and asynchronous communication:

The difference between synchronous communication and asynchronous communication is: the presence or absence of a clock line. Synchronous communication has a clock line, and the sending and receiving parties use a unified clock to determine when to transmit data, such as I2C and SPI. There is no clock line for asynchronous communication, and characters can be sent at any time, but only flag bits can be added at the beginning and end of the data to distinguish different data frames, that is, start bits and stop bits are added, and the transmitted data is in bytes. A start bit is added before each byte, and a stop bit is added after each byte. Before receiving data, the baud rate must be known in advance, and the transmission efficiency is lower than that of synchronous communication. Like UART but convenient and simple, easy to operate

 simply put:

Synchronization refers to the communication method in which the sender sends the data and waits for the receiver to send back a response before sending the next data packet.  
Asynchronous means: after the sender sends data, it does not wait for the receiver to send back a response, and then sends the communication method of the next data packet.

Serial communication and parallel communication:

Serial communication is a data line, and the data is transmitted bit by bit.    

The parallel communication is 8 data lines, and the data is sent byte by byte.

The serial port can be described as one lane, while the parallel port has 8/16 lanes that can transmit 8/16 bits (one byte/two bytes) data at the same time. 

3.2.4 Communication between FIFO processes

3.2.5 ModBus 

Modbus can connect control devices produced by different manufacturers into an industrial network for centralized monitoring, and is a general industrial standard. Modbus is a master/slave architecture protocol. One node is the master node, and other nodes that use the Modbus protocol to participate in communication are slave nodes. Each slave device has a unique address. Only the node designated as the master node can initiate a command. All Modbus data frames contain a check code to ensure the correctness of transmission. Basic ModBus commands can instruct a slave device to change a value in one of its registers, control or read an I/O port, and direct the device to send back data in one or more of its registers.    

Brief description of MODBUS-RTU and ASCII modes and CRC and LRC verification methods

Modbus is an application-layer messaging protocol  at layer 7 of the OSI model that provides client/server communication between devices connected to different types of buses or networks. The Modbus application layer protocol and service specifications mainly include two categories: one is Modbus on serial links (Modbus serial links depend on TIA/EIA standards: 232-F and 485-A), and the other is TCP/ Modbus over IP (Modbus TCP/IP depends on IETF standards: RFC793 and RFC791 are related).

(3 messages) Understand the Modbus protocol in one article_Programmer's blog without hair loss-CSDN blog

3.2.6 JTAG

JTAG is used for hardware testing and system debugging, that is, a method for factory testing of PCBs. JTAG is an IEEE standard developed in the 1980s (Joint Test Action Group; Joint Test Action Group) to solve electronic board manufacturing problems, and more Commonly used is a protocol that can be used as a programming, debugging, and probing port. Mainly used for chip internal testing. Since it is a protocol, it is also an interface, an interface that connects the PC to the chip.

The basic principle of JTAG is to define a TAP (TestAccess Port; test access) inside the device. The state machine of the TAP controller changes the state through TCK and TMS to realize the input of data and instructions. node to test. The JTAG test allows multiple devices to be connected in series through the JTAG interface to form a JTAG chain, which can test each device separately. Now, the JTAG interface is also commonly used to implement ISP (In-System Programmable; online programming) to program devices such as Flash.

(2 messages) What is JTAG?_Jia 167's blog-CSDN blog_jtag

3.2.7 Ethernet protocol

        The Ethernet protocol is a protocol defined by the data link layer and the physical layer. After the data sent by the host in Ethernet collides, the host will execute the collision avoidance algorithm, so we say that Ethernet is a LAN communication standard based on collision zone and collision detection. The collision avoidance algorithm is that the host waits for a period of time and then resends the data. Therefore, the bottom layer of the Ethernet also has a retransmission mechanism, but the retransmission mechanism of the Ethernet is only to ensure that the data is sent from one host to another in the LAN.

Compare and understand MAC address and IP address:

        There are two sets of addresses in the actual data routing process, one is the source IP address and destination IP address, and the other is the source MAC address and destination MAC address.

The IP address describes the overall starting and ending points of the journey.
The MAC address describes the start and end of each interval on the road.
For example, when taking a bus, the source IP address is the stop where we get on the bus, the destination IP address is the stop where we finally get off, and the source MAC address is the last stop that the bus has arrived at, and the destination MAC address is the next stop of the bus. The site to be reached.

Therefore, during the routing process of data, the source IP address and destination IP address can be understood as not changing, and the source MAC address and destination MAC address of the data will change after each hop.

(3 messages) Data Link Layer Protocol——Ethernet Protocol_2021dragon's Blog-CSDN Blog_Ethernet Protocol

(3 messages) <13>Basic knowledge - Ethernet (Ethernet)_Dark_Ice_'s Blog-CSDN Blog_csdn Ethernet

3.2.8 MQTT protocol

MQTT is a protocol generated to avoid data transmission in some special environments in the Internet of Things.

MQTT ( Message Queuing Telemetry Transport ) is a messaging protocol  based on the publish / subscribe paradigm under the ISO standard (ISO/IEC PRF 20922). It works on the TCP/IP protocol family and is a publish/subscribe message protocol designed for remote devices with low hardware performance and poor network conditions . For this reason, it needs a message middleware  .

MQTT is a client - server based message publish/subscribe transport protocol. The MQTT protocol is lightweight, simple, open and easy to implement. These characteristics make it widely applicable. In many cases, including constrained environments such as machine-to-machine (M2M) communication and the Internet of Things (IoT). It is used extensively in sensors communicating via satellite links, medical devices that occasionally dial, smart homes, and some miniaturized devices.

 The origin of the MQTT Internet of Things protocol that you don't know - remote monitoring of oil pipelines based on satellite communications - Zhihu (zhihu.com)

3.3 Memory

3.3.1 Bootloader

Divided into three types: 1) Local power-on 2) Remote backup 3) Remote non-backup

Bootloader=Boot + loader

The purpose of Boot:
the ultimate goal: to jump to the C language; in order to run the program in the C language, a series of initializations will be performed, and how to allow software programmers to enter the development of the C language/higher-level language environment through a series of settings after the system is powered on , this process is the main purpose of boot.

The purpose of Loader:
the main purpose is to start to execute the application logic, such as lighting: need the interface development of the light; serial port input and output: need serial port programming; load the kernel of linux: flash programming, network card programming, initialization before the kernel starts. There will be different changes according to different applications.

If a development board wants to execute the loader, it must first look at what the boot has done.
Detailed explanation of Bootloader, it is enough to read this article to understand Bootloader

Before configuring the system clock, there is another problem. It will not work immediately after configuration, but it will take a while, and a watchdog must be introduced during this period. The watchdog is a timer. Within a period of time, if the timer is not fed again, once it decreases to 0, an interrupt/reset will be triggered, and the CPU is equivalent to restarting. Therefore, it is necessary to ensure that there is enough time to execute the preconditions (1), (2), (3), and (4), so the watchdog must be turned off for safety reasons before configuring the clock. At the same time, the interrupt must be turned off, because we haven't entered C or the system processing. Even if the interrupt comes, we still don't know how to deal with it, because our function has not been registered. The interrupt is also turned off, and the interrupt is turned on when the main function is called. In addition, MMU and CACHE can also be turned off. MMU generally refers to the use of the operating system. In general, bare-metal programs can be ignored for simplicity. For CACHE, the instruction CACHE does not matter whether it can be turned on or off, but Generally, it is best to turn off the data cache at this time. Although the speed can be improved, due to the problem of data integrity, it is possible that the integrity of the data will be affected after the cache is turned on, which will bring problems to later debugging. It's a big hassle, so turn it off first.
 

3.4 Embedded

3.4.1 Embedded Development

3.5 Operating system

3.5.1 What is an operating system

(1) linux, windows, android, ucos are the operating systems
(2) The operating system is essentially a program, composed of many source files, which need to be compiled and connected into an operating system program (vmlinz, zImage)
(3) The main components of the operating system The role is to manage computer hardware and provide a running environment for applications.

Core functions of the operating system:

(1) Memory management. If there is no operating system, the memory needs to be managed by the program itself. For example, where you want to use memory in uboot, you can use it casually, without registration or restrictions. At this time, if the program itself accidentally reuses the same block of memory, a program logic error will occur. After the system grows (with more memory), memory management is very troublesome; after the operating system is established, the operating system is responsible for managing and controlling all memory, and all applications need to apply and register with the operating system when they need to use memory. The memory management module allocates memory for you to use, which has the advantage of ensuring that memory usage will not conflict.
(2) Process scheduling. The operating system supports multiple applications running at the same time (so you can watch movies while chatting on QQ...), which is macroscopic parallelism. In fact, on a single-core CPU, it cannot be parallelized microscopically. The parallelism on the macroscopic level is the time-division multiplexing mechanism provided by the operating system. The process scheduling module of the operating system is responsible for switching between processes.
(3) Hardware equipment management. Without an operating system, you have to write your own code to control any hardware. With an operating system, the operating system itself will control each hardware, and the application program does not need to consider the specific details of the hardware. The hardware device management module of the operating system is the driver module.
(4) File system. A file system is a way of managing storage devices. The storage device is composed of many sectors, each sector has 512/1024/2048/4096 bytes, and the storage device needs to be read and written in units of sectors. If there is no file system, the program has to read and write sectors by itself, so it has to remember which file is in which sector. With the file system, we don't need to pay attention to the sector anymore, we only need to pay attention to the directory and file name in the file system, regardless of which sector the file is on the physical disk.

3.5.2 The driver is part of the kernel

Driver: A computer software term that refers to a program that drives software in a computer . A driver, short for a device driver, is a special program added to an operating system that contains information about a hardware device. This information enables the computer to communicate with the appropriate device. The driver is a configuration file written by the hardware manufacturer according to the operating system. It can be said that without the driver, the hardware in the computer cannot work.

(1) The driver is the hardware device management module in the kernel
(2) The driver works in the kernel state.
(3) Driver failures can crash the entire kernel
(4) Driver vulnerabilities can make the kernel unsafe

3.5.3 Applications and Kernel

(1) The application program does not belong to the kernel, but on top of the kernel
(2) The application program works in the user mode, which is restricted.
(3) Application failure will not lead to kernel crash
(4) The application calls the kernel work through the API interface defined by the kernel
(5) Summary 1: The application is the ultimate goal
(6) Summary 2: The kernel is to provide the underlying layer for the application resource management server 

3.5.4 System on Chip SOC

System-on-Chip (System-on-Chip) refers to the function of the entire system that can be realized on a single silicon chip.

A circuit system capable of realizing certain functions is composed of multiple modules, such as processors, interfaces, memories, analog-to-digital converters, and so on. These functional modules can be realized by discrete devices, and then combined on a printed circuit board (PCB) to form a system-on-a-board ( System-on-a-Board). 

What is a System on Chip "SOC"? _Hero's Xiaobai's blog-CSDN blog_soc system on chip

4. Knowledge Expansion

4.1 PID control algorithm

In Inovance frequency converter, PID control algorithm is used. PID algorithm is called universal algorithm, which is mainly divided into position PID algorithm and incremental PID algorithm.

PID actually refers to "proportional", "integral" and "derivative", these three constitute the basic elements of PID. Each completes a different task and has a different impact on system functionality. Its structure is simple, its parameters are easy to adjust, and it is a control algorithm often used in control systems.

(1 message) Analysis of the difference between positional PID and incremental PID_Z Xiaoxuan's blog-CSDN blog_The difference between incremental pid and positional pid

PID (proportion integration differentiation) actually refers to proportional, integral, differential control. (When I read this algorithm at the beginning, the formula can be understood, and I know how to use it and how to write the code, but I just don’t know the principle, and I don’t know why the three items of proportion, differentiation, and integration are used to achieve the best control. Why can’t two, what is the benefit of using 3 items, what is the role of each item) see the following article

(1 message) Read and understand the PID control algorithm in one article (abandon the formula and truly understand PID control from the principle)_Determining Finite Automata Blog-CSDN Blog_pid

One article to understand the PID control algorithm

4.2 Filtering algorithm 

4.2.1 Mean filter, median filter

The following is the implementation of the algorithm codes of mean filtering, median filtering, first-order filtering, Kalman filtering, etc. and the figure after filtering

Filtering algorithm - mean filtering, median filtering, first-order (αβ) filtering, Kalman filtering_GoodluckTian's Blog-CSDN Blog_Filtering Algorithm

Kalman filter: In-depth understanding and visualization of Kalman filter - Zhihu (zhihu.com) 

Kalman filter algorithm principle (KF, EKF, AKF, UKF)_GoodluckTian's blog-CSDN blog_Kalman filter algorithm principle

4.2.2 LC, RC filter circuit

        Commonly used filter circuits are passive filter and active filter two categories. The main forms of passive filtering are capacitor filtering, inductive filtering and compound filtering (including L-type, LC filtering, LCπ-type filtering and RCπ-type filtering, etc.). The main form of active filtering is active RC filtering, also known as electronic filter. The size of the pulsation component in the direct current is represented by the pulsation coefficient, and the larger the value, the worse the effect of the filter.

        Capacitors have the ability to "block DC, pass AC, pass high frequency, and block low frequency", while inductors have the function of "passing DC, blocking AC, passing low frequency, and blocking high frequency".

(1) Compared with LC filters, RC filters are easier to miniaturize or integrate, and the relative volume of LC is larger;

(2) The RC filter has loss, and the LC filter can theoretically have no loss;

(3) RC is smaller than LC, and the cost is low;

(4) RC is used in low-frequency circuits, and LC filters are generally used in high-frequency circuits;

(5) The resistance in the RC filter consumes a part of the DC voltage. R cannot be made very large, and it is used in a circuit with low current requirements. The RC is small in size and low in cost. The filtering effect is not as good as that of the LC circuit; the LC filter is mainly inductive The resistance is small, the DC loss is small. The inductive reactance to AC is large, and the filtering effect is good. The disadvantage is that it is bulky and heavy. The cost is high. It is used in power circuits with high requirements.

(6) The more filtering stages, the better the effect, but the higher the loss and cost, so it is not recommended to exceed 3 stages;

(7) RC filters are generally used in combination with operational amplifiers to form active filters, and are mostly used for filtering low-frequency signals. For example, it is used as a loop filter in a phase-locked loop.
Analysis of LC and RC filter circuits

4.3 Clock tree

The clock tree has a system clock and other clocks, which process clock signals through different devices.

HSE (high-speed external clock signal) is generally used, and HSI (high-speed internal clock signal) is used only after HSE has a problem, because the frequency of HSI will fluctuate and be unstable according to the temperature and environment.

(3 messages) STM32-RCC Clock-Clock Tree Introduction_Learn c entry to buried blog-CSDN blog_clock tree

Guess you like

Origin blog.csdn.net/qq_43681154/article/details/125841618