Several necessary steps to learn MCU in depth

Publisher:hxcp18Latest update time:2016-08-26 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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

Previous article:Crystal ESR and C
Next article:Connection between microcontroller and incremental rotary encoder

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号