1. Trang chủ
  2. » Công Nghệ Thông Tin

Giáo trình MSP430 microcontroller basics

18 254 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 40,13 KB
File đính kèm MSP430 Microcontroller Basics.zip (4 MB)

Nội dung

Giáo trình MSP430 microcontroller basics, tìm hiểu về MSP430 microcontroller basics, giáo án về MSP430 microcontroller basics, giáo trình tiếng anh về MSP430 microcontroller basics, tìm hiểu giáo án MSP430 microcontroller basics.

MSP430 Microcontroller Basics This page intentionally left blank MSP430 Microcontroller Basics John H Davies AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Newnes is an imprint of Elsevier Newnes is an imprint of Elsevier 30 Corporate Drive, Suite 400, Burlington, MA01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2008, Elsevier Ltd All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: permissions@elsevier.com You may also complete your request online via the Elsevier homepage (http://www.elsevier.com) by selecting “Support & Contact” then “Copyright and Permission” and then “Obtaining Permissions.” Recognizing the importance of preserving what has been written, Elsevier prints its books on acid-free paper whenever possible Library of Congress Cataloging-in-Publication Data Application submitted British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library ISBN: 978-0-7506-8276-3 For information on all Newnes publications, visit ourWeb site at: http://www.books.elsevier.com 08 09 10 11 12 13 10 Printed in the United States of America “To Elizabeth.” This page intentionally left blank Contents Preface xi Chapter 1: Embedded Electronic Systems and Microcontrollers 1.1 What (and Where) Are Embedded Systems? .1 1.2 Approaches to Embedded Systems 1.3 Small Microcontrollers .5 1.4 Anatomy of a Typical Small Microcontroller 1.5 Memory 11 1.6 Software 15 1.7 Where Does the MSP430 Fit? 16 Chapter 2: The Texas Instruments MSP430 21 2.1 The Outside View—PinOut 21 2.2 The Inside View—Functional Block Diagram 24 2.3 Memory 25 2.4 Central Processing Unit 30 2.5 Memory-Mapped Input and Output 32 2.6 Clock Generator 33 2.7 Exceptions: Interrupts and Resets 36 2.8 Where to Find Further Information 37 Chapter 3: Development 43 3.1 Development Environment 44 3.2 The C Programming Language 46 3.3 Assembly Language 55 3.4 Access to the Microcontroller for Programming and Debugging 57 3.5 Demonstration Boards 59 3.6 Hardware 64 3.7 Equipment 65 www.newnespress.com viii Contents Chapter 4: A Simple Tour of the MSP430 67 4.1 First Program on a Conventional Desktop Computer 68 4.2 Light LEDs in C 70 4.3 Light LEDs in Assembly Language 72 4.4 Read Input from a Switch 80 4.5 Automatic Control: Flashing Light by Software Delay 91 4.6 Automatic Control: Use of Subroutines 99 4.7 Automatic Control: Flashing Light by Polling Timer_A 105 4.8 Header Files and Issues Brushed under the Carpet 114 Chapter 5: Architecture of the MSP430 Processor 119 5.1 Central Processing Unit .119 5.2 Addressing Modes 125 5.3 Constant Generator and Emulated Instructions 131 5.4 Instruction Set 132 5.5 Examples 146 5.6 Reflections on the CPU and Instruction Set 153 5.7 Resets 157 5.8 Clock System 163 Chapter 6: Functions, Interrupts, and Low-Power Modes 177 6.1 Functions and Subroutines 178 6.2 What Happens when a Subroutine Is Called? 178 6.3 Storage for Local Variables 179 6.4 Passing Parameters to a Subroutine and Returning a Result 183 6.5 Mixing C and Assembly Language 185 6.6 Interrupts 186 6.7 What Happens when an Interrupt Is Requested? 188 6.8 Interrupt Service Routines 190 6.9 Issues Associated with Interrupts 196 6.10 Low-Power Modes of Operation 198 Chapter 7: Digital Input, Output, and Displays 207 7.1 Digital Input and Output: Parallel Ports 208 7.2 Digital Inputs 216 7.3 Switch Debounce 225 7.4 Digital Outputs 238 7.5 Interface between 3V and 5V Systems 243 7.6 Driving Heavier Loads 247 7.7 Liquid Crystal Displays 252 7.8 Driving an LCD from an MSP430x4xx 256 7.9 Simple Applications of the LCD 264 www.newnespress.com Contents ix Chapter 8: Timers 275 8.1 Watchdog Timer 276 8.2 Basic Timer1 281 8.3 Timer_A 287 8.4 Measurement in the Capture Mode 300 8.5 Output in the Continuous Mode 318 8.6 Output in the Up Mode: Edge-Aligned Pulse-Width Modulation 330 8.7 Output in the Up/Down Mode: Centered Pulse-Width Modulation 349 8.8 Operation of Timer_A in the Sampling Mode 352 8.9 Timer_B 353 8.10 What Timer Where? 356 8.11 Setting the Real-Time Clock: State Machines 357 Chapter 9: Mixed-Signal Systems: Analog Input and Output 369 9.1 Comparator_A 371 9.2 Analog-to-Digital Conversion: General Issues 393 9.3 Analog-to-Digital Conversion: Successive Approximation 402 9.4 The ADC10 Successive-Approximation ADC 407 9.5 Basic Operation of the ADC10 412 9.6 More Advanced Operation of the ADC10 424 9.7 The ADC12 Successive-Approximation ADC 432 9.8 Analog-to-Digital Conversion: Sigma–Delta 438 9.9 The SD16_A Sigma–Delta ADC 446 9.10 Operation of SD16_A 459 9.11 Signal Conditioning and Operational Amplifiers 475 9.12 Digital-to-Analog Conversion 485 Chapter 10: Communication .493 10.1 Communication Peripherals in the MSP430 495 10.2 Serial Peripheral Interface 497 10.3 SPI with the USI 504 10.4 SPI with the USCI 513 10.5 AThermometer Using SPI in Mode with the F2013 as Master 520 10.6 AThermometer Using SPI in Mode with the FG4618 as Master 526 10.7 Inter-integrated Circuit Bus 534 10.8 A Simple I²C Master with the USCI_B0 on a FG4618 542 10.9 A Simple I²C Slave with the USI on a F2013 549 10.10 State Machines for I²C Communication 559 10.11 AThermometer Using I²C with the F2013 as Master 567 10.12 Asynchronous Serial Communication 574 10.13 Asynchronous Communication with the USCI_A 581 www.newnespress.com x Contents 10.14 A Software UART Using Timer_A 590 10.15 Other Types of Communication 599 Chapter 11: The Future: MSP430X 601 11.1 Architecture of the MSP430X 601 11.2 Instruction Set of the MSP430X 607 11.3 Where Next? 614 11.4 Conclusion 617 Appendix A: Kickstarting the MSP430 619 A.1 Introduction to EW430 619 A.2 Developing a Project in C 621 A.3 Debugging with the Simulator 627 A.4 Debugging with the Emulator 630 A.5 Developing a Project in Assembly Language 633 A.6 Tips for Using EW430 636 A.7 Tips for Specific Development Kits 640 Appendix B: Further Reading 645 Books and Articles 645 Newsletters, Magazines, and Journals 651 Index 655 www.newnespress.com Preface About a decade ago, I took over the teaching of a first-year, second-semester course on digital electronics It covered flip-flops, counters, and state machines, all built from small-scale integrated circuits One of the projects at the end was to build a digital die In many ways it was an excellent exercise because there were so many feasible ways in which it could be approached—simple counters, Johnson counters, or state machines My concern was that it was very close to the project that I had experienced in my first course on digital electronics, which was back in the mid-1970s The technology was close to the state of the art then, but was it still appropriate after so many years? Another feature of our course is that it is taken not only by electronic engineers but also by students from the science faculty, mostly computer scientists I wanted these students to leave with a feeling for what can readily be done with modern programmable electronics in smaller-scale systems I therefore replaced the material in the second half of the course with microcontrollers (Do not worry, state machines were not abandoned—they are taught with hardware description languages in the context of programmable logic devices.) More recently, I thought that the time had come to review the choice of microcontroller We traditionally used 8-bit processors because modern devices have versatile peripherals and sophisticated embedded emulation and are quite powerful enough for most applications Then the Texas Instruments MSP430 caught my eye A problem with 8bit microcontrollers is that bits are too few for addresses, which are typically 16 bits long, and this means that data and addresses cannot be treated on an equal footing In contrast, the MSP430 has a uniform, 16-bit architecture throughout: The address bus, data bus, and registers in the CPU are all 16 bits wide The CPU has a modern design with plenty of registers, most of which can be used equally for data or addresses It has a small instruction set with orthogonal addressing and an ingenious constant generator, which is used to emulate many operations that would otherwise need their own, distinct instructions In many ways these features make the 16-bit MSP430 simpler than a typical 8-bit processor www.newnespress.com xii Preface Of course an elegant architecture does not generate many sales in the real world More important are the range of peripherals and development tools The MSP430 offers the usual selection of peripherals plus some less common modules, including sigma–delta analog-todigital converters and operational amplifiers Some devices include hardware multipliers and digital-to-analog converters, which provide a complete signal chain (although, of course, Texas Instruments also offers an enormous range of digital signal processors) There is a choice of two free development environments (always an important consideration in education) One is IAR EmbeddedWorkbench, which is available for a wide range of microcontrollers Another, Code Composer Essentials, is produced by Texas Instruments itself A third option is the GCC toolchain for MSP430 at mspgcc.sourceforge.net I have not yet mentioned the major selling point of the MSP430, which is its low power consumption Many microcontrollers are based on long-established designs with low-power modes grafted onto them This means that returning to full power from a low-power mode is often awkward and in some cases is virtually a reset operation The MSP430 is refreshingly different because it was designed from the outset for lowpower operation Entry to low-power modes and exit from them is straightforward, supported by a versatile clock system For example, the clock module includes a digitally controlled oscillator that restarts at full speed from a low-power mode in less than 1_s in newer devices In many applications the MSP430 is put into a low-power mode, from which it is awakened by interrupts These automatically restore full power for the interrupt service routine and return the processor to low power when it has finished No extra code is needed for this: It is an intrinsic part of the interrupt mechanism Most peripherals are designed for low power, although this can sometimes make them a little more complicated than would otherwise be necessary The main point is that low-power modes are easy to use The quality of the data sheets and user’s guides is another issue in education and those for the MSP430 are fine Unfortunately one item was missing in the area of documentation: a suitable textbook in English I wrote this book to fill the gap Outline Most textbooks on microcontrollers follow one of two approaches The first is to present a sequence of projects to explore successive aspects of the device I think that this works well for simpler architectures, notably the 8-bit PICs, because it enables the reader to write functioning programs rapidly This always feels good Unfortunately I am not sure that it works as well for more advanced peripherals, which need considerable explanation before the reader can learn to use them fully www.newnespress.com Preface xiii The alternative approach is to describe each module in the microcontroller fully and in turn, starting with the CPU and instruction set and working out to the peripherals This makes for a well-organized reference book but can be tedious as a textbook I tried to steer a course between these two My inspiration is Kernighan and Ritchie’s The C Programming Language, which starts with a “Tutorial Introduction” before exploring the language systematically in subsequent chapters I think that it takes rather more introduction to a microcontroller so the “simple tour,” which is my equivalent to the tutorial, does not start until Chapter Before that, the first chapter contains a general introduction to embedded systems and microcontrollers This sets the scene for Chapter 2, which focuses on the MSP430 and gives a broad view of its features I include a chapter on hardware and software for developing applications, which I hope will be particularly useful for readers who are new to microcontrollers It also contains some reminders of features of the C language that are more prominent in programs for microcontrollers than desktop computers—bit fields for instance This leads into the tour, which runs through some simple programs to illustrate input and output, the inevitable flashing LEDs, and an introduction to one of the timers (the MSP430 has several) The remainder of the book provides a more systematic description of the MSP430 I start with the CPU and instruction set, and show how the constant generator is used to provide further “emulated” instructions The clock system is also described in this chapter It is followed by Chapter on subroutines, interrupts, and low-power modes I already mentioned that a major feature of the MSP430 is the way in which low-power modes are handled automatically when interrupts are serviced Subsequent chapters are concerned with the most widely used peripherals Chapter on digital input and output starts with the usual parallel ports and goes on to describe liquid crystal displays, which many MSP430s can drive directly There is a wide selection of timers in the MSP430, which are covered in the next chapter This is followed by a lengthy chapter on analog input and output The MSP430 offers many peripherals for analog-to-digital conversion, ranging from a simple comparator to a 16-bit sigma– delta module I not think that you can use any of these without some understanding of their characteristics, which explains the length of this chapter Some MSP430s include operational amplifiers and digital-to-analog converters, which I described briefly The final long chapter is on communication I cover only three types of communication— serial peripheral interface, inter-integrated circuit bus, and asynchronous—but there are several peripherals for these in different variants of the MSP430, so there is a lot to explain www.newnespress.com xiv Preface The very last chapter provides an introduction to the MSP430X, an extended architecture with a 20-bit address bus that can handle 1MB of memory There is also an appendix to take the reader through the steps of editing, building, and debugging the first project, which can sometimes be a frustrating experience I find it annoying when books contain large chunks copied directly from data sheets and have tried to avoid this You cannot hope to program a microcontroller without the data sheet at your side Having said that, I start by going through each bit of the registers that control the peripherals used for the early programs The idea is to explain how a typical peripheral is configured After that I become more selective and concentrate on the overall function of the peripheral instead Usually I pick out a few details that I think need extra explanation but skip the more mundane aspects They are in the example programs in any case I include links to many of Texas Instruments’ application notes because I can see no point in repeating material that has been thoroughly explained already I find that many students are strangely reluctant to use this valuable resource There are a few reminders about code examples for the same reason C or Assembly Language? Most small microcontrollers are now programmed using the C language so the question might seem redundant In fact often columns in newletters on embedded systems often carry articles with titles such as “Is Assembly Language Dead?” However, the answer seems to be clearly that assembly language is not dead for small microcontrollers, such as the MSP430 Most code is written in C but you may occasionally need to write a subroutine in assembly language to perform an operation that cannot be written out directly in C Two examples are operations that require bitwise rotations rather than shifts and calculations that can be done more efficiently by exploiting special instructions of the CPU, such as binary-coded decimal arithmetic Intrinsic functions often avoid the need for assembly language but not always More important, assembly language is often needed for debugging and this is the most compelling reason for describing it in a textbook Small microcontrollers typically spend much of their time interacting with hardware by manipulating the registers that control the peripherals Debugging may require stepping through lines of assembly language to check each step You have to look at the manual to check the details of each instruction, but it helps to have a general idea of how the assembly language works www.newnespress.com Preface xv From a pedagogical point of view, assembly language is useful to illustrate the architecture of the processor In fact the MSP430 is simple enough that you can explore the thinking behind the design of the instruction set Besides, assembly language can be fun (in small doses) My approach is to develop the first, simple programs in Chapter using both C and assembly language to show the relation between them However, C dominates by the end of the chapter Assembly language makes a strong showing in the next two chapters, which cover architecture, subroutines, and interrupts, including a section on mixing C and assembly language Almost all remaining programs are in C, with assembly language reappearing only briefly for a function to convert numbers to binary-coded decimal The listings in the text are read directly from the programs that I tested Companion Web Site Please visit the companionWeb site for this book at www.elsevierdirect.com/companions/9780750682763 and download the programs used as examples in the book These programs were read into the text of the book from the workspaces that I used for testing, which means that the downloaded files should match the book perfectly Links are also provided for data sheets, user’s guides, and development tools Solutions to the odd-numbered examples are freely available on the companionWeb site but the remaining solutions are offered only to instructors Acknowledgments It is a pleasure to thank numerous people who have helped me in various ways to write this book Many are from Texas Instruments: Bonnie Baker, Jacob Borgeson, Andreas Dannenberg, Colin Garlick, Thomas Mitnacht, and Robert Owen I am particularly grateful to Adrian Valenzuela for his comments on the final draft Several engineers from other companies were kind enough to provide advice and assistance: Edward Gibbins and Steve Duckworth from IAR, Tom Baugh of SoftBaugh, Paul Curtis of Rowley Associates, David Dyer of Ericsson and Fernando Rodriguez while he was at Texas Instruments Finally, I am grateful to colleagues and students at Glasgow University, from whom I have learnt an enormous amount over the years I’d like to thank Fernando Rodriguez (not the same person who was at Texas Instruments) and David Muir in particular, with both of whom I have run a wide range of projects on embedded systems and microcontrollers—from tutor boxes with flip-flops to the electronic systems of a Formula Student racing car John Davies, Milngavie www.newnespress.com This page intentionally left blank CHAPTER Embedded Electronic Systems and Microcontrollers This chapter provides a short introduction to embedded electronic systems, where they are used, and ways in which they can be implemented Microcontrollers were originally developed from microprocessors for use in embedded electronic control systems, as their name implies They include a processor and most or all of the memory, clock, and other systems needed to support it Everything is inside a single package, which is why a microcontroller is often described as a “computer on a chip.” I review the main features of a typical small microcontroller before setting the scene for the rest of the book with the MSP430 1.1 What (and Where) Are Embedded Systems? Suppose that you asked people in the developed world to show you the products in their house that contained “computer chips.” (Admittedly, this term is deliberately vague.) Probably they would point to a personal computer and stop there If you tried harder, you might be offered a game console or personal digital assistant It is unlikely that they would mention cellular phones, which contain a startling degree of processing power just for communication, to say nothing of taking photographs and playing games There is hardly an electrical consumer product nowadays that does not rely on digital control This seems reasonable for washing machines and video recorders, but one might wonder why a toaster or a kettle needs any digital electronics These products contain embedded electronic systems: The processor supports the operation of the product but is not the main reason for purchasing it There are said to be about 100 embedded processors for each computer, so high-profile, leading-edge microprocessors make up a small part of the market in terms of www.newnespress.com Chapter volume Fancy modern cars have approaching 100 processors and even a personal computer has embedded processors in its keyboard, mouse, screen, disk drives, and so on The snag for an engineer is that embedded seems synonymous with invisible and few people appreciate the extent to which they rely on electronics Embedded systems encompass a broad range of computational power A crude classification is given by the number of bits that can be manipulated at a time Many processors perform very simple tasks, for which or even bits are sufficient For example, I have an electric toothbrush that pauses briefly every 30 s to remind me to move on to the next quarter of my mouth The electronics in a remote control, kettle, or toaster need not be very sophisticated either A bigger device that can handle bits is needed for something like a washing machine These may be comparable in power with the processors used in the first personal computers and, in fact, the descendents of the microprocessors of those days are still widely used Digital control has been employed in car engines for many years, since the first legislation was introduced to reduce pollution and raise efficiency These relied on 16-bit processors for a long time, but 32 bits are now needed to provide the necessary performance A cellular phone also has a 32-bit processor as well as specialized hardware for digital signal processing The subject of this book is the Texas Instruments MSP430, which is a straightforward, modern 16-bit processor designed specially for low-power applications 1.2 Approaches to Embedded Systems Many different approaches can be taken for the design of embedded systems The general trend is toward digital systems and increasing integration: Systems that used analog electronics or small-scale integrated circuits (ICs) in the past are now more likely to use larger digital ICs It is easier to follow this evolution for a simple system so we look at a couple of these first 1.2.1 Timer for an Electric Toothbrush First consider a very simple application, the timer for the toothbrush mentioned earlier Here are a few possible ways of building a timer to give a 30 s delay Small-Scale Integration: The 555 Mention “timer” to many electronic engineers and they will immediately think of the 555 Introduced by Signetics in 1972, this has proven so versatile that complete books have been devoted to it In a straightforward circuit it provides a square wave whose period is www.newnespress.com Embedded Electronic Systems and Microcontrollers given very roughly by RC, the product of the values of a resistor and capacitor (Really there are two resistors, and RC should be multiplied by a constant, but that does not affect the argument.)We want RC ≈ 30 s and it is usually a good idea not to exceed R = 1M_, or leakage currents can become a problem This means that C ≈ 33_F, which is a standard value The snag is that capacitors of this value are usually electrolytic, which are physically large and leaky, but the circuit would probably work This solution needs an eight-pin 555, two resistors, and one electrolytic capacitor Medium-Scale Integration: 4000 Series CMOS A large capacitor is needed with the 555 because the period of oscillation is so long A remedy is to reduce the period (increase the frequency) and feed the output into a counter, which could be selected from the 4000 series of small- and medium-scale ICs This was the first family of CMOS logic and dates from 1968 They are slow but operate from a wide range of voltages and are particularly suitable for battery-powered circuits Unlike the 7400 series, which provides mostly straightforward logic components, several unusual functions are available A suitable device for this application is the 4060 It contains a 14-bit ripple counter and an internal oscillator circuit to provide a clock, which needs either a crystal or two resistors and a capacitor The outputs from ten stages of the counter are brought to pins so it need not just divide the clock by the maximum factor of 14 = 16,384.Without designing the system in detail, the oscillator can now run at a few hundred Hz This permits a much smaller, nonelectrolytic capacitor The snag is that the 4060 comes in a 16-pin package, so the overall circuit might take up more space than with the 555 Large-Scale Integration: Small Microcontroller I suspect that the real product contains a small microcontroller This is a complete “computer on a chip” and is described in the next section Several manufacturers produce these in eight-pin and even six-pin packages, only a few millimeters across They have complete internal oscillators, so no external components are needed (except perhaps a decoupling capacitor) Even these tiny components can far more than timing 30 s intervals Perhaps they also supervise the charging of the battery, which is indicated by a light-emitting diode (LED) Maybe they could drive a small speaker to play a tune as well 1.2.2 Electronic Dice The project in my undergraduate course on digital electronics (a long time ago) was to build an electronic dice from gates and flip-flops The top circuit in Figure 1.1 is more www.newnespress.com Chapter Figure 1.1: Electronic dice built using (top) JK flip-flops and gates and (bottom) an eight-pin microcontroller modern but uses 7400 series logic ICs and the same idea (it was formerly used in one of my department’s courses) Two packages contain JK flip-flops and the third contains gates, which drive the flip-flops through the correct sequence and provide the clock This is a simple example of a Moore state machine The lower photograph shows a circuit built on the same board using an eight-pin microcontroller The economy in components and size is obvious In fact, the on–off switch is superfluous because the microcontroller automatically switches off the LEDs after a few seconds and enters a low-power mode until the button is pressed again 1.2.3 Larger Systems Large embedded systems might contain fairly standard personal computers inside them Many automatic teller machines (ATMs) are built like this The advantage is that the hardware is standard and a huge range of software is available, including operating systems On the other hand, the systems are large and consume a lot of power Their reliability may also be questionable Three general approaches can be taken between this extreme and small-scale integration Application-specific integrated circuits (ASICs): Specially designed for a particular application as their name implies They provide the best performance but are extremely www.newnespress.com Embedded Electronic Systems and Microcontrollers expensive to design and test This restricts them to applications with very large volume or where performance must be bought at any price Field-programmable gate arrays (FPGAs) and programmable logic devices (PLDs): Essentially an array of gates and flip-flops, which can be connected by programming the device to produce the desired function This is specified using a hardware description language such as VHDL or Verilog Older programmable logic devices, such as the 22V10, contain a set of flip-flops (ten in this case) whose inputs come from an array of AND and OR gates They are often used to provide the “glue” logic needed to support a large processor Field-programmable gate arrays have a more versatile structure and may be enormous, with over a billion (10 9) transistors Microcontrollers: These have nearly fixed hardware built around a central processing unit (CPU) The CPU controls a range of peripherals, which may provide both digital and analog functions such as timers and analog-to-digital converters Small devices usually include both volatile and nonvolatile memory on the chip but larger processors may need separate memory Their operation is usually programmed using a language such as C or C++ In practice the distinction between these is blurred, particularly for larger ICs For example, part of a FPGA may be designed to act as a processor (FPGAs are often used to test the design of microcontrollers) Some devices include a fixed processor with something like a FPGA that can be configured to provide the desired digital peripherals Example 1.1 Estimate the number of embedded electronic systems in your living room 1.3 Small Microcontrollers A microprocessor contains a complete digital processor, which includes at least the arithmetic logic unit and associated registers The earliest devices, such as the Intel 4004 and Texas Instruments’ TMS1000, were introduced at the beginning of the 1970s Their breathtaking evolution since then has been toward increasing computational power and complexity They are also more powerful in an electrical sense Large, modern microprocessors need huge heat sinks and fans and can draw over 100A of current The reduction of power dissipation is a major thrust of current development, now that so many microprocessors are used in portable equipment, whose battery should last for as long as www.newnespress.com Chapter possible A microprocessor needs many other components to support it These include a (large) external memory and the other components that can be found on the motherboard of a personal computer It was realized from the start that microprocessors would also be useful to control electronic equipment, such as photocopiers Here the emphasis was less on computational power; the drive was more to reduce the complexity of the hardware and increase reliability The trend was therefore to integrate as many functions as possible on to the same chip as the processor This gave rise to the microcontroller (MCU or _C), which typically contains all of the functions needed to make a complete computer system, including memory A microcontroller also contains a selection of peripheral modules to provide commonly needed digital functions, such as timers, and often analog functions as well Inevitably the distinction between microprocessors and microcontrollers is blurred Although microprocessors have evolved almost entirely toward increasing computational power, this is not true of microcontrollers One trend has been toward increasing integration so that everything is in one package, including the clock oscillator Another trend has been the increasing integration of analog functions, so that it is often cheaper to buy a microcontroller with an analog-to-digital converter (ADC) than it is to buy a standalone ADC Processing power has increased in some families For instance the PowerPC processor, which powered Macintosh computers for many years, is now widely used in microcontrollers for engine management However, there has also been vigorous development of smaller, cheaper devices There is now a wide selection of microcontrollers in eight-pin and even six-pin packages, costing well under $1 These are aimed at applications that might previously have used discrete components and small-scale integration or, more likely, did not include electronics at all From now on, I shall consider only “small” microcontrollers (MCUs) although as usual this term cannot be defined precisely Typically these devices can process or 16 bits of data and have a 16-bit address bus, which means that they can address 64KB of memory directly with no paging or banking (The upper-case letter K stands for a “binary” kilo, [...]... or Assembly Language? Most small microcontrollers are now programmed using the C language so the question might seem redundant In fact often columns in newletters on embedded systems often carry articles with titles such as “Is Assembly Language Dead?” However, the answer seems to be clearly that assembly language is not dead for small microcontrollers, such as the MSP430 Most code is written in C... systems and microcontrollers—from tutor boxes with flip-flops to the electronic systems of a Formula Student racing car John Davies, Milngavie www.newnespress.com This page intentionally left blank CHAPTER 1 Embedded Electronic Systems and Microcontrollers This chapter provides a short introduction to embedded electronic systems, where they are used, and ways in which they can be implemented Microcontrollers... the memory, clock, and other systems needed to support it Everything is inside a single package, which is why a microcontroller is often described as a “computer on a chip.” I review the main features of a typical small microcontroller before setting the scene for the rest of the book with the MSP430 1.1 What (and Where) Are Embedded Systems? Suppose that you asked people in the developed world to show... processor This gave rise to the microcontroller (MCU or _C), which typically contains all of the functions needed to make a complete computer system, including memory A microcontroller also contains a selection of peripheral modules to provide commonly needed digital functions, such as timers, and often analog functions as well Inevitably the distinction between microprocessors and microcontrollers is blurred... provide the clock This is a simple example of a Moore state machine The lower photograph shows a circuit built on the same board using an eight-pin microcontroller The economy in components and size is obvious In fact, the on–off switch is superfluous because the microcontroller automatically switches off the LEDs after a few seconds and enters a low-power mode until the button is pressed again 1.2.3 Larger... may be designed to act as a processor (FPGAs are often used to test the design of microcontrollers) Some devices include a fixed processor with something like a FPGA that can be configured to provide the desired digital peripherals Example 1.1 Estimate the number of embedded electronic systems in your living room 1.3 Small Microcontrollers A microprocessor contains a complete digital processor, which... nonelectrolytic capacitor The snag is that the 4060 comes in a 16-pin package, so the overall circuit might take up more space than with the 555 Large-Scale Integration: Small Microcontroller I suspect that the real product contains a small microcontroller This is a complete “computer on a chip” and is described in the next section Several manufacturers produce these in eight-pin and even six-pin packages,... evolved almost entirely toward increasing computational power, this is not true of microcontrollers One trend has been toward increasing integration so that everything is in one package, including the clock oscillator Another trend has been the increasing integration of analog functions, so that it is often cheaper to buy a microcontroller with an analog-to-digital converter (ADC) than it is to buy a standalone... in some families For instance the PowerPC processor, which powered Macintosh computers for many years, is now widely used in microcontrollers for engine management However, there has also been vigorous development of smaller, cheaper devices There is now a wide selection of microcontrollers in eight-pin and even six-pin packages, costing well under $1 These are aimed at applications that might previously... general idea of how the assembly language works www.newnespress.com Preface xv From a pedagogical point of view, assembly language is useful to illustrate the architecture of the processor In fact the MSP430 is simple enough that you can explore the thinking behind the design of the instruction set Besides, assembly language can be fun (in small doses) My approach is to develop the first, simple programs

Ngày đăng: 14/05/2016, 10:14

TỪ KHÓA LIÊN QUAN

w