Microcontroller C language learning architecture

Publisher:悠然自在Latest update time:2022-12-14 Source: zhihu Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The first thing many people who want to learn microcontrollers ask me is how to learn microcontrollers well? Regarding this issue, I will tell you today how I started learning microcontrollers, how to get started, and how to become proficient in this process.


step

1. Find a book to get a general understanding of the microcontroller structure, and it’s enough to have a general understanding. You don’t have to understand everything, and I won’t let you publish a book. (three days)

2. Find a learning board to practice programming. Learning microcontrollers means practicing programming. If you encounter something you don’t know, ask people or look up books. (twenty days)

3. Find some information on small circuits online to practice designing peripheral circuits. After welding, debug it yourself and become familiar with the process. (ten days)

4. Completely design circuits and products with your own personal style, you are already a master.

Learning and practice of single-chip microcomputer

The improvement of microcontrollers focuses on practice. If you want to learn microcontrollers well, software programming is essential. But being familiar with the hardware is also very important for learning microcontroller well. How to learn hardware well, hands-on practice is essential. We can make our own electronic production by ourselves, and by completing it, we can improve our understanding of some chips and the proficiency in using them. In this way we can learn more about the structure of the chip. I believe that after you complete an electronic production of your own, your microcontroller level will be qualitatively improved.


Step One: Use of Digital I/O

Using buttons to input signals and LEDs to display output levels, you can learn the digital I/O functions of the pins. After pressing a certain button, a certain LED lights up. This is the function of combinational logic in digital circuits, although it is very simple. It is simple, but you can learn general MCU programming ideas. For example, you must set up many registers to initialize the pins so that the pins can have digital input and output functions. Every time you use a function of the microcontroller, you must set the register that controls the function. This is the characteristic of microcontroller programming. Don't be afraid of trouble. All microcontrollers are like this.


Step 2: Use of timer

Once you learn how to use a timer, you can use a microcontroller 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, you can use a microcontroller 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, the light will stay 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 (PLD) can implement sequential circuits, and programmable controllers (PLC) can also implement sequential circuits. However, only microcontrollers are the simplest and lowest cost to implement. The use of timers is very important. Logic plus time control is the basis for the use of microcontrollers.


Step 3: Interrupt

The characteristic of a single-chip microcomputer is that a program is executed repeatedly. The execution of each instruction in the program requires a certain amount of execution time. If the program does not execute an instruction, the action of the instruction will not occur, which will delay many things that happen quickly. Things like, for example, the falling edge when a button is pressed. In order for the microcontroller to respond to fast actions during the normal running of the program, the interrupt function of the microcontroller must be used. This function is that after a fast action occurs, the microcontroller interrupts the normal running program and processes the fast action. After the processing is completed , and then return to execute the normal program.

The difficulty in using the interrupt function is that you need to know precisely when interrupts are not allowed to occur (mask interrupts), when interrupts are allowed to occur (interrupts are enabled), and which registers need to be set to make certain interrupts work. When the interrupt starts, the program should What to do, what should the program do after the interrupt is completed, etc. After you learn how to interrupt, you can compile a program with a more complex structure. Such a program can do one thing and monitor one thing. Once the monitored thing happens, it will interrupt what you are doing and handle the monitored thing. Of course, you can also Monitoring multiple things, vivid metaphor, and interrupt function make the microcontroller have the function of eating from the bowl and watching the pot.

Learning the above three steps is equivalent to the Eighteen Dragon Subduing Palms martial arts. After mastering three palms, you can barely protect yourself.


Step 4: RS232 communication with PC

Microcontrollers have USART interfaces, especially many models in the MSP430 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 MAX3232 chip needs to be used for level conversion.

The use of the USART interface is very important. Through this interface, information can be exchanged between the microcontroller and the PC. 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, PC RS232 interface programming, etc. Just imagine, the data on the microcontroller experiment board is displayed on the PC monitor, and the PC keyboard signal can be displayed on the microcontroller experiment board. How interesting it would be!


Step 5: Learn A/D conversion

The MAP430 microcontroller has a multi-channel 12-bit A/D converter. Through these A/D converters, the microcontroller can operate analog quantities, display and detect signals such as voltage and current. When studying, pay attention to concepts such as 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 PCI, I2C interface and LCD interface

The use of these interfaces can make it easier for the microcontroller to connect to external devices, and is very important in expanding the functionality of the microcontroller.


Step 7: Learn to compare, capture, and PWM functions

These functions enable the microcontroller to control the motor, detect the speed signal, and implement control functions such as motor speed regulator. If you learn all the above seven steps, you can design a general application system, which is equivalent to learning the ten moves to subdue the dragon and the eighteen palms, and you can attack.


Step 8: Learn the hardware and software design of USB interface, TCP/IP interface, and various industrial buses.

It is very important to learn the hardware and software design of USB interfaces, TCP/IP interfaces, and various industrial buses, because this is the current development direction of product development.

So far, it is equivalent to learning 15 moves and the Eighteen Dragon-Subduing Palms, but it is not yet at the level of defeating invincible opponents in the world. Even so, it is still a microcontroller prawn!!


Reference address:Microcontroller C language learning architecture

Previous article:Understand UART communication protocol in one article
Next article:Microcontroller study notes, three steps to teach you

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号