This is a very useful statement, but I don't use it often. I usually use standard keywords when defining variable data types so that others can It is very convenient to study your program. If you are a DELPHI programming enthusiast or programmer, you may be accustomed to the definition of variables in DELPHI. For example, the int type is often defined with the keyword Integer. If you want to use this keyword again when using C51, you can write it like this: is equal to int, so a and b are also defined as int. typedef cannot be used to define variables directly, it just gives a name to an existing data type. The replacement does not create a new data type. The following two sentences are examples of errors: We will explain this in detail later when we explain the structure type. The syntax of typedef is The unary operator requires one operand, the binary operator requires two operands, and the trinocular operator requires three operands. An expression is a formula with a specific meaning, consisting of operations and their objects. C is an expression language. becomes an expression statement. Assignment operator: It is also clear that it is to assign data to variables. For example, x=10; From this we can see that the formula that uses the assignment operator to connect a variable with an expression is an assignment expression. Adding ";" after the expression forms an assignment statement. The format of the assignment statement using "=" is as follows: variables. And the expression on the right can be an assignment expression. In statements such as if (a=x), "=" is mistakenly used as "==". The "==" symbol is used to perform equality operations. Arithmetic, increment and decrement operators Among the following, only the positive and negative operators are unary operators, and the others are binary operators: is 0.5, and when two integers are divided, the value obtained is an integer, such as 7/3, which is 2. Like other languages, C operators have precedence and associativity. You can also use parentheses "()" to change the priority. These are almost the same as the mathematics we learned when we were young, so I don't need to explain them in detail. :( Let's add a serial interface to our experimental board. With the help of computer software, I can directly see the output results of the microcontroller. In the future, I will use some simple practical This section explains the simple application and programming of the microcontroller and PC serial communication. If you are using a finished experimental board or simulator, you can skip this section.
The conversion chip and basic pin wiring functions are enough. I usually use two low-power transistors and a small amount of circuitry to replace the MAX232, which can save The effect is also good (if you are interested, you can check the relevant information on the website http://www.cdle.net ). The following figure shows the basic connection of MAX232 line graph. |
|
Based on the circuits in the last two lessons, add MAX232 according to Figure 7-3. Soldering with a soldering iron in this hot day is really hot. Yes: The P serial port uses a DB9 female connector, so you can use the purchased PC serial port extension cable to connect to the computer, or you can directly connect it to the computer com port superior. |
Figure 7-2 DB9 connector |
Figure 7-3 Experimental circuit with MAX232 |
After that, we will use the "Hello World!" program from the first lesson to say hello to your computer! Burn the program to the chip. Connect the serial port. Hey, now you need to open your serial port debugging software. If you don't have it, quickly download one online. You will use Windows Super Mid-range is also OK, but I never use it. I use comdebug from http://emouze.com , it is a good software, I like it because of its function It works well and also has a "line status" function, which is very useful when I make gadgets. The serial port number and baud rate are adjusted, the serial port is opened, and the microcontroller is powered on. You can see "Hello World!" appearing continuously in the receiving area. Be sure to open the serial port of the software first, and then power on the microcontroller, otherwise the character The characters are not aligned and garbled characters are seen. |
Figure 7-4 Debugging results |
Previous article:Clock chip DS1302 program example
Next article:Microcontroller C Language Tutorial (VI)
Recommended ReadingLatest update time:2024-11-16 07:55
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Sony employee stole $154 million in public funds and exchanged them for Bitcoin: when it was recovered, it appreciated to over $180 million
- 8-bit, 16-bit and 32-bit MCUs, are more bits better?
- [Evaluation of EVAL-M3-TS6-665PN development board] 3. Power-on test
- Get a gift for grabbing the post: Watch the live broadcast and gain an in-depth understanding of the principle, operation, and waterproof structure design of ST's latest MEMS barometer
- CPAFC Carrier Synchronization
- When should I use a PWM controller?
- SensorTile.box unpacking issues
- Are the EX0 bit in the IE register and the IE0 bit in the TCON register in the 51 microcontroller duplicated?
- Detailed diagram of microwave oven capacitor connection
- The execution time limit has been exceeded. Please check whether there is an infinite loop or the program algorithm is inefficient.