This book uses 89C51/S51 as a typical machine to explain the principles, interfaces and application technologies of single-chip microcomputers in an easy-to-understand way. The main contents include: basic knowledge of microcomputers, hardware structure of 89C51/S51 single-chip microcomputers, instruction system, assembly language programming knowledge, interrupt system, timer and application, 89C51/S51 serial port communication and serial communication technology, 89C51/S51 single-chip microcomputer small system and off-chip expansion, application system configuration and interface technology, system application examples and C51 programming, as well as wireless single-chip microcomputers and their point-to-multipoint wireless communication, RFID technology and the application of the Internet of Things and C51 programming, etc. Chapter 1 Basic knowledge of microcomputers……………………………………………… 1 1.1 The concepts of microprocessor, microcomputer and single-chip microcomputer…………… 1 1.1.1 Composition of microprocessor (machine)……………………………… 1 1.1.2 Memory and input/output interface…………………………… 5 1.2 Working process of microcomputer……………………………………… 5 1.2.1 Order of executing an instruction…………………………………… 6 1.2.2 Process of executing an instruction……………………………… 7 1.2.3 Process of executing a program………………………………… 8 1.3 Common number systems and encodings……………………………… 11 1.3.1 Number systems and conversion between number systems………………………… 12 1.3.2 Common codes used in computers………………………………………… 18 1.4 Data representation in computers……………………………………… 19 1.4.1 Signed numbers………………………………………………………… 19 1.4.2 Unsigned numbers………………………………………………… 20 1.5 89C51/S51 microcontrollers…………………………………………… 21 1.5.1 AT89C51/S51 microcontroller series………………………………… 22 1.5.2 STC89 microcontroller series……………………………………… 23 1.5.3 SST89 microcontroller series……………………………………… 23 1.6 Questions and exercises……………………………………………… 24 Chapter 2 Hardware Structure and Principle of 89C51/S51 MCU………………………………………… 25 2.1 Internal Structure and Features of 89C51/S51 MCU…………………………………… 25 2.1.1 Basic Components of 89C51/S51 MCU………………………………………… 25 2.1.2 Internal Structure of 89C51/S51 MCU Chip……………………………………… 26 2.2 Pins and Functions of 89C51/S51 MCU……………………………… 29 2.3 Memory Configuration of 89C51/S51 MCU…………………………………… 34 2.3.1 Program Memory Address Space………………………………………… 35 2.3.2 Data Memory Address Space………………………………………… 37 2.4 89C51/S51CPU Timing…………………………………………………… 44 2.5 Reset Operation………………………………………………………… 46 2.5.1 The Main Function of Reset Operation……………………………… 46 2.5.2 Reset Circuit……………………………………………………… 48 2.6 Questions and Exercises…………………………………………… 49 Chapter 3 Instruction System……………………………………………… 50 3.1 Assembly Language…………………………………………………… 50 3.1.1 Instructions and Programming Language………………… 50 3.1.2 Instruction Format………………………………………………… 51 3.2 Addressing Mode……………………………………………………… 52 3.2.1 Seven addressing modes…………………………………………………… 53 3.2.2 Addressing space and symbol annotations………………………… 57 3.3 Instruction system of 89C51/S51 microcontroller………………………………… 58 3.3.1 Data transfer instructions…………………………………………………… 59 3.3.2 Arithmetic operation instructions………………………………… 63 3.3.3 Logical operation instructions………………………………………… 67 3.3.4 Control program transfer instructions…………………………………… 69 3.3.5 Bit operation (Boolean processing) instructions…………………… 77 3.4 Questions and exercises…………………………………………………… 80 Chapter 4 Assembly Language Programming Knowledge…………………………………… 85 4.1 Programming steps, methods and techniques…………………………… 85 4.1.1 Programming steps……………………………………………………… 85 4.1.2 Programming methods and techniques………………………………… 87 4.1.3 The basic structure of assembly language program………………… 88 4.2 Pseudo-instructions……………………………………………… 96 4.3 Thinking questions and exercises……………………………………… 99 Chapter 5 Interrupt system…………………………………………………… 100 5.1 Microcomputer input/output method………………………………… 100 5.1.1 Unconditional transfer method……………………………………… 100 5.1.2 Query Transfer Mode………………………………………… 100 5.1.3 Direct Memory Access (DMA) Mode…………………………… 101 5.2 The Concept of Interrupts…………………………………………………… 101 5.3 89C51/S51 Interrupt System Structure and Interrupt Control… 103 5.3.1 89C51/S51 Interrupt Sources……………………………………… 104 5.3.2 Interrupt Control………………………………………………… 104 5.4 Interrupt Response and Interrupt Processing Process… 109 5.4.1 Interrupt Response……………………………………………… 109 5.4.2 Interrupt Processing…………………………………………… 111 5.4.3 5.4.4 About the specific interrupt service routine……………………………… 112 5.5 Interrupt program example……………………………………………… 113 5.5.1 Main program………………………………………………………… 113 5.5.2 Interrupt service routine………………………………………… 114 5.6 Questions and Exercises ……………………………………………… 117 Chapter 6 Timers and Applications ………………………………………… 119 6.1 Overview of Timers ………………………………………………………… 119 6.1.1 What is counting and timing …………………………………… 119 6.1.2 Composition of a timer/counter ………………………… 120 6.2 Timer Control ………………………………………………………… 121 6.2.1 Working Mode Register TMOD …………………………… 121 6.2.2 Control Register TCON ………………………………………… 122 6.3 Four Modes of Timers and Applications ………… 123 6.3.1 Mode 1 and Applications ……………………………… 124 6.3.2 Mode 2 and its application…………………………………… 125 6.3.3 Mode 3 and its application…………………………………… 128 6.3.4 Comprehensive application examples………………………………………… 129 6.4 Questions and exercises……………………………………………… 136 Chapter 7 89C51/S51 serial port and serial communication technology… 138 7.1 Basic knowledge of serial communication…………………………… 138 7.1.1 Data communication………………………………………………… 138 7.1.2 Transmission mode of serial communication……………………… 139 7.1.3 Asynchronous communication and synchronous communication……… 140 7.1.4 7.2 Serial Port and Application ………………………………………… 144 7.2.1 89C51/S51 Serial Port ……………………………………………… 144 7.2.2 Application of 89C51/S51 Serial Port …………………………………… 156 7.3 89C51/S51 and 89C51/S51 Point-to-Point Asynchronous Communication …… 161 7.3.1 Communication Protocol …………………………………… 161 7.3.2 Baud Rate Setting ……………………………………………… 161 7.3.3 Communication Program Example ……………………………… 163 7.4 7.4.1 Interface circuit for communication between MCU and PC…………………………………… 167 7.4.2 PC communication software……………………………………………… 168 7.4.3 89C51 communication software design……………………………………… 173 7.5 Wireless MCU and its point-to-multipoint wireless communication……………………… 177 7.5.1 Wireless MCU………………………………………………………… 177 7.5.2 Wireless MCU realizes point-to-multipoint wireless communication……………………… 178 7.5.3 Multi-point wireless temperature measurement system……………………… 179 7.6 Application of RFID technology and Internet of Things……………………… 181 7.6.1 Definition of Internet of Things………………………………………… 181 7.6.2 RFID Technology…………………………………………………… 181 7.7 Questions and Exercises……………………………………………… 184 Chapter 8 Microcontroller Small System and Off-Chip Expansion……………………… 185 8.1 Serial Expansion Bus Interface Technology………………………… 185 8.1.1 SPI Serial Peripheral Interface Bus…………………………… 185 8.1.2 I2C Bus…………………………………………………………… 191 8.1.3 Single Bus…………………………………………………………… 191 8.2 The Generation of Parallel Expansion Triple Bus……………………… 197 8.2.1 8.2.2 Implementation of system expansion …………………………………… 198 8.3 Expanding data memory…………………………………………………… 199 8.4 Expansion of simple parallel I/O port……………………………………… 199 8.4.1 Direct input/output of I/O port………………………………… 199 8.4.2 Expansion method of simple I/O interface………………… 200 8.5 Questions and exercises……………………………………………… 202 Chapter 9 Application system configuration and interface technology… 204 9.1 Human-machine channel configuration and interface technology… 204 9.1.1 9.1.2 LED display interface and display program ………………………… 212 9.1.3 Serial port controlled keyboard/LED display interface circuit ………… 216 9.2 A/D converter and interface technology in the system forward channel ………… 220 9.2.1 8-bit serial A/D chip TLC0831 and single-chip microcomputer interface and programming …… 220 9.2.2 8-bit 2-channel serial A/D chip ADC0832 and single-chip microcomputer interface and programming …… 222 9.2.3 10-bit single-channel serial output A/D chip TLC1549 interface and programming …… 224 9.2.4 12-bit serial A/D chip AD7893 and single-chip microcomputer interface and programming …… 227 9.2.5 9.2.6 16-bit high-speed serial A/D chip AD7683 and single-chip microcomputer interface and programming …… 235 9.2.7 8-bit parallel output A/D chip ADC0809 and single-chip microcomputer interface and programming …… 239 9.3 System back channel configuration and interface technology ………… 242 9.3.1 Power switch devices and interface in the back channel ………… 243 9.3.2 Bidirectional thyristor (thyristor) temperature control system ………… 246 9.3.3 Serial input D/A chip TLC5615 interface technology ………………………… 246 9.3.4 Parallel input D/A chip and interface technology …………………… 251 9.4 Questions and Exercises…………………………………………………… 255 Chapter 10 System Utilities…………………………………………………… 257 10.1 The Concept of Main Program and Subprogram…………………………… 257 10.1.1 Main Program…………………………………………………………… 257 10.1.2 Subroutines and parameter transfer…………………………………… 257 10.1.3 Interrupt service subroutine…………………………………………… 259 10.2 Data acquisition and simple control program………………………… 260 10.2.1 Data acquisition program……………………………………………… 260 10.2.2 Navigation light control program………………………………… 260 10.2.3 Water level control program………………………………………… 262 10.2.4 Buzzer alarm subroutine…………………………………… 265 10.3 Data processing program……………………………………………… 265 10.3.1 Sorting program…………………………………………………… 266 10.3.2 10.3.3 Scale conversion (engineering quantity conversion) …………………… 267 10.4 Code conversion program…………………………………………………… 270 10.5 Anti-interference technology…………………………………………………… 272 10.5.1 Software trap technology……………………………………………… 272 10.5.2 Software watchdog………………………………………………… 275 10.5.3 MCU on-chip hardware watchdog……………………… 277 10.6 Shortest program………………………………………………………… 279 Chapter 11 C51 Programming……………………………………………… 280 11.1 11.1.1 C51 identifiers and keywords …………………………………… 280 11.1.2 C51 data types …………………………………………………… 282 11.1.3 Storage methods of C51 variables ………………………………………… 283 11.1.4 C51 operators, expressions and rules ……………… 287 11.2 C51 statements ………………………………………………………… 289 11.2.1 Declaration statements ………………………………………… 289 11.2.2 Expression statements ………………………………………… 289 11.2.3 Compound statements ………………………………………… 290 11.2.4 11.2.5 Switch and Jump Statements …………………………………… 291 11.2.6 Loop Statements …………………………………………………… 293 11.2.7 Function Call Statements ………………………………………… 294 11.2.8 Return Statements ……………………………………………… 294 11.2.9 Empty Statements ……………………………………………… 295 11.3 C51 Flow Control Structures …………………………………… 295 11.4 C51 Functions …………………………………………………… 295 11.4.1 Function Definitions ………………………………………… 296 11.4.2 11.5 Arrays and pointers ……………………………………………… 300 11.5.1 Array definition and reference ……………………………… 300 11.5.2 Character array ……………………………………………… 301 11.5.3 Assigning initial values to array elements ……………… 302 11.5.4 Arrays as function parameters …………………… 302 11.5.5 The concept of pointers …………………………………… 303 11.5.6 Array pointers ……………………………………………… 306 11.5.7 Pointer address calculation ………………………… 307 11.5.8 11.6 Questions and Exercises ………………………………………… 309 Appendix A 80C51 Instruction Table …………………………………………… 311 Appendix B 89C51 Instruction Matrix (Assembly/Disassembly Table) ……… 316 Appendix C 8255A Programmable Peripheral Parallel Interface Chip and Interface …… 317 References ………………………………………………………… 3251 Declaration Statements ……………………………………………… 289 11.2.2 Expression Statements ……………………………………………… 289 11.2.3 Compound Statements ……………………………………………… 290 11.2.4 Conditional Statements ……………………………………………… 290 11.2.5 Switch and Jump Statements ……………………………… 291 11.2.6 Loop Statements ……………………………………………… 293 11.2.7 Function Call Statements …………………………………… 294 11.2.8 Return Statements ……………………………………………… 294 11.2.9 Void Statements ……………………………………………… 295 11.3 11.4 C51 Functions ………………………………………………………… 295 11.4.1 Function Definition………………………………………………… 296 11.4.2 Function Call………………………………………………… 296 11.5 Arrays and Pointers…………………………………………… 300 11.5.1 Array Definition and Reference…………………………… 300 11.5.2 Character Arrays…………………………………………… 301 11.5.3 Assigning Initial Values to Array Elements……… 302 11.5.4 Arrays as Function Parameters……………………… 302 11.5.5 The concept of pointers……………………………………………… 303 11.5.6 Array pointers………………………………………………… 306 11.5.7 Pointer address calculation………………………………… 307 11.5.8 Pointer arrays and pointer-type pointers……… 308 11.6 Questions and exercises…………………………………………… 309 Appendix A 80C51 instruction table…………………………………………… 311 Appendix B 89C51 instruction matrix (assembly/disassembly table)……… 316 Appendix C 8255A programmable peripheral parallel interface chip and interface… 317 References…………………………………………………………… 3251 Declaration Statements ……………………………………………… 289 11.2.2 Expression Statements ……………………………………………… 289 11.2.3 Compound Statements ……………………………………………… 290 11.2.4 Conditional Statements ……………………………………………… 290 11.2.5 Switch and Jump Statements ……………………………… 291 11.2.6 Loop Statements ……………………………………………… 293 11.2.7 Function Call Statements …………………………………… 294 11.2.8 Return Statements ……………………………………………… 294 11.2.9 Void Statements ……………………………………………… 295 11.3 11.4 C51 Functions ………………………………………………………… 295 11.4.1 Function Definition………………………………………………… 296 11.4.2 Function Call………………………………………………… 296 11.5 Arrays and Pointers…………………………………………… 300 11.5.1 Array Definition and Reference…………………………… 300 11.5.2 Character Arrays…………………………………………… 301 11.5.3 Assigning Initial Values to Array Elements……… 302 11.5.4 Arrays as Function Parameters……………………… 302 11.5.5 The concept of pointers……………………………………………… 303 11.5.6 Array pointers………………………………………………… 306 11.5.7 Pointer address calculation………………………………… 307 11.5.8 Pointer arrays and pointer-type pointers……… 308 11.6 Questions and exercises…………………………………………… 309 Appendix A 80C51 instruction table…………………………………………… 311 Appendix B 89C51 instruction matrix (assembly/disassembly table)……… 316 Appendix C 8255A programmable peripheral parallel interface chip and interface… 317 References…………………………………………………………… 325
You Might Like
Recommended ContentMore
Open source project More
Popular Components
Searched by Users
Just Take a LookMore
Trending Downloads
Trending ArticlesMore