This book takes MCS-51 single-chip microcomputer as the main body, starting from practical application, and combining a large number of examples to gradually explain the C language programming method of 51 single-chip microcomputer, as well as the hardware structure and functional application of 51 single-chip microcomputer. The whole book is divided into basic part, application part and comprehensive improvement part. All examples are simulated by simulation software Proteus and experimental board experiments, so that readers can truly \"learn theory and practice at the same time\" and gradually master the hardware structure and development method of single-chip microcomputer in practice. Contents Basics Chapter 1 Overview of MCU and Introduction to Experimental Equipment 2 1.1 Overview of MCU 2 1.1.1 Definition, Classification and Internal Composition of MCU 2 1.1.2 Structure of MCU Application System and Its Working Process 5 1.1.3 Application of MCU 6 1.2 Basic Knowledge of MCU 7 1.2.1 Conversion between Number Systems 7 1.2.2 Number Representation Methods in MCU and Correspondence between Common Number Systems 10 1.2.3 Representation of Logical Data 10 1.2.4 Basic Terms Commonly Used in MCU 12 1.3 Effective Methods and Ways to Get Started with MCU 12 1.4 Basic Conditions for Learning MCU 13 1.4.1 Software Conditions 13 1.4.2 Hardware Conditions 15 Exercises 16 Chapter 2 MCU Development Software and Development Process 17 2.1 Use of Simulation Software Proteus 17 2.1.1 Main Functions and Features of Proteus 17 2.1.2 Example 1: Functional experience - Proteus simulation of microcontroller playing the theme song of \"Desire\" 17 2.1.3 Introduction to the interface and operation of Proteus software 19 2.1.4 Example 2: Quick introduction to Proteus simulation design 21 2.2 Use of Keil C51 31 2.2.1 Minimum system of microcontroller 31 2.2.2 Example 3: Use Keil C51 to write a program to light up a light-emitting diode 31 2.3 Use of program burner and burning software 38 Exercises and experiments 38 Chapter 3 Gradually understand the basic structure of microcontrollers 40 3.1 Example 4: Use microcontroller to control a light to flash 40 3.1.1 Implementation method 40 3.1.2 Program design 40 3.1.3 Simulation with Proteus software 41 3.1.4 Delay program analysis 43 3.2 Example 5: Send the status of P1 port to P0, P2 and P3 ports 44 3.2.1 Implementation method 44 3.2.2 Program design 45 3.2.3 Simulation with Proteus software 45 3.2.4 Experiment with an experimental board 46 3.2.5 Introduction to I/O port functions 46 3.2.6 Structural analysis of I/O ports 46 3.3 Example 6: Using P3 port to light up an 8-bit LED 49 3.3.1 Implementation method 49 3.3.2 Program design 50 3.3.3 Simulation with Proteus software 51 3.3.4 Experiment with an experimental board 51 3.4 Example 7: Light up an 8-bit LED by operating the P3 port address 51 3.4.1 Implementation method 51 3.4.2 Program design 52 3.4.3 Simulation with Proteus software 53 3.4.4 Experiment with an experimental board 53 3.5 The basic structure of the MCS-51 microcontroller memory 53 3.5.1 3.5.2 Program Memory 53 3.6 Reset Circuit of MCU 55 Exercises and Experiments 55 Chapter 4 MCU C Language Development Basics 56 4.1 Structural Features of C Language Source Program 56 4.2 Identifiers and Keywords 57 4.3 Data Types and Operators in C Language 59 4.3.1 Data Types 59 4.3.2 Operators 62 4.3.3 Example 8: Using Different Data Types to Control the Flashing of LEDs 65 4.3.4 Example 9: Using P0 and P1 to Display the Results of Addition and Subtraction 68 4.3.5 Example 10: Using P0 and P1 to Display the Results of Multiplication 70 4.3.6 Example 11: Using P1 and P0 to Display the Results of Division 71 4.3.7 Example 12: Using Increment Operation to Control the Flashing Pattern of 8-Bit LED at P0 73 4.3.8 Example 13: Use P0 port to display the result of logical \"AND\" operation 74 4.3.9 Example 14: Use P0 port to display the result of conditional operation 74 4.3.10 Example 15: Use P0 port to display the result of bitwise \"XOR\" operation 75 4.3.11 Example 16: Use P0 to display the result of left shift operation 76 4.3.12 Example 17: \"Universal logic circuit\" experiment 77 4.3.13 Example 18: Use right shift operation pipeline to light up the 8-bit LED of port P1 78 4.4 C language statements 79 4.4.1 Overview 79 4.4.2 Control statements 80 4.4.3 Example 19: Use if statement to control the lighting state of 8-bit LED of port P0 84 4.4.4 Example 20: Use switch statement to control the lighting state of 8-bit LED of port P0 86 4.4.5 Example 21: Use for statement to design whistle alarm program 88 4.4.6 Example 22: Use while statement to control the flashing pattern of 8-bit LED at port 0 92 4.4.7 Example 23: Use do-while statement to control the 8-bit LED at port 0 to light up 93 4.5 Arrays in C language 95 4.5.1 Definition and reference of array 95 4.5.2 Example 24: Use character array to control the 8-bit LED at port 0 to light up 97 4.5.3 Example 25: Use port 0 to display string constant 98 4.6 Pointers in C language 99 4.6.1 Definition and reference of pointer 100 4.6.2 Example 26: Use port 0 to display pointer operation result 102 4.6.3 Example 27: Use pointer array to control the 8-bit LED at port 0 to light up 103 4.6.4 Example 28: Use array pointer to control the 8-bit LED at port 0 to light up 104 4.7 Functions in C language 106 4.7.1 Function definition and call 106 4.7.2 Example 29: Use P0 and P1 ports to display the return value of an integer function 109 4.7.3 Example 30: Use a parameterized function to control the speed of an 8-bit LED pipeline at port P0 111 4.7.4 Example 31: Use an array as a function parameter to control the lighting of an 8-bit LED pipeline at port P0 112 4.7.5 Example 32: Use a pointer as a function parameter to control the lighting of an 8-bit LED pipeline at port P0 113 4.7.6 Example 33: Use a function pointer to control the lighting of an 8-bit LED pipeline at port P0 115 4.7.7 Example 34: Use a pointer array as a function parameter to display multiple strings 116 4.7.8 Example 35: Example of using the character function ctype.h 118 4.7.9 Example 36: Example of using the internal function intrinsics.h 119 4.7.10 4.8.1 Introduction to common preprocessing commands 123 4.8.2 Example 39: Macro definition application example 126 4.8.3 Example 40: File inclusion application example 127 4.8.4 Example 41: Conditional compilation application example 128 Exercises and experiments 129 Chapter 5 MCU Timer/Counter 131 5.1 Basic concepts of timer/counter 131 5.2 Structure and working principle of timer/counter 132 5.2.1 Structure of timer/counter 133 5.2.2 Working principle of timer/counter 133 5.3 Control of timer/counter 134 5.3.1 Mode control register (TMOD) of timer/counter 134 5.3.2 Timer/Counter Control Register (TCON) 134 5.3.3 Four working modes of timer/counter 135 5.3.4 Calculation of initial value of timing/counting in timer/counter 138 5.4 Examples of timer/counter applications 138 5.4.1 Example 42: Using timer T0 to control the ticking light 138 5.4.2 Example 43: Using timer T1 query mode to control the alarm 140 Exercises and experiments 142 Chapter 6 MCU interrupt system 143 6.1 Basic concepts of interrupt system 143 6.2 Structure and control of interrupt system 144 6.2.1 The structure of the interrupt system 144 6.2.2 Control of the interrupt system 145 6.3 Examples of the application of the interrupt system 148 6.3.1 Example 44: Using the interrupt mode of timer T0 to control the marquee 148 6.3.2 Example 45: Using the fraction 1 of timer T1 to control the alarm 149 6.3.3 Example 46: Using the interrupt mode of timer T0 to control the PWM wave 151 6.3.4 Example 47: Using the music player of timer T0 154 6.3.5 Example 48: Using the gate control bit of timer T0 to measure the width of an external positive pulse 159 6.3.6 Example 49: Using an external interrupt to measure the cumulative number of negative transition signals 161 Exercises and experiments 163 Chapter 7 Serial Communication Technology 164 7.1 Basic concepts of serial communication 164 7.2 The structure of the serial communication port 166 7.3 Control of the serial communication port 166 7.3.1 Serial port control register SCON 167 7.3.2 Power control register PCON 167 7.3.3 Four working modes and baud rate settings 168 7.4 Serial communication port application examples 171 7.4.1 Example 50: Simplex communication based on mode 1 171 7.4.2 Example 51: Simplex communication based on mode 3 173 7.4.3 Example 52: MCU sends data to computer 176 7.4.4 Example 53: Computer controls MCU LED display 178 Exercises and experiments 180 Application Chapter 8 Interface Technology 182 8.1 LED digital tube interface technology 182 8.1.1 Principle and interface circuit of LED digital tube 182 8.1.2 Example 54: Use LED digital tube to display the number \"5\" 184 8.1.3 Example 55: Use LED digital tube to display the numbers 0 to 9 185 8.1.4 Example 56: Use digital tubes to display the number \"1234\" by slow dynamic scanning 186 8.1.5 Example 57: Fast dynamic scanning to display the number \"1234\" 188 8.1.6 Example 58: Implementation of dot matrix LED dynamic display 189 8.2 Keyboard interface technology 191 8.2.1 Working principle of independent keyboard 192 8.2.2 Example 59: Independent keyboard input experiment without software debounce 193 8.2.3 Example 60: Independent keyboard input experiment with software debounce 194 8.2.4 Example 61: CPU-controlled keyboard scanning experiment 195 8.2.5 Example 62: Timer interrupt-controlled keyboard scanning experiment 200 8.2.6 Example 63: \"One key with multiple functions\" experiment 201 8.2.7 Example 64: Independent keyboard controlling stepping motor experiment 204 8.2.8 Working principle of matrix keyboard 209 8.2.9 Example 65: Digital tube display of key values on matrix keyboard 210 8.2.10 Example 66: Design of simple electronic piano 214 8.3 Character LCD interface technology 220 8.3.1 Introduction to 1602 character LCD 220 8.3.2 Example 67: Display the character \"A\" with LCD 225 8.3.3 Example 68: Design of LCD clock 230 Exercises and experiments 231 Chapter 9 Application of new serial interface chips 232 9.1 I2C bus devices and their application examples 232 9.1.1 I2C bus interface 232 9.1.2 Example 69: Write the number of key presses into AT24C02, then read it out and send it to LCD for display 235 9.1.3 Example 70: Read/write operation of two AT24C02s connected to the I2C bus 236 9.1.4 Example 71: Write the music score of \"Good People Live a Peaceful Life\" into AT24C02 and play it 238 9.2 Single Bus Devices and Their Application Examples 239 9.2.1 Introduction to Single Bus 239 9.2.2 Example 72: DS18B20 Temperature Detection and LCD Display 244 9.3 SPI Bus Interface Chip and Its Application Examples 245 9.3.1 Introduction to SPI Serial Bus 245 9.3.2 Example 73: Write the data \"0xaa\" into X5045 and then read it out and send it to P1 port for display 248 9.3.3 Example 74: Write the running light control code into X5045 and read it out and send it to P1 port for display 250 9.3.4 Example 75: Read/write operations on two X5045s connected to the SPI bus 251 Exercises and Experiments 252 Chapter 10 Application Examples of Common Function Devices 254 10.1 Analog/Digital (A/D) Conversion Devices 254 10.1.1 Basics of A/D Conversion 254 10.1.2 Example 76: 5V DC Digital Voltmeter Based on ADC0832 256 10.2 Digital/Analog (D/A) Conversion Devices 258 10.2.1 Basics of D/A Conversion 258 10.2.2 Example 77: Using DAC0832 to Generate Sawtooth Wave Voltage 260 10.3 Infrared Remote Control Signal Receiver Device 261 10.3.1 Basics of Infrared Signal Reception 261 10.3.2 Example 78: Using P1 Port to Display the Key Value of an Infrared Remote Control 263 10.3.3 Example 79: Using an Infrared Remote Control to Control a Relay 265 10.4 Time Clock Chip 266 10.4.1 Introduction to Common Time Clock Chips 267 10.4.2 Example 80: Calendar Clock Based on DS1302 269 Exercises and Experiments 271 Comprehensive Improvement Chapter 11 Comprehensive Application Examples 274 11.1 Example 81: LCD Display of Chinese Characters 274 11.1.1 Introduction to Graphic Dot Matrix Display 274 11.1.2 Simulation Schematic Design 278 11.1.3 Program Design and Simulation 279 11.2 Example 82: Use of 12-bit A/D Converter TLC2543 284 11.2.1 Introduction to TLC2543 284 11.2.2 Simulation Schematic Design 286 11.2.3 Program Design and Simulation 288 11.3 Example 83: Use of Two-wire Serial Interface Sensor SHT11 293 11.3.1 Introduction to Intelligent Temperature and Humidity Sensor SHT11 293 11.3.2 Simulation Schematic Design 295 11.3.3 Program Design and Simulation 295 11.4 Example 84: Use of Voltage Sensor 302 11.4.1 Introduction to FS4003 Sensor 302 11.4.2 Simulation Schematic Design 304 11.4.3 Program Design and Simulation 305 11.5 Example 85: Use of RS-232 Digital Sensor 310 11.5.1 Introduction to Serial Communication Protocol of FS4003 Sensor 310 11.5.2 Simulation Schematic Design 310 11.5.3 Program Design and Simulation 311 11.6 Example 86: Application Example of Current Sensor 318 11.6.1 Basics of Current Sensor Use 318 11.6.2 Simulation Schematic Design 319 11.6.3 Program Design and Simulation 321 11.7 Example 87: Design of Oxygen Concentration Detector Based on Chemical Sensor 323 11.7.1 Introduction to R-17MED Chemical Sensor 323 11.7.2 Hardware Simulation Circuit Design 324 11.7.3 Programming and Simulation 325 11.8 Example 88: MCU sends a read command to an RS-485 sensor 327 11.8.1 Introduction to RS-485 communication 328 11.8.2 Simulation schematic design of TTL/RS-485 conversion 329 11.8.3 Programming and Simulation 331 11.9 Example 89: MCU receives data from RS-485 sensor 333 11.9.1 Format of data returned by RS-485 sensor 333 11.9.2 Simulation schematic design 334 11.9.3 Programming and Simulation 334 11.10 Example 90: Using VB to implement serial communication between MCU and computer 337 11.10.1 Development background 337 11.10.2 Development requirements 337 11.10.3 Introduction to Visual Basic 6.0 337 11.10.4 Adding MSComm Controls and Basic Property Settings 338 11.10.5 The Process of Implementing Serial Communication in Visual Basic 6.0 339 11.11 Example 91: Serial Communication Programming in LabVIEW Environment 345 11.11.1 Development Environment 345 11.11.2 Upper and Lower Computer Program Design 346 11.11.3 Program Results 353 11.12 Example 92: Design of Hand Grip Strength Evaluator 353 11.12.1 System Working Principle 353 11.12.2 Simulation Schematic Design 354 11.12.3 Program Design and Simulation 355 11.13 Example 93: Heart Rate Measurement System Design 359 11.13.1 System Working Principle 359 11.13.2 Simulation Schematic Design 360 11.13.3 Program Design and Simulation 361 11.14 Example 94: Design of Fire Protection System Based on Platinum Thermal Resistance 367 11.14.1 System Working Principle 367 11.14.2 Simulation Schematic Design 368 11.14.3 Program Design and Simulation 370 11.15 11.18 Example 98: Design of DC motor speed control system based on PWM 389 11.18.1 System working principle 389 11.18.2 Simulation schematic design 390 11.18.3 Program design and simulation 391 11.19 Example 99: Design of automatic cold end compensation for K-type thermocouple 313 11.20.1 System working principle 313 11.20.2 Simulation schematic design 314 11.20.3 Program design and simulation 315 11.21 Example 90: Design of motor speed meter 316 11.22.1 System working principle 316 11.22.2 Simulation schematic design 317 11.22.3 Program design and simulation 318 11.23 Example 91: Design of DC motor speed control system based on PWM 319 11.23.1 System working principle 319 11.18.2 Simulation Schematic Design 389 11.18.3 Program Design and Simulation 390 11.19 Example 99: Thermal Printer Driver Design 392 11.19.1 System Working Principle 392 11.19.2 Simulation Schematic Design 393 11.19.3 Program Design and Simulation 393 11.20 Example 100: Aircraft Engine Thermocouple Signal Simulation Voltage Source Design 395 11.20.1 System Working Principle 395 11.20.2 Circuit Schematic Design 396 11.20.3 Program Design 396 References 399
You Might Like
Recommended ContentMore
Open source project More
Popular Components
Searched by Users
Just Take a LookMore
Trending Downloads
Trending ArticlesMore