Share an easy-to-understand msp430 microcontroller learning tutorial
[Copy link]
Learning is the process of meeting challenges and solving difficulties. Without challenges, there is no fun in life. The following uses the MSP430 series microcontroller as an example to explain the process of learning microcontrollers.
Below, taking the MSP430 series microcontroller as an example, we will explain the process of learning microcontrollers.
(1) Obtaining information
Buy relevant books and get information from the Hangzhou Lierda Company website and the TI website. For example, you can find FET usage guides, MSP430 F1xx series, F4xx series usage instructions and specific microcontroller chip data on the Internet. You can find simulator FET circuit diagrams, experimental board circuit diagrams, chip packaging knowledge and a large number of practical application reference circuits. Of course, some information is in English, and it is a challenge to understand English information. Learning English at level 4 and level 6 is for reading information. English is difficult to learn, but reading information is easy. As long as you are determined, you can understand all relevant information after reading one book.
(2) Purchase simulator FET and experimental circuit board
If your financial situation is good, you can buy it directly.
(3) Homemade simulator FET and experimental circuit board
To make a self-made simulator FET, you must first find the FET circuit diagram on the Internet, and then you can use the circuit board drawing software to draw the circuit diagram and circuit board diagram, which is another challenge. The FET circuit is very simple, but it still takes some effort to make it. Find a relevant book and practice drawing the schematic diagram. After drawing the schematic diagram, learn to understand the component package and then buy the components. At this time, you can draw the circuit board diagram. Once the drawing is completed, the PCB file will be handed over to the circuit board production company. After 10 days, you can get the circuit board, solder the components and cables, and after the experimental circuit board is completed, you can debug it together with the experimental circuit board.
To make a self-made experimental circuit board, you need to have knowledge of the internal working principle of the microcontroller chip, knowledge of packaging, and a clear understanding of the function of each pin. You also need knowledge of digital tubes, buttons, resistors, three-terminal voltage regulators, diodes, heat sinks, electrolytic capacitors, ordinary capacitors, resistors, toggle switches and other components. For beginners, you can make a simple experimental board with only 3 digital tubes, 8 buttons, and 8 light-emitting diodes. Although such an experimental board is simple, it is enough to help beginners get started with microcontrollers. The same as making a self-made experimental circuit board, first draw the circuit diagram, then buy components, and then draw the circuit board. Since the MSP430 series chips are flat packages, it is difficult to solder them. This seems to be a challenge, but it is actually very simple. The method is as follows: First, apply rosin water on the pad. When the rosin water is not dry, place the chip on the pad, pay attention to the position of the first pin of the chip, and align the pin with the pad. Touch the pin with a clean electric soldering iron (without any solder). As long as the pin is hot, the solder on the pad will automatically solder the pin. Be sure to pay attention to the soldering iron. There should be no solder on the electric soldering iron. It is best to equip a magnifying glass when soldering. When soldering a circuit board, the parameters of each component must be checked, and components that can be measured with a multimeter must be measured.
(4) Obtain IAR software from the Internet
Go to the website of Lierda or TI to download the IAR software and install it on your computer.
(5) Debugging FET and experiment board
Connect one end of the FET to the parallel port of the PC, and the other end to the JTAG interface of the experimental board. After powering on, check whether the FET chip and the microcontroller chip on the experimental board are hot (use hand simulation), and whether the PC is working properly. Then run the IAR software, find an example of C language or assembly language, and download it to the microcontroller after successful compilation. If it can be downloaded, it means everything is successful. Otherwise, it needs to be studied carefully. Generally speaking, as long as the circuit on the circuit board is correct and the component parameters are accurate, there will be no failure.
(6) Learn MCU step by step
Learning to use a microcontroller means understanding the microcontroller hardware structure, learning how to initialize various functions in assembly or C language, and writing programs to implement various functions.
Step 1: Use of Digital I/O
By using buttons to input signals and LEDs to display output levels, you can learn the digital I/O functions of pins. After pressing a button, a LED 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.
Step 2: Use the timer
Once you learn how to use the timer, you can use a single-chip microcomputer to implement a sequential circuit. The function of a 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 lowest cost to implement.
The use of timers is very important. Logic plus time control is the basis of the use of microcontrollers.
Step 3: Interrupt
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 single-chip microcomputer respond to fast actions during the normal operation of the program, the interrupt function of the single-chip microcomputer must be used. This function is that after the fast action occurs, the single-chip microcomputer interrupts the normal running program and processes the fast action. After the processing is completed, it returns to execute the normal program. The difficulty in using the interrupt function is that it is necessary to accurately know when to not allow interrupts to occur (shield interrupts) and when to allow interrupts to occur (enable interrupts), 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 about interrupts, you can compile programs with more complex structures. Such a program can do one thing and monitor one thing. Once the monitored thing happens, it will interrupt the thing it is doing and handle the monitored thing. Of course, it can also monitor multiple things. Figuratively speaking, the interrupt function enables the microcontroller to 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. If you have mastered three of the palms, you can barely protect yourself.
Step 4: RS232 communication with PC
All 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 a PC. The logic levels between them are different, so a MAX3232 chip is needed for level conversion.
The use of 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 and other knowledge. Imagine that the data on the microcontroller experiment board is displayed on the PC monitor, and the keyboard signal of the PC 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, which can be used to operate analog quantities, display and detect voltage, current and other signals. When learning, pay attention to concepts such as analog ground and digital ground, reference voltage, sampling time, conversion rate, and conversion error.
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, which is very important in expanding the functions 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 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 ten moves of the Eighteen Dragon Subduing Palms and being able to 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 interface, TCP/IP interface, and various industrial buses, because this is the current development direction of product development.
So far, it is equivalent to learning 15 moves of the 18 Dragon Subduing Palms, but it is not enough to be invincible. Even so, it is still a master of single-chip microcomputers. By the way, the technical support of MSP430 single-chip microcomputers is very good. Responsible engineers will step forward at the critical moment to save you from danger.
6. Achieve the ideal state
It is difficult to reach the ideal state. In the era of knowledge explosion, even if you study every day, it is difficult to keep up with the development of science and technology, not to mention that you have to find a job, get a promotion, write papers, get scientific research funds, political studies, buy a house, buy a car, firewood, rice, oil, salt, sauce, vinegar, tea, etc. every day. So, do you still need to study? The answer is yes. People live for their interests. Only if you like microcontrollers can you learn microcontrollers, not for any purpose, just for the fun of learning. Of course, if your interest can also make money, it will kill two birds with one stone.
Learning to use a single-chip microcomputer is actually learning to use a tool. At best, you are a craftsman who can mend pots and bowls. If you want to make further progress, you need to work hard in signal recognition, control theory, digital signal processing theory, communication theory, etc. Only in this way can you develop high-level, high-value-added, intellectual property products and reach the highest level of being proficient in using the Eighteen Dragon Palms and being invincible.
The single-chip microcomputer is the basis for the development of advanced hardware products such as DSP and embedded operating system. If you want to develop further, you must learn the development of single-chip microcomputer.
If you learn the development of CPLD and FPGA as well as hardware description language on the basis of learning single-chip microcomputers, you can get a share of the pie in the development of high-speed products.
|