A beginner's guide to electronics: the first step from loser to rich and handsome

Publisher:创意火舞Latest update time:2014-11-03 Source: 21icKeywords:MCU  LED  MSP430  ROM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The 51 single-chip microcomputer is the first single-chip microcomputer that every electronic engineer comes into contact with (at least all the ones I know are, and it is not ruled out that there are experts). Many experts believe that the 51 will soon complete its historical mission, but I personally think that its simple operation is the best choice for new students to get started. It is cheap, the price of a bowl of knife-cut noodles, and there are a lot of information about it, the most representative of which is the tutorial "Teaching You to Learn Single-chip Microcomputers in Ten Days" by Teacher Guo Tianxiang. Students should realize that the 51 single-chip microcomputer is the first step into the world of electronics.

If you are still keen on using 51 MCU to make cars, drive LEDs, and make power supplies, then you are out of date. If you insist on using 51 until the resources are exhausted and then transform, you still have a long way to go. You must decisively give up using 51 MCU and take the first step towards being tall, rich and handsome. I personally think that MSP430 MCU is the second step to learn MCU. Now I will tell you why.

1. MSP430F149 VS STC89C52

Look at the table below, the difference between MSP430F149 and STC89C52 is simply the difference between the evil American imperialism and the Mexican class brothers. Look at the ROM and RAM, one is a SAIC-GM-Wuling minivan, and the other is Optimus Prime. You should know that the larger the ROM, the larger the program that can be loaded, and the larger the RAM, the more data can be temporarily stored; look at the peripherals integrated on the chip, one is American equipment armed to the teeth, and the other is Xiaomi plus rifle, it is Xiaomi + rifle, not Xiaomi plus brand rifle; look at the power consumption mode and power requirements, a real man, no explanation.

1.gif

Some people may complain about the price. Just look at the on-chip peripherals. If you use the STC89C52+ASIC combination, the price will probably be far more than 10 yuan. Some people may complain about the package. If I remember correctly, MSP430 also has DIP package.

2.jpg
3.jpg

The computing speed of msp430 is unmatched by 51 MCU. In addition, the hardware multiplier is integrated inside the MSP430, which greatly improves the computing speed. Msp430 is a low-power MCU, especially suitable for battery-powered devices. If you are going to develop low power consumption in the future, then msp430 and PIC are good choices. [page]

The 51 MCU is the easiest to learn, but its performance in all aspects is also very low. In actual applications, few people use 51 to develop products. If you want to develop higher-end MCUs, msp430 is a better choice. On the one hand, it allows you to involve low-power applications, and on the other hand, its functions and performance are close to ARM processors. Learning MSP430 well is a foundation for learning ARM in the future.

How to quickly get started with MSP430 microcontroller

The fastest and most effective way to learn MCU is to use a development board. When you buy a development board, the seller will send you relevant tutorials. I think you can get started quickly with a little practice.

I also went through this when I was learning MSP430. Now I share my experience with you and hope it will be helpful to you. How long does it take to jump from 51 microcontroller to msp430 microcontroller? I said it only takes one day. Even if you are not good at learning, you can get started in a week at most. Now I want to teach you a few tricks to help you quickly get started with MSP430 microcontroller.

The first move: Star Absorbing Technique

The Star Absorbing Technique is a martial art that can absorb the inner strength of others and use it for oneself. This martial art once dominated the martial arts world and was feared by the world. The types of microcontrollers cannot be counted with fingers and toes, and it is a bit difficult to count them with hair. If you want to learn the internal structure of each microcontroller, and then program and develop applications, it is something that only Crayon Shin-chan can do. So Gang Leader Ren developed the Star Absorbing Technique, which uses the experience of others as a means, and combined with his own practice, he can soon have a new martial art.

How do we apply the Star Absorbing Technique when learning MSP430 microcontroller?

Open your IE browser, go to Taobao homepage, search for MSP430 microcontroller development board, and you will see a lot of products, and most of them come with video tutorials and data sheets. These video tutorials can help you avoid many detours. First, you need to learn how to install IAR software, then how to set up the software and create a new project. This is the most basic skill. Follow it step by step, and you will find that using msp430 and 51 microcontrollers is almost the same, with its commonalities and differences.

To learn microcontrollers, you should try to reduce the time spent on addressing information and reading a lot of data manuals, and spend time on analyzing the program and memorizing the register settings. When you buy your development board, your seller has already sorted out the information for you, and given you tutorials and examples, so you just need to absorb them into your brain and turn them into your knowledge.

Star-sucking method - learn to use development boards and video tutorials to reduce detours as much as possible and spend more time on actual operations and development.

The second trick: transplanting flowers and trees

Transplanting flowers and trees is a martial art similar to the Star-Absorbing Art, but the difference is that it utilizes one's previously used martial arts and transfers them to new martial arts, instantly unleashing tremendous power.

As for the 51 MCU and MSP430 MCU, there are similarities and differences in the programming of the two MCUs. We can use the 51 MCU program and only need to modify a few letters, so that its program can be used as the MSP430 program. This method is called program transplantation. C language has strong portability. No matter what MCU it is, as long as it is programmed in C language, most of them can be transplanted to each other, but transplanting programs requires modularization of programs, otherwise transplantation will become more difficult.

51 Program modular transplantation msp430 example

Use 51 MCU and MSP430 to control two lights, one red and one green, and the two lights turn on and off alternately with a time interval of 0.5 seconds. Requirements: The program should be modular and can be easily transplanted

51 single chip microcomputer hardware circuit:

The anode of the red light is connected to the pull-up resistor, and the cathode is connected to the P1.0 pin of the microcontroller.

The anode of the green light is connected to the pull-up resistor, and the cathode is connected to the P1.1 pin of the microcontroller.

Msp430 microcontroller hardware circuit:

The anode of the red light is connected to the pull-up resistor, and the cathode is connected to the P2.0 pin of the microcontroller.

The anode of the green light is connected to the pull-up resistor, and the cathode is connected to the P2.1 pin of the microcontroller.

The red fonts are the differences in programming between the 51 MCU and the MSP430 MCU. The 51 MCU needs to declare the bit when using the IO port, for example, sbit P10 = P1^0; while the MSP430 MCU does not need to define the bit, but needs to set the IO direction, for example, P2DIR|= BIT0; to configure the P20 IO pin to output mode.

The MSP430 watchdog is turned on by default, so it should be turned off at the beginning of the program.

The blue font is the delay function. The delay function of each MCU is different, which depends on the time used by a single machine cycle of the MCU. Therefore, the delay function cannot be transplanted when transplanting the program. However, in order to facilitate the transplantation of other programs, the function names of the delay functions of two different MCUs need to be the same.

The delay function of the 51 single-chip microcomputer generally uses program delay, which is an inaccurate delay method.

In this article, the delay method of MSP430 uses the delay function in the MSP430 function library, __delay_cycles((long)(CPU_F*(double)x/1000.0)) to make precise delays. The user only needs to set the crystal oscillator frequency.

The bold black font is our application function. This application function is a portable module. The program of this module can be used directly without modification no matter where it is transplanted. This is the idea of ​​modular program transplantation. This program can be applied not only to MSP430, but also to other microcontrollers, such as STM32.

Modular programs have the following characteristics:

1. P10 = 1; or P1OUT &=BIT0; cannot appear in the application function. These IO port configuration codes must be replaced by other terms. For example, #define Red_ON P10 = 0, we replace the P10 port on state with Red_ON.

2. Modular programs are usually described in English, for example, Red_ON means the red light is on. The meaning is very clear. One of the advantages of all modular programs is that they are easy to read and understand.

3. General IO configuration is usually defined by #define and stored in the header file or at the beginning of the program.

4.gif
Keywords:MCU  LED  MSP430  ROM Reference address:A beginner's guide to electronics: the first step from loser to rich and handsome

Previous article:Application of MC9S08QE4 microcontroller in active RFID
Next article:How to design wearable electronic products with MCU

Recommended ReadingLatest update time:2024-11-16 14:40

Summary and analysis of common problems in AVR microcontroller C programming
I have been using AVR microcontrollers to do projects these days. This time, I am learning in depth while doing it, and I try to use the knowledge that I have ignored before, such as pointers, file inclusion, conditional compilation, variable scope, etc. I have learned a lot and realized again that there is no useless
[Microcontroller]
Summary and analysis of common problems in AVR microcontroller C programming
LED Street Light Brightness Control Design
At present, in the field of high-brightness LED street lamp drivers, the two main technical solutions that are widely used at home and abroad are "using dedicated power supply chips" and "using switching power supplies with discrete components". In order to meet the needs of "intelligence", a single-chip microcomput
[Power Management]
LED Street Light Brightness Control Design
A multifunctional calculator based on 51 single-chip microcomputer, supporting binary and octet decimal negative number calculation
hardware design working principle Use the matrix keyboard for key input, obtain the user's input by scanning the matrix keyboard, and display it in real time on the 1602 LCD. Each time the input is obtained, it is processed and calculated according to the corresponding method designed by the software. After the inpu
[Microcontroller]
A multifunctional calculator based on 51 single-chip microcomputer, supporting binary and octet decimal negative number calculation
Lesson 1 Microcontroller Overview
1. What is a single chip microcomputer?  Before explaining what a single-chip microcomputer is, let's first look at the microcomputer system that everyone has seen in our daily lives. As shown in Figure 1, a complete computer system mainly includes four major components: display, host, keyboard and mouse. Figure
[Microcontroller]
Lesson 1 Microcontroller Overview
Research on packaging and performance of color temperature tunable LED
1 Introduction Since the invention of blue LED, people have begun to develop various high-power white LED packaging technologies, hoping that white LED can replace traditional lighting sources. At present, there are two main white LED production technologies on the market. The first is to use phosphors
[Power Management]
Research on packaging and performance of color temperature tunable LED
51 single chip microcomputer timer water light digital tube timing
      This is a comprehensive timer of the previous process. T0 controls the running light, T1 controls the time, and it is displayed through the digital tube.       code show as below:       //Led running light, 5-digit digital tube 100000 seconds timing #include                            //header file #include 
[Microcontroller]
Design of electronic alarm clock based on AT89S52 single chip microcomputer
1. System Function Requirements The task requirements of the computer clock are: once the system is running, it starts timing from 00:00:00, and displays the current values ​​of hours, minutes, and seconds on the digital tube. 2. System Overall Plan 1. Clarify the tasks Basic working principle: ever
[Microcontroller]
Design of electronic alarm clock based on AT89S52 single chip microcomputer
51 MCU Tutorial from Scratch—— 22 MCU Serial Port Introduction
The serial port is a tool for the microcontroller to exchange information with the outside world. There are two communication modes for 8051 microcontroller: Parallel communication: data bits are sent or received at the same time. Serial communication: data bits are sent or received sequentially. See t
[Microcontroller]
51 MCU Tutorial from Scratch—— 22 MCU Serial Port Introduction
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号