Eight steps to become a MCU master

Publisher:SereneMeadowLatest update time:2017-11-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Learning to use a microcontroller is to understand the microcontroller hardware structure and the application of internal resources, learn the initialization settings of various functions in assembly or C language, and program the realization of various functions. The following are some of my experiences:
    
    Step 1: Use of digital I/O
    Use buttons to input signals and light-emitting diodes to display output levels, so that you can learn the digital I/O function of the pins. After pressing a button, a certain light-emitting diode lights up. This is the function of combinational logic in digital circuits. Although it is very simple, you can learn general microcontroller programming ideas. For example, many registers must be set to initialize the pins so that the pins have digital input and output functions. Every time a function of the microcontroller is used, the register that controls the function must be set. This is the characteristic of microcontroller programming. Don't be afraid of trouble. All microcontrollers are like this. It should be noted that two functions use the same group of I/O ports. For example, the LCD and LED routines all use the PB group. If the two are combined, there will be conflicts and the expected effect cannot be achieved. It is recommended that different modules use different IO ports.
    
    Step 2: Use of timer
    
    Once you learn how to use the timer, you can use a single-chip microcomputer to implement a sequential circuit. The function of the sequential circuit is powerful and has many applications in the control of industrial and household electrical equipment. For example, a single-chip microcomputer can be used to implement a corridor light switch with a button. After the button is pressed once, the light will automatically turn off after 3 minutes. When the button is pressed twice in succession, the light will always be on. When the button is pressed for more than 2 seconds, the light will turn off. Digital integrated circuits can implement sequential circuits, programmable logic devices (PLDs) can implement sequential circuits, and programmable controllers (PLCs) can also implement sequential circuits, but only single-chip microcomputers are the simplest and the lowest cost.
    
    The use of timers is very important. Logic plus time control is the basis for the use of single-chip microcomputers.
    
    Step 3: Interrupts
    
    The characteristic of a single-chip microcomputer is that a program is repeatedly executed. The execution of each instruction in the program requires a certain execution time. If the program does not execute a certain instruction, the action of the instruction will not occur, which will delay many fast-moving things, such as the falling edge when a button is pressed. In order to make the MCU respond to fast actions during the normal operation of the program, the interrupt function of the MCU must be used. This function is that after the fast action occurs, the MCU interrupts the normal operation of the program, processes the fast action, and returns to execute the normal program after the processing is completed.
    
    The difficulty in using the interrupt function is that it is necessary to accurately know when the interrupt is not allowed to occur (shield interrupt) and when the interrupt is allowed to occur (open interrupt), which registers need to be set to make a certain interrupt work, what the program should do when the interrupt starts, what the program should do after the interrupt is completed, etc. After learning the interrupt, you can compile a more complex program. Such a program can do one thing and monitor one thing. Once the monitored thing happens, it interrupts the thing being done and processes the monitored thing. Of course, it can also monitor multiple things. Figuratively speaking, the interrupt function enables the MCU to have the function of eating from the bowl and watching the pot. Learning the above three steps is equivalent to the martial arts of the Eighteen Dragon Palms. If you have learned three palms, you can barely protect yourself.
    
    Step 4: RS232 communication with the PC.
    
    The MCU has a USART interface, especially many models in the stm8 series, which have two USART interfaces. The USART interface cannot be directly connected to the RS232 interface of the PC. The logic levels between them are different, and a stm8s105c6 chip is needed for level conversion. The use of the USART interface is very important. Through this interface, the microcontroller and the PC can exchange information. Although RS232 communication is not advanced, it is very important to learn the interface. To use the USART interface correctly, you need to learn the communication protocol, the RS232 interface programming of the PC, and so on. Imagine that the data on the microcontroller experimental board is displayed on the PC monitor, and the keyboard signal of the PC can be displayed on the microcontroller experimental board. How interesting it will be!
    
    Step 5: Learn A/D conversion
    
    The stm8 microcontroller has a multi-channel 12-bit A/D converter. Through these A/D converters, the microcontroller can operate analog quantities, display and detect voltage, current and other signals. When learning, pay attention to the concepts of analog ground and digital ground, reference voltage, sampling time, conversion rate, conversion error, etc. A simple example of using the A/D conversion function is to design a voltmeter.
    
    Step 6: Learn
    
    the use of PCI, I2C interface and LCD interface. These interfaces can make it easier for the microcontroller to connect to external devices, which is very important in expanding the functions of the microcontroller.
    
    Step 7: Learn the comparison, capture and PWM functions.
    
    These functions can enable the microcontroller to control the motor, detect the speed signal, and realize the control functions such as the motor speed regulator. If you have learned all the above seven steps, you can design a general application system, which is equivalent to learning the 10 moves of the 18th Palm of the Dragon, and you can attack.
    
    Step 8: Learn the hardware and software design of the USB
    
    interface, TCP/IP interface, and various industrial buses. Learning the hardware and software design of the USB interface, TCP/IP interface, and various industrial buses is very important because it is the development direction of current product development.
    
    So far, it is equivalent to learning 15 moves of the 18th Palm of the Dragon, but it is not yet the realm of being invincible. Even so, it is still a microcontroller hero.

Reference address:Eight steps to become a MCU master

Previous article:Principle and function of single chip microcomputer crystal oscillator circuit
Next article:Detailed explanation of the connection between RXD and TXD of microcontroller serial communication

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号