8 key points to learn and develop single chip microcomputer

Publisher:advancement3Latest update time:2018-05-29 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Learning MCU means learning the hardware structure of MCU, the application of internal resources and peripherals. Master the initialization of various functions in C language (with a small amount of assembly), and realize the writing and debugging of various functional functions.

1. Application of digital I/O

In most MCU experiments, the marquee and key detection experiments are typical applications of digital I/O. By setting or clearing the I/O pin of the MCU to light up or turn off the LED light, and reading the status of the button being pressed or released, although it is simple, this is the logical function in the digital circuit.

The digital I/O experiment teaches us the programming concept of the microcontroller. We must first configure the corresponding registers of the microcontroller 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 the microcontroller is to set and initialize the registers related to the function, which is the characteristic of microcontroller programming.

2: RS 232 serial communication

The microcontroller has a UART interface, which 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 SP3232 chip.

The use of UART interface is very important. Through this interface, we can exchange information between the microcontroller and the PC. The concept of "interface" is introduced here. Using UART interface will also help us learn the simplest and most commonly used communication protocols. We can also monitor the data of the microcontroller experimental board through the PC's serial port debugging software.

Three: Use of timer

Once you learn how to use a timer, you can use a microcontroller to implement a typical sequential logic circuit. Sequential logic circuits are the most powerful and widely used. For example, in industrial control, we let a switch open and close every 1 second. 
The timer is the most important internal resource of a microcontroller, and it is the basis for the realization of logic and time control.

Four: Interruption

In the microcontroller software design architecture, the loop execution of a program is a feature and also a drawback. 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, so many fast-occurring events, such as the rising edge of square wave frequency detection, will be ignored. The interrupt function is designed to respond immediately to external events when the microcontroller program is running normally. 
When the interrupt function is executed, the microcontroller gives priority to processing the interrupt program. When the interrupt processing is completed, it returns to the normal program execution of the microcontroller. The mechanism of interrupt is relatively easy to understand, but when to turn on the interrupt, when to turn off and mask the interrupt, how to configure 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 the interrupt, you can write programs with complex structure functions, which can flash a small LED light, scan buttons, send data, and do multiple things... To make an analogy, the interrupt function can make the microcontroller eat what is in the bowl and look at what is in the pot.

Five: I2C, SPI communication interface

After all, the resources of the microcontroller system are limited, and using the I2C and SPI communication interfaces to expand peripherals is the most common method and also a very important method. These two communication interfaces are serial communication interfaces, and the typical basic experiments are the I2C EEPROM experiment and the SPI SD card reading and writing experiment.

Six: Compare, Capture, PWM

By comparison, the capture and PWM functions can make the microcontroller more suitable for motor control, signal detection, and 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.

七:AD、DA

At present, most single-chip microcomputers have built-in multi-channel A/D analog-to-digital converters. Through these A/D converters, the single-chip microcomputer 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 digital circuits control analog circuits, and the simplest A/D analog-to-digital converter is the voltmeter experiment.

8: RS485, CAN, USB, TCP/IP protocol, industrial bus

The mainstream communication protocols at present are USB protocol - high-speed communication interface between lower and upper computers; 
TCP/IP - universal communication protocol used by the Internet; 
industrial bus - protocols such as Modbus, CANOpen, etc. for communication between various modules of industrial control. These will be applied in future projects, integrated into the firmware of the microcontroller, and are also a development direction of current product development.


Reference address:8 key points to learn and develop single chip microcomputer

Previous article:51 interrupt priority and interrupt nesting
Next article:Detailed explanation of 51 single-chip microcomputer interrupts (Part 1)

Latest Microcontroller Articles
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号