Embedded Microcontroller Interfacing for M CORE Systems - G. Jack Lipovski, University of Texas

Trường đại học

Đại học Texas tại Austin

Người đăng

Ẩn danh

Thể loại

Sách giáo khoa

2000

457
0
0

Phí lưu trữ

75 Point

Tóm tắt

I. Tổng quan về Embedded Microcontroller Interfacing MCORE

Embedded Microcontroller Interfacing for MCORE Systems là cuốn sách chuyên sâu về giao tiếp vi điều khiển nhúng. Tác giả G. Jack Lipovski biên soạn cuốn sách này. Ông là giảng viên tại Khoa Kỹ thuật Điện và Máy tính thuộc Đại học Texas, Austin. Academic Press xuất bản sách vào năm 2000. Cuốn sách thuộc Academic Press Series in Engineering. Loạt sách này do J. David Irwin từ Đại học Auburn担任 biên tập viên chính. Series bao gồm nhiều cuốn sách kỹ thuật tiên tiến. Các cuốn nổi bật gồm Industrial Controls and Manufacturing, DSP Integrated Circuits. Cuốn sách này tập trung vào kiến trúc bộ xử lý MCORE. Nội dung bao gồm lập trình hợp ngữ, lập trình C/C++, giao tiếp phần cứng. Cuốn sách cung cấp kiến thức từ cơ bản đến nâng cao. Đối tượng độc giả gồm sinh viên, kỹ sư và nhà nghiên cứu. Sách là tài liệu quan trọng trong lĩnh vực hệ thống nhúng.

1.1. Vị trí trong Academic Press Series in Engineering

Academic Press Series in Engineering là bộ sưu tập sách kỹ thuật hàng đầu. Loạt sách bao gồm các chủ đề liên ngành như kỹ thuật điện, cơ khí, máy tính và sản xuất. Series cung cấp sổ tay, sách giáo khoa và tài liệu tham khảo chuyên nghiệp. Các cuốn sách khác trong series gồm Time Domain Electromagnetics, Control in Robotics and Automation. Soft Computing and Intelligent Systems cũng là một phần của bộ sưu tập. Mục tiêu của series là cung cấp kiến thức cutting-edge cho ngành công nghiệp. Độc giả tìm thấy tài liệu thiết yếu cho thành công trong ngành kỹ thuật hiện đại. Cuốn sách về MCORE Systems đóng góp quan trọng vào bộ sưu tập này.

1.2. Đối tượng và mục tiêu của cuốn sách

Cuốn sách hướng đến ba nhóm đối tượng chính. Nhóm thứ nhất là sinh viên kỹ thuật điện tử và máy tính. Nhóm thứ hai là kỹ sư chuyên nghiệp làm việc trong ngành công nghiệp. Nhóm thứ ba là nhà nghiên cứu trong lĩnh vực vi điều khiển. Sinh viên sử dụng sách như tài liệu học tập chính thức. Kỹ sư tìm thấy giải pháp thực tế cho thiết kế hệ thống nhúng. Nhà nghiên cứu tham khảo các phương pháp tiên tiến. Cuốn sách cũng hữu ích cho người muốn tìm hiểu về bộ xử lý MCORE. Kiến trúc này được thiết kế cho ứng dụng nhúng với hiệu suất cao.

II. Phân tích kiến trúc và tập lệnh MCORE

Kiến trúc MCORE được trình bày chi tiết trong cuốn sách. Bộ xử lý có hai chế độ hoạt động chính. Chế độ người dùng và chế độ giám sát hoạt động song song. Chế độ người dùng có 16 thanh ghi mục đích chung từ r0 đến r15. Chế độ giám sát bổ sung thêm bộ thanh ghi thay thế r0' đến r15'. Các thanh ghi thay thế dùng riêng cho xử lý ngắt. Điều này giúp giảm độ trễ xử lý ngắt đáng kể. Chế độ giám sát còn có 13 thanh ghi điều khiển từ cr0 đến cr12. Chương trình sử dụng bộ đếm chương trình PC để lấy lệnh. Bit mã điều kiện C điều khiển nhánh trong chương trình. Bit này là bit ít nghĩa nhất của thanh ghi trạng thái PSR. Thanh ghi PSR chính là thanh ghi điều khiển cr0. Bit nghĩa nhất của PSR là bit giám sát S.

2.1. Các loại lệnh và chế độ địa chỉ

Tập lệnh MCORE gồm nhiều loại lệnh khác nhau. Hầu hết chế độ địa chỉ áp dụng cho lệnh cụ thể. Cuốn sách mô tả lệnh theo nhóm loại lệnh. Các lệnh bao gồm số học, logic, tải và lưu trữ. Lệnh nhánh và lệnh điều khiển đặc biệt cũng được trình bày. Mỗi loại lệnh có biến thể phù hợp với chế độ địa chỉ. Điều này cho phép lập trình viên linh hoạt truy cập dữ liệu. Các chế độ địa chỉ được giới thiệu cùng lệnh áp dụng. Cách tiếp cận này giúp hiểu rõ mối quan hệ giữa lệnh và địa chỉ.

2.2. Tổ chức bộ nhớ và thanh ghi điều khiển

Tổ chức bộ nhớ trong MCORE tối ưu cho ứng dụng nhúng. Các thanh ghi điều khiển từ cr0 đến cr12 quản lý hoạt động bộ xử lý. Thanh ghi PSR chứa bit giám sát và bit mã điều kiện. Phần lớn lệnh hoạt động với bất kỳ thanh ghi nào. Tuy nhiên một số lệnh chỉ dùng thanh ghi cụ thể. Thiết kế này cân bằng giữa tính linh hoạt và hiệu quả. Các thao tác thường dùng trong hệ thống nhúng được thực thi nhanh. Kiến trúc bộ nhớ hỗ trợ truy cập hiệu quả cho ứng dụng thời gian thực.

III. Phương pháp giảng dạy lập trình trong sách

Cuốn sách áp dụng phương pháp giảng dạy từ cơ bản đến nâng cao. Nội dung bắt đầu với kiến trúc máy tính vi mô. Phần tiếp theo giới thiệu lập trình hợp ngữ. Chương trình hợp ngữ được trình bày qua ví dụ cụ thể. Người đọc hiểu cách bộ xử lý MCORE thực thi lệnh. Phần lập trình C và C++ cung cấp góc nhìn cấp cao hơn. Người học viết mã nguồn hiệu quả hơn với ngôn ngữ bậc cao. Sách bao gồm bài tập cuối chương với nhiều mức độ khó. Bài tập yêu cầu viết mã lệnh và giải thích hiệu ứng lệnh. Người đọc phân tích giá trị thanh ghi sau khi thực thi. Cách tiếp cận này củng cố kiến thức lý thuyết qua thực hành. Người đọc áp dụng được kiến thức vào dự án thực tế.

3.1. Ví dụ thực hành về mã lệnh MCORE

Các ví dụ trong sách minh họa lệnh cụ thể. Lệnh addu thực hiện phép cộng không dấu giữa hai thanh ghi. Lệnh andn thực hiện phép AND ngược bit. Lệnh cmphs so sánh hai giá trị và đặt bit C. Lệnh cmplt so sánh nhỏ hơn có điều kiện. Lệnh mult thực hiện phép nhân. Mỗi ví dụ giải thích chi tiết những gì xảy ra khi thực thi. Tác động lên bit mã điều kiện C được mô tả rõ ràng. Ví dụ từ đơn giản đến phức tạp giúp hiểu cách lệnh hoạt động. Cách trình bày này tạo nền tảng vững chắc cho lập trình viên.

3.2. Bài tập phát triển kỹ năng phân tích

Phần bài tập cuối chương rất đa dạng. Người đọc viết mã lệnh và dự đoán kết quả thực thi. Bài tập yêu cầu xác định địa chỉ opcode của lệnh. Người học giải thích hiệu ứng lệnh lên thanh ghi. Tính toán giá trị thanh ghi sau chuỗi lệnh là bài tập phổ biến. Một số bài yêu cầu viết chuỗi lệnh ngắn nhất tương đương lệnh không tồn tại. Những bài tập này phát triển kỹ năng tư duy logic. Người đọc hiểu sâu cách bộ xử lý hoạt động ở cấp phần cứng. Kỹ năng này chuẩn bị cho công việc thiết kế hệ thống nhúng thực tế.

IV. Ứng dụng và tầm quan trọng của cuốn sách

Cuốn sách có giá trị ứng dụng cao trong nhiều lĩnh vực kỹ thuật. Kiến thức giao tiếp vi điều khiển nhúng là nền tảng quan trọng. Ứng dụng bao gồm điều khiển công nghiệp, thiết bị y tế, hệ thống ô tô. Cuốn sách cung cấp công cụ thiết kế và triển khai hệ thống nhúng hiệu quả. Phần tài liệu tham khảo hướng dẫn áp dụng kiến thức vào dự án cụ thể. Sách giới thiệu công cụ phát triển và kỹ thuật gỡ lỗi. Điều này giúp tăng năng suất làm việc của kỹ sư. Sự kết hợp lý thuyết và thực hành tạo giá trị đặc biệt. Cuốn sách là tài liệu không thể thiếu cho chuyên gia hệ thống nhúng. Nội dung áp dụng được cho nhiều nền tảng phần cứng khác nhau.

4.1. Giá trị cho ngành công nghiệp hiện đại

Ngành công nghiệp hiện đại phụ thuộc vào hệ thống nhúng thông minh. Kiến thức từ cuốn sách giúp phát triển sản phẩm hiệu suất cao. Sản phẩm tiêu thụ điện năng thấp và có độ tin cậy cao. Các kỹ thuật giao tiếp áp dụng được cho nhiều loại vi điều khiển. Giá trị sách không giới hạn ở kiến trúc MCORE. Kỹ sư làm việc với nhiều nền tảng phần cứng lợi ích từ cuốn sách. Sách nhấn mạnh tối ưu hóa mã nguồn và quản lý tài nguyên. Đây là yếu tố quan trọng trong phát triển sản phẩm cạnh tranh.

4.2. Đóng góp cho giáo dục kỹ thuật

Cuốn sách đóng vai trò quan trọng trong giáo dục kỹ thuật. Nội dung tổ chức logic từ cơ bản đến nâng cao. Sách phù hợp cho cả tự học và giảng dạy chính thức. Bài tập cuối chương giúp sinh viên củng cố kiến thức. Kỹ năng giải quyết vấn đề được phát triển qua thực hành. Cuốn sách giới thiệu kiến trúc máy tính và hệ điều hành nhúng. Nền tảng này chuẩn bị cho việc học môn nâng cao hơn. Sự kết hợp lý thuyết và thực hành phản ánh giáo dục hiện đại. Sinh viên tốt nghiệp có kỹ năng đáp ứng nhu cầu ngành công nghiệp.

21/04/2026

Trích đoạn nội dung tài liệu

Embedded Microcontroller Interfacing for M CORE Systems www.org Academic Press Series in Engineering Series Editor J. David Irwin Auburn University Designed to bring together interdependent topics in electrical engineering, mechanical engineering, computer engineering, and manufacturing, the Academic Press Series in Engineering provides state-of-the-art handbooks, textbooks, and professional reference books for researchers, students, and engineers. This series provides readers with a comprehensive group of books essential for success in modern industry. A particular emphasis is given to the applications of cutting-edge research. Engineers, researchers, and students alike will find the Academic Press Series in Engineering to be an indispensable part of their design toolkit. Published books in the series: Industrial Controls and Manufacturing, 1999, E. Kamen DSP Integrated Circuits, 1999, L. Wanhammar Time Domain Electromagnetics, 1999, S. Rao Single- and Multi-Chip Microcontroller Interfacing for the Motorola 68HCI2, 1999, G. Lipovski Control in Robotics and Automation, 1999, B. Tarn Soft Computing and Intelligent Systems, 1999, N. Gupta Introduction to Microcontrollers, 1999, G. Lipovski Control of Induction Motors, 2000, A. Trzynadlowski Embedded Microcontroller Interfacing for MCORE Systems, 2000, G. Lipovski Embedded Microcontroller Interfacing for M CORE Systems G. Jack LipoYski Department of Electrical and Computer Engineering University of Texas www.org Austin, Texas ACADEMIC PRESS A Harcourt Science and Technology Company San Diego San Francisco New York Boston London Sydney Tokyo This book is printed on acid-free paper. @ Copyright © 2000 by Academic Press All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission in writing from the publisher. Requests for permission to make copies of any part of the work should be mailed to the following address: Permissions Department, Harcourt, Inc., 6277 Sea Harbor Drive, Orlando, Florida, 32887-6777. ACADEMIC PRESS A Harcourt Science and Technology Company 525 B Street, Suite 1900, San Diego, CA 92101-4495, USA http://www.com Academic Press Harcourt Place, 32 Jamestown Road, London NWl 7BY, UK http: //www. com Library of Congress Catalog Card Number: 00-102018 ISBN: 0-12-451832-X Printed in the United States of America 00 01 02 03 04 05 IP 9 8 7 6 5 4 3 2 1 Dedicated to my wife Isabelle Lipovski www.org This Page Intentionally Left Blank Contents Preface ix List of Figures x List of Tables xiii Acknowledgments xiv About the Author xv 1 Microcomputer Architecture 1 1.1 An Introduction to the Microcomputer 1 1.2 The M CORE Instruction Set 11 1.3 Assembly-Language Programming 27 1.4 Organization of MCORE Microcontrollers 27 1.5 Conclusions 29 Problems 31 2 Programming in C and C + + 37 2.3 Writing Clear C Programs 58 2.4 Conclusions 76 Problems 78 3 Operating Systems 85 3.1 What Is an Operating System? 85 3.2 Functions and Features of Ariel 88 3.3 Object-oriented Operating Systems Functions 103 3.4 Conclusions 104 Problems 105 4 Bus Hardware and Signals 109 4.2 Address and Control Signals in MCORE Microcontrollers 121 4.3 Voltage Level Considerations 128 4.4 Conclusions 130 Problems 131 5 Parallel and Serial Input-Output 137 5.1 I/O Devices and Ports 138 5.2 Input/Output Software 167 vn viii Contents 5.3 Input/Output Indirection 182 5.4 A Designer's Selection of I/O Ports and Software 205 5.5 Conclusions 208 Problems 209 6 Interrupts and Alternatives 217 6.3 Fast Synchronization Mechanisms 267 6.4 A Designer's Selection of Synchronization Mechanisms 274 6.5 Conclusions 277 Problems 278 7 Timer Devices and Time-Sharing 285 7.3 Ariel Task Management 302 7.4 Conclusions 306 Problems 307 8 Embedded I/O Device Design 311 8.2 MMC2001 Environment for Additional Hardware 318 8.3 A MOVE Architecture for I/O Devices 323 8.5 Conclusions 334 Problems 335 9 Communication Systems 339 9.3 UART Link Protocols 350 9.5 Conclusions 379 Problems 380 10 Display and Storage Systems 387 10.3 Conclusions 421 Problems 422 Appendix 429 Index 433 Preface The embedded microcontroller industry is moving towards inexpensive micro- controllers with significant amounts of ROM and RAM, and some user-designed hardware that is put on a single microcontroller chip. In these microcontrollers, the majority of the design cost is incurred in the writing of software that will be used in them. The memory available in such microcontrollers permits the use of real-time operating systems. Further, C + + compilers permit the use of classes to encapsulate the function members, their data members, and their hardware, in an object. Both of these techniques reduce software design cost. This book aims to give the principles of and concrete examples of design, especially software design, of the Motorola MMC2001, a particular MCORE embedded microcontroller. The first four chapters of the book provide background. The first chapter is aimed at the high-level programmer who will need to acquire a reading knowledge of assembler language to be able to debug his or her high-level language programs. The second chapter is aimed at the hardware designer, who will need to know enough C and C + + programming to be able to write the programs in an embedded micro- controller. The third chapter introduces the real-time operating system, including the use of device drivers. The fourth chapter provides information for programmers who need to understand the issues involved in hardware design, including the design of ASIC modules that are implemented in an MCORE chip. While many readers will be familiar with one or more of these topics, the designer of embedded micro- controllers needs to be familiar with all of them. These chapters bring the reader to an adequate level of background needed for embedded microcontroller design. The next three chapters are the core of this book. The fifth chapter discusses the alternatives to the parallel port, and ways to program interfaces to control them. The sixth chapter describes alternatives to interrupts, and ways to program interrupt and other synchronization interfaces. The seventh chapter highlights the techniques for and problems with time slice operation of embedded microcontrollers. A simple multi- threaded time sharing system is introduced, followed by an object-oriented time sharing system. The use of real-time operating systems multitasking is then discussed. Chapter 8 shows how to design additional hardware to be added into the MMC2001 chip. It gives an ASIC design example, and describes a processor architecture that is suitable for special-purpose designs. The last two chapters provide some examples of system design. Chapter 9 discusses communication techniques and shows several programming approaches to the MMC2001 UART device. The tenth chapter shows the programming of display and storage systems. This book provides a concrete understanding of hardware-software tradeoffs, high-level languages, and embedded microcontroller operating systems. Because these very practical areas should be understood by many if not all computer en- gineering graduate students, this book is written as a textbook for a graduate level course. However, it will also be very useful to practitioners, especially those who will work with the Motorola M-CORE embedded microcontroller. It is therefore also written for engineers who need to understand and use these microcontrollers. IX List of Figures Figure Title Page Figure 1.1 Analogy to the von Neumann computer 3 Figure 1.2 MCORE Registers 12 Figure 1.3 MCORE memory 13 Figure 1.4 Leaf and nonleaf subroutines 22 Figure 1.5 Block diagram showing the effect of an instruction 27 Figure 1.6 Photomicrograph of the MMC2001 chip 28 Figure 1.7 MMC2001 organization 29 Figure 1.8 Memory map of the MMC2001 30 Figure 2.1 Conditional statements 42 Figure 2.2 Case statements 43 Figure 2.3 Loop statements 43 Figure 2.4 A Huffman coding tree 55 Figure 2.5 An object and its pointers 71 Figure 2.6 Other Huffman codes 80 Figure 4.1 Voltage waveforms, signals, and variables 110 Figure 4.2 Some common gates 115 Figure 4.3 Logic diagrams for a popular driver and register 116 Figure 4.4 16R4 PAL used in microcomputer designs 120 Figure 4.5 Some timing relationships 121 Figure 4.6 Timing relationships for an MCORE microcontroller 122 Figure 4.7 MMC2001 address and data bus signals 123 Figure 4.8 Block diagram decoding for Table 4.9 Common integrated circuits used in decoders 127 Figure 4.10 Logic diagram of minimal complete decoder 128 Figure 4.11 Axiom MMC2001 evaluation board 129 Figure 4.13 Some MSI I/O chips 133 Figure 5.1 Logic diagram for a completely decoded input device 140 Figure 5.2 Logic diagram for a completely decoded basic output device 141 Figure 5.3 Block diagram for a readable output device 142 Figure 5.4 An unusual I/O port 145 Figure 5.5 A set port 147 Figure 5.6 Address output techniques 149 Figure 5.7 MMC2001 parallel ports 150 Figure 5.8 MMC2001 EIM control ports 153 Figure 5.9 Driver arguments and associated structures 164 Figure 5.10 Traffic light 171 Figure 5.11 Mealy sequential machine 175 Figure 5.12 A linked-Hst structure 177 List of Figures XI Figure 5.13 MMC2001 port connections for a chip tester 179 Figure 5.14 The 74HC00 180 Figure 15 MC6818A time-of-day chip 183 Figure 16 An LCD display 185 Figure 17 Simple serial input/output ports 187 Figure 18 Configurations of simple serial input/output registers 188 Figure 5.19 Flow chart for series serial data output 190 Figure 5.20 Dallas Semiconductor 1620 digital thermometer 191 Figure 5.21 ISPI data, control, and status ports 192 Figure 5.22 Multicomputer communication system using the ISPI 194 Figure 5.23 Some ICs for I/O 210 Figure 6.1 Paper tape hardware 218 Figure 6.2 State diagram for I/O devices 219 Figure 6.3 Flow charts for programmed I/O 221 Figure 6.4 M C O R E edge ports 223 Figure 6.5 Infrared control 227 Figure 6.6 Magnetic card reader 228 Figure 6.8 MMC2001 interrupt controller ports 237 Figure 6.9 INTO hardware 238 Figure 6.10 Simplified edge interrupt request path 239 Figure 6.11 Polled interrupt request path 249 Figure 6.12 General round-robin poUing process 250 Figure 6.13 Vector interrupt request path 252 Figure 6.14 Keyboard control and status ports 255 Figure 6.15 Keys and keyboards 256 Figure 6.16 ISPI network 257 Figure 6.17 Connections for context switching 269 Figure 6.18 Fast synchronization mechanisms using memory organizations 271 Figure 6.19 Indirect memory using a MCM6264D-45 273 Figure 6.20 Synchronization mechanisms summarized 275 Figure 6.1 Pulsewidth modulator 286 Figure 7.2 Time-of-day module 288 Figure 7.3 Watchdog timer module 290 Figure 7.4 Programmable interval timer 292 Figure 7.5 "Centronics" parallel printer port 299 Figure 8.1 A two-bit decoder 313 Figure 8.2 Module regie built from module C74HC374 315 Figure 8.chain module 315 Figure 8.4 Array of instances in a module 316 Figure 8.5 Shift register 317 Figure 8.7 Cell library for MMC2001 hardware 321 xii List of Figures Figure 8.8 Logic diagram for a completely decoded input device (revised) 322 Figure 8.9 Architecture for a MOVE processor 324 Figure 8.10 Architecture for a MOVE processor ALU 325 Figure 8.11 Adder module 326 Figure 8.12 Search module 330 Figure 8.13 Component modules 331 Figure 8.14 MOVE processor using search modules 332 Figure 9.1 Peer-to-peer communication at different levels 340 Figure 9.2 Drivers and receivers 345 Figure 9.3 Originating a call on a modem 349 Figure 9.4 Frame format for UART signals 351 Figure 9.5 Block diagram of a UART (IM6403) 354 Figure 9.6 Transmitter signals 355 Figure 9.7 MMC2001 UARTO 357 Figure 9.8 Synchronous formats 370 Figure 9.9 IEEE-488 bus handshaking cycle 374 Figure 9.10 SCSI timing 376 Figure 9.11 An SCSI interface 379 Figure 10.1 The raster scan display used in television 388 Figure 10.2 Character display 389 Figure 10.3 The composite video signal 389 Figure 10.4 Screen display 391 Figure 10.5 Circuit used for TV generation 391 Figure 10.6 Hardware for a more reahstic display 393 Figure 10.7 Bit and byte storage for FM and MFM encoding 398 Figure 10.8 Organization of sectors and tracks on a disk surface 399 Figure 10.9 A special byte (data = OxAl, clock pulse missing between bits 4,5)401 Figure 10.10 The Western Digital WD37C65C 403 Figure 10.11 File dump 408 Figure 10.12 SCSI commands for a ZIP-100 drive 409 Figure 10.13 PC disk organization 410 Figure 10.14 Dump of a boot sector 410 Figure 10.15 PC file organization 411 Figure 10.16 Dump of a directory 412 Figure 10.

Nội dung được bảo vệ bản quyền — Tải xuống đầy đủ