January 09, 2025

Embedded Engineers Share: Eight Steps to Learn MCUs

To become an embedded engineer, simple single-chip learning and application is indispensable. Learning microcontroller is to learn the hardware structure of the microcontroller, the application of internal resources and peripherals. In the C language (very small amount of assembly) to master the initialization of various functions, start and stop, to achieve the writing and debugging of various functional functions.

The first step: the application of digital I / O

In most of the MCU experiments, the marquee experiment is a typical application of digital I/O, and it is also the reason why the experiment of the marquee is scheduled. Turning the LED on or off by setting or clearing the I/O pins of the microcontroller is simple, but this is the logic function in digital circuits. Experiments in math I/O applications also have a button experiment where an LED is illuminated when a key is pressed. The digital I/O experiment teaches us the programming idea of ​​the microcontroller. We must first configure the corresponding register of the microcontroller to initialize the I/O pin, so that the pin can have digital input and output functions. The use of a built-in or external function of the microcontroller is to set and initialize the registers associated with the function, and this is the feature of the microcontroller programming. If you have 4 or 5 functions, you can get more than a dozen lines of programs. Be patient and don't be bothered. All microcontrollers are like this.

The second step: RS232 serial communication

The MCU has a UART interface. This simple, old communication method can be directly connected to the RS232 interface of our PC. Of course, because of their different level logic, an RS232 level conversion chip must be used to connect to the PC. , for example, the Max232 chip.

The use of the UART interface is very important. Through this interface, we can exchange information between the microcontroller and the PC, and the learning of the "interface" concept is introduced. Using the UART interface will also learn the most simple and commonly used communication protocols. We can also monitor the data of the single-chip experimental board through the serial debugging software of the PC. Think about it, this is a magical thing~~

The third step: the use of timers

By learning the use of timers, you can use a microcontroller to implement a typical sequential logic circuit. The application of sequential logic circuits is the most powerful and extensive. For example, in industrial control, we let a switch turn on and off every 1 second. This solution can be implemented by an ordinary digital integrated circuit, or by a PLC, or by a CPLD or an FPGA, but only the implementation of the single chip is the simplest and the most economical. The timer is the most important one in the internal resources of the microcontroller, and it is the basis of the logic and time control implementation.

Step 4: Interrupt

In the microcontroller software design architecture, a program loop execution is one of its characteristics, but also a drawback. The execution of each operation instruction requires a certain execution time. If the program does not execute the instruction, the action of the instruction will not be triggered. This will ignore many fast-occurring events, such as the rising edge of square wave frequency detection. The interrupt function is designed to respond immediately to external events while the microcontroller program is running normally. When the interrupt function is executed, the MCU preferentially processes the interrupt program. When the interrupt processing is completed, it returns to the normal program execution of the microcontroller. The mechanism of the interrupt is relatively easy to understand, but when to open the interrupt, when to close, to mask the interrupt, how to configure to enable some functions of the interrupt, which programs to execute in the interrupt, what requirements are required for these programs? Take some time to understand and practice. After interrupting the learning, you can write a program with complex structure functions. You can flash a small LED light while scanning the button, while sending data, you can also do a lot of things... To make a metaphor, the interrupt function can make the microcontroller eat. In the bowl, looking at the pot. According to the legendary 8020 law, if you master the four steps mentioned above, then you have learned 80% of the content.

Step 5: I2C, SPI communication interface

After all, the SCM system has limited resources, and the use of I2C and SPI communication interfaces to extend peripherals is the most common method and a very important method. These two communication interfaces are serial communication interfaces. The typical basic experiment is the I2C EEPROM experiment and the SPI SD card reading and writing experiment.

Step 6: Compare, capture, PWM function

Comparison, capture and PWM functions can make the microcontroller more suitable for motor control, signal detection, and achieve motor speed and step adjustment. The PWM wave is now the main means of LED dimming. Here we have initially touched the analog circuit part of the digital circuit.

Step 7: A/D modulus acquisition

At present, the MCU basically has a multi-channel A/D analog-to-digital converter. Through these A/D converters, the MCU can acquire analog quantities for detecting voltage, current and other signals. When learning, it is necessary to distinguish between analog ground and digital ground, reference voltage, sampling time, slew rate, conversion error and other important concepts. This step learned the digital circuit control analog circuit part, and the simplest A/D analog-to-digital converter is the voltmeter experiment.

Step 8: Learn USB interface, TCP/IP protocol, industrial bus

At present, the mainstream communication protocol is USB protocol - high-speed communication interface between lower computer and upper computer; TCP/IP - universal communication protocol for Internet use; industrial bus - communication protocol for communication between various modules such as Modbus, CANOpen . These will be applied to future projects, integrated into the firmware of the microcontroller, and is also a development direction of current product development.

Isolated Safety Barrier

The main function of the safety barrier is to restrict the dangerous energy in the safe place from entering the dangerous place, that is, to limit the voltage and current sent to the dangerous place.

1. Due to the tripartite isolation mode, there is no need for system grounding line, which brings great convenience to the design and on-site construction. The requirements for instruments in hazardous areas are greatly reduced, and isolated instruments are not required on site.
2. Since the signal line does not need to be grounded together, the stability and anti-interference ability of the detection and control circuit signal are greatly enhanced, so as to improve the reliability of the whole system.
3. The isolated safety barrier has stronger input signal processing ability and can accept and process thermocouple, thermal resistance, frequency and other signals, which is impossible for Zener safety barrier.
4. The isolated safety barrier [2] can output two mutually isolated signals to be used by two equipment using the same signal source, ensure that the signals of the two equipment do not interfere with each other, and improve the electrical safety insulation performance between the connected equipment.

Isolated Safety Barrier,Output Intrinsic Isolated Safety Barrier,Explosion-Proof Relay Isolated Barrier,Switch Explosion-Proof Relay Barrier

Taizhou Jiabo Instrument Technology Co., Ltd. , https://www.jbcbyq.com