Steps for learning Single-Chip Microcomputer

Source: Internet
Author: User

Learning to use single-chip microcomputer is to understand the hardware structure of single-chip microcomputer, as well as the application of internal resources, to learn initialization settings of various functions in the compilation or C language, and to implement programming of various functions.

Step 1: use of digital I/O

With the button input signal, the Light Emitting Diode shows the output level, you can learn the digital I/O function of the pin, after pressing a button, a light emitting diode is shining, this is the function of combining logic in a digital circuit. Although it is very simple, you can learn general single-chip microcomputer programming ideas. For example, you must set many registers to initialize the pins, in order to enable the pin to have digital input and output functions. Each time a single-chip microcomputer function is used, it is necessary to set the registers that control this function. This is the characteristic of single-chip microcomputer programming. Do not be afraid of trouble. All single-chip computers are like this.


Step 2: timer usage

You can use a single-chip microcomputer to implement a time series circuit when using a timer. The time series circuit is powerful and has many applications in the control of industrial and household electrical equipment. For example, you can use a single-chip microcomputer to implement a corridor light switch with a button. After the button is pressed once, the light will automatically go off after three minutes. When the button is pressed twice in a row, the light will always go off, when the button is pressed for more than 2 s, the light is off. Digital integrated circuits can implement time series circuits, Programmable Logic Devices (PLD) can implement time series circuits, and programmable controllers (PLC) can also implement time series circuits, but only single-chip microcomputer can achieve the simplest, the lowest cost. In initial use, you can make a simple example, such as timing 500 ms to make the LED flash. The use of timer is very important, and logical plus time control is the basis for the use of single chip microcomputer.

Step 3: interrupt

Single-chip microcomputer is characterized by repeated execution of a program. The execution of each instruction in the program takes a certain amount of time. If the program does not execute a certain instruction, the action of this instruction will not happen, this will delay many fast events, such as the descent edge when the button is pressed. In order for the microcontroller to respond to the rapid action during the normal operation of the program, the interrupt function of the microcontroller must be used. This function is used to interrupt the normal operation of the program after the rapid action occurs, process the quick action. After the action is completed, the normal program is returned. The difficulty in using the interrupt function is that you need to know exactly when the interrupt is not allowed (the interruption is blocked) and when the interrupt is allowed (the interrupt is enabled ), which registers need to be set to enable certain interruptions to take effect? What should the program do when the interruption starts, what should the program do after the interruption is completed. After learning to interrupt, you can compile a program with a more complex structure. Such a program can do one thing and monitor one thing. Once something is monitored, interrupt what is being done, process monitoring, of course, you can also monitor multiple things, the image analogy, the interruption function enables the single-chip microcomputer to have a bowl, look at the pot function.

The above three steps are equivalent to killing the dragon and giving up the eight-handed martial arts. You can barely protect yourself.

Step 4: Perform RS232 communication with PC

Currently, single-chip microcomputer basically has UART interfaces, many of which have two UART interfaces. When a single-chip microcomputer communicates with a PC through a serial port, the UART interface and the computer's RS232 interface need to use a chip similar to maxcompute for level conversion. The use of UART interface is very important. Through this interface, information can be exchanged between single-chip microcomputer and PC. Although RS232 communication is not advanced, it is very important to learn interfaces. To use the UART interface correctly, you need to learn about the communication protocol and PC RS232 interface programming. Imagine how interesting the data on the single-chip microcomputer lab board is displayed on the PC monitor, and the keyboard signal of the PC can be displayed on the single-chip microcomputer lab board!

Step 5: Learn A/D Conversion

Currently, the single-chip microcomputer with better performance has an on-chip ADC, supporting multi-channel resolution from 8-bit, 10-bit to 12-bit or higher. These A/D converters allow single-chip microcomputer to perform analog operations to display and detect voltage, current, and other signals. When learning, pay attention to the concepts of analog and digital, reference voltage, sampling time, conversion rate, and conversion error. A simple example of using the/D conversion function is to design a voltmeter.

Step 6: Learn SPI, I2C interface and LCD interface

The use of these interfaces makes it easier for single-chip microcomputer to connect to external devices, which is very important to extend the single-chip microcomputer function.

Step 7: Learn the comparison, capture, and PWM Functions

These functions enable the single-chip microcomputer to control the motor, detect the speed signal, and implement control functions such as the motor governor. If you have learned the above seven steps, you can design a general application system, which is equivalent to learning to attack the system.

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

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


So far, it is equivalent to learning to attract and drop the top 18, but it is not as good as it is. Even so, it is also a single-chip microcomputer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.