To become an embedded engineer, simple microcontroller basic learning and application are indispensable. Learning microcontrollers means learning the hardware structure of microcontrollers, the application of internal resources and peripherals. In C language (very little assembly), master the initialization, start and stop of various functions, and realize the writing and debugging of various functional functions.
Step 1: Application of digital I/O
In most microcontroller experiments, the marquee experiment is a typical application of digital I/O, which is also the reason why the marquee experiment is arranged first. By setting or clearing the I/O pin of the microcontroller to light up or turn off the LED light, although it is simple, this is the logical function in the digital circuit. The experiment of mathematical I/O application also has a key experiment. When a key is pressed, a certain LED light is lit. The digital I/O experiment teaches us the programming ideas of microcontrollers. The corresponding registers of the microcontroller must be configured first to initialize the I/O pins, so that the pins can have digital input and output functions. The use of a built-in or external function of a microcontroller is to set and initialize the registers related to the function, which is the characteristic of microcontroller programming. It takes at least 4 or 5 functions, or more than a dozen lines of program. Be patient and don't be afraid of trouble. All single-chip microcomputers are like this.
Step 2: RS232 serial communication single-chip
microcomputers have UART interfaces. This simple and ancient communication method can be directly connected to the RS232 interface of our PC for communication. Of course, because their level logic is different, an RS232 level conversion chip must be used to connect to the PC, such as the Max232 chip.
The use of the UART interface is very important. Through this interface, we can exchange information between the single-chip microcomputer and the PC, and the concept of "interface" is introduced. Using the UART interface will also learn the simplest and most commonly used communication protocols and other knowledge. We can also monitor the data of the single-chip microcomputer experimental board through the serial port debugging software of the PC. Think about it, what a magical thing this will be~~
Step 3: Use of timers
Learn how to use timers, and you can use single-chip microcomputers to implement typical sequential logic circuits. The application of sequential logic circuits is the most powerful and widespread. For example, in industrial control, we let a switch open and close every 1 second. This solution can be implemented through ordinary digital integrated circuits, PLCs, CPLDs or FPGAs, but the implementation of a single-chip microcomputer is the simplest and most economical. The timer is the most important internal resource of the single-chip microcomputer, and it is also the basis for the implementation of logic and time control.
Step 4: Interrupt
In the single-chip microcomputer software design architecture, the cyclic execution of a program is a feature and also a disadvantage. 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, which will ignore many fast-occurring events, such as the rising edge of the square wave frequency detection. The interrupt function is designed to respond immediately to external events when the single-chip microcomputer program is running normally. When the interrupt function is executed, the single-chip microcomputer gives priority to processing the interrupt program. When the interrupt processing is completed, it returns to the normal program execution of the single-chip microcomputer. The mechanism of interrupt is relatively easy to understand, but when to turn on the interrupt, when to turn off and shield the interrupt, how to configure it to enable certain functions of the interrupt, which programs to execute in the interrupt, and what requirements these programs must meet require some time to understand and practice. After learning interrupts, you can write programs with complex structure functions. You can flash a small LED light, scan buttons, send data, or do multiple things at the same time... To put it in a metaphor, the interrupt function can make the microcontroller eat what is in the bowl and look at what is in the pot. According to the legendary 8020 law, if you have mastered the four steps mentioned above, then you have learned 80% of the content.
Step 5: I2C, SPI communication interface
After all, the resources of the microcontroller system are limited, and using I2C and SPI communication interfaces to expand peripherals is the most commonly used method and also a very important method. These two communication interfaces are serial communication interfaces. The typical basic experiments are the I2C EEPROM experiment and the SPI SD card reading and writing experiment.
Step 6: Comparison, capture, PWM function
comparison, capture and PWM functions can make the microcontroller more suitable for motor control, signal detection, and realize the adjustment of motor speed and step length. PWM wave is now the main means of LED dimming. Here we have already made a preliminary contact with the analog circuit part of the digital circuit.
Step 7: A/D analog-to-digital acquisition.
Currently, most microcontrollers have built-in multi-channel A/D analog-to-digital converters. Through these A/D converters, the microcontroller can obtain 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, conversion rate, conversion error and other important concepts. In this step, we learned how to control the analog circuit part of the digital circuit, and the simplest A/D analog-to-digital converter is the voltmeter experiment.
Step 8: Learn USB interface, TCP/IP protocol, industrial bus.
The current mainstream communication protocols are USB protocol - high-speed communication interface between the lower computer and the upper computer; TCP/IP - universal communication protocol used by the Internet; industrial bus - such as Modbus, CANOpen and other industrial control modules. The communication protocol. These will be used in future projects, integrated into the firmware of the microcontroller, and are also a development direction for current product development.
Keywords:MCU
Reference address:Several necessary steps to learn MCU in depth
Step 1: Application of digital I/O
In most microcontroller experiments, the marquee experiment is a typical application of digital I/O, which is also the reason why the marquee experiment is arranged first. By setting or clearing the I/O pin of the microcontroller to light up or turn off the LED light, although it is simple, this is the logical function in the digital circuit. The experiment of mathematical I/O application also has a key experiment. When a key is pressed, a certain LED light is lit. The digital I/O experiment teaches us the programming ideas of microcontrollers. The corresponding registers of the microcontroller must be configured first to initialize the I/O pins, so that the pins can have digital input and output functions. The use of a built-in or external function of a microcontroller is to set and initialize the registers related to the function, which is the characteristic of microcontroller programming. It takes at least 4 or 5 functions, or more than a dozen lines of program. Be patient and don't be afraid of trouble. All single-chip microcomputers are like this.
Step 2: RS232 serial communication single-chip
microcomputers have UART interfaces. This simple and ancient communication method can be directly connected to the RS232 interface of our PC for communication. Of course, because their level logic is different, an RS232 level conversion chip must be used to connect to the PC, such as the Max232 chip.
The use of the UART interface is very important. Through this interface, we can exchange information between the single-chip microcomputer and the PC, and the concept of "interface" is introduced. Using the UART interface will also learn the simplest and most commonly used communication protocols and other knowledge. We can also monitor the data of the single-chip microcomputer experimental board through the serial port debugging software of the PC. Think about it, what a magical thing this will be~~
Step 3: Use of timers
Learn how to use timers, and you can use single-chip microcomputers to implement typical sequential logic circuits. The application of sequential logic circuits is the most powerful and widespread. For example, in industrial control, we let a switch open and close every 1 second. This solution can be implemented through ordinary digital integrated circuits, PLCs, CPLDs or FPGAs, but the implementation of a single-chip microcomputer is the simplest and most economical. The timer is the most important internal resource of the single-chip microcomputer, and it is also the basis for the implementation of logic and time control.
Step 4: Interrupt
In the single-chip microcomputer software design architecture, the cyclic execution of a program is a feature and also a disadvantage. 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, which will ignore many fast-occurring events, such as the rising edge of the square wave frequency detection. The interrupt function is designed to respond immediately to external events when the single-chip microcomputer program is running normally. When the interrupt function is executed, the single-chip microcomputer gives priority to processing the interrupt program. When the interrupt processing is completed, it returns to the normal program execution of the single-chip microcomputer. The mechanism of interrupt is relatively easy to understand, but when to turn on the interrupt, when to turn off and shield the interrupt, how to configure it to enable certain functions of the interrupt, which programs to execute in the interrupt, and what requirements these programs must meet require some time to understand and practice. After learning interrupts, you can write programs with complex structure functions. You can flash a small LED light, scan buttons, send data, or do multiple things at the same time... To put it in a metaphor, the interrupt function can make the microcontroller eat what is in the bowl and look at what is in the pot. According to the legendary 8020 law, if you have mastered the four steps mentioned above, then you have learned 80% of the content.
Step 5: I2C, SPI communication interface
After all, the resources of the microcontroller system are limited, and using I2C and SPI communication interfaces to expand peripherals is the most commonly used method and also a very important method. These two communication interfaces are serial communication interfaces. The typical basic experiments are the I2C EEPROM experiment and the SPI SD card reading and writing experiment.
Step 6: Comparison, capture, PWM function
comparison, capture and PWM functions can make the microcontroller more suitable for motor control, signal detection, and realize the adjustment of motor speed and step length. PWM wave is now the main means of LED dimming. Here we have already made a preliminary contact with the analog circuit part of the digital circuit.
Step 7: A/D analog-to-digital acquisition.
Currently, most microcontrollers have built-in multi-channel A/D analog-to-digital converters. Through these A/D converters, the microcontroller can obtain 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, conversion rate, conversion error and other important concepts. In this step, we learned how to control the analog circuit part of the digital circuit, and the simplest A/D analog-to-digital converter is the voltmeter experiment.
Step 8: Learn USB interface, TCP/IP protocol, industrial bus.
The current mainstream communication protocols are USB protocol - high-speed communication interface between the lower computer and the upper computer; TCP/IP - universal communication protocol used by the Internet; industrial bus - such as Modbus, CANOpen and other industrial control modules. The communication protocol. These will be used in future projects, integrated into the firmware of the microcontroller, and are also a development direction for current product development.
Previous article:Crystal ESR and C
Next article:Connection between microcontroller and incremental rotary encoder
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
Guess you like
- Software requirements for legally controlling microcontrollers remotely via Android phones
- How to Meet the Testing Challenges of Multi-Antenna Systems
- Award-winning live broadcast: STMicroelectronics SiC products and industrial application guide, please watch at 10:00 on September 10~
- TecoCore Co., Ltd. is looking for SSD firmware development talents to join
- Texas Instruments' new synchronous boost converter TPS61288 is an ideal solution for wireless speaker boost converters
- New ideas for fast network configuration for micropython
- A new user uses Quartus for the first time
- Insulation paths and insulation types
- Top four domestic automotive chips
- ST extends long-term supply commitment for SPC56 automotive MCU to promote automotive electronics innovation