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.
Previous article:51 interrupt priority and interrupt nesting
Next article:Detailed explanation of 51 single-chip microcomputer interrupts (Part 1)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- How to use a power amplifier to amplify and output a pulse train signal? How to use the Burst function of a signal generator?
- 【DIY Creative LED】LED lights and holes
- Surge arrester explanation and working principle
- Is there any error in the schematic diagram of the electrostatic generator?
- Cheap_Flash_FS (SPI_Flash version) -- embedded SPI_FLASH file system free source code, please download
- TPS61040 boost circuit abnormality
- [Atria AT32WB415 series Bluetooth BLE 5.0 MCU] + CAN communication
- What does it mean when a pushpin icon is displayed during STM32CubeMX pin configuration?
- Does TI C6678 support flash partitioning?
- 6678 SRIO: About QMSS, CPPI and SRIO Socket