PART 1 Introduction 1
1 Introduction to Microcontrollers 1
1.1 The Microcomputer 3
1.2 The 68HC11 and 68HC12 Microcontrollers 14
1.3 Historical Context 14
1.4 Software and Hardware Development 15
Summary 22
Exercises 22
PART 2 Assembly Language Programming 24
2 Programming Basics 24
2.1 Programming Languages 24
2.2 Types of Program Segments 30
2.3 Software Construction 31
Summary 34
Exercises 34
3 Simple Assembly Code Construction 35
3.1 Assembly Source Code 37
3.2 A Basic Build Process 47
3.3 Run-Time Debugging-A Tutorial 52
Summary 59
Exercises 60
4 CPU12 Programming Model 61
4.1 The CPU Register Set 61
4.2 CPU12 Addressing Modes 64
4.3 The CPU12 Instruction Set 77
Summary 78
Exercises 78
5 Basic Assembly Programming Techniques 80
5.1 Data Transfer 80
5.2 Using the Stack 86
5.3 Basic Arithmetic Programming 92
5.4 Shifting and Rotating 105
5.5 Boolean Logic,Bit Testing,and Bit Manipulation 106
5.6 Branches and Jumps 113
5.7 Subroutines 120
5.8 Position Independence 128
Summary 132
Exercises 132
6 Assembly Program Design and Structure 137
6.1 Design and Documentation Tools 138
6.2 Structured Control Constructs 143
6.3 Data Storage 155
6.4 Program Structure 162
6.5 Passing Parameters 163
Summary 172
Exercises 173
7 Assembly Applications 174
7.1 Software Delay Routines 174
7.2 I/O Data Conversions 180
7.3 Basic I/O Routines 194
7.4 Fixed-Point Arithmetic 208
Summary 229
Exercises 229
PART 3 Microcontroller Hardware and I/O 231
8 Introduction to Real-Time I/O and Multitasking 231
8.1 Real-Time Systems 231
8.2 CPU Loads 233
8.3 I/O Detection and Response 234
8.4 Basic Cooperative Multitasking 261
8.5 Using CPU12 Interrupts 274
8.6 Basic Real-Time Debugging 289
Summary 293
Exercises 293
9 Microcontroller I/O Resources 295
9.1 General Purpose I/O 296
9.2 Timers 306
9.3 Serial I/O 347
9.4 A-to-D Conversion 366
Summary 376
Exercises 376
10 The Final Product 378
10.1 MCU Hardware Design 379
10.2 Reset Exceptions 386
10.3 M68HC912B32 Operating Modes 394
10.4 Configuration and Start-Up Code 400
10.5 Final Product Development 406
Summary 416
Exercises 417
11 System Expansion 418
11.1 The Bus Cycle 419
11.2 Chip-Select Logic 421
11.3 Bus Timing Analysis 434
Summary 437
Exercises 438
PART 4 Programming Microcontrollers in C 439
12 Modular and C Code Construction 439
12.1 C Source Code 440
12.2 The Modular Build Process 454
12.3 Source-Level Debugging 475
Summary 481
Exercises 481
13 Creating and Accessing Data in C 483
13.1 Introduction to Data Types 484
13.2 ANSI-C Data Types 485
13.3 Variables and Stored Constants 494
13.4 Pointers 498
13.5 Arrays and Strings 503
13.6 Structures 507
13.8 Bit Operations 509
13.7 Enumerated Types 509
Summary 516
Exercises 517
14 C Program Structures 518
14.1 Control Structures 518
14.2 Functions 536
14.3 Modules 548
14.4 Start-Up and Initialization 557
Summary 564
Exercises 564
PART 5 Real-Time Multitasking Kernels 566
15 Real-Time Multitasking in C 566
15.1 Real-Time Programming Review 566
15.2 Real-Time Kernel Overview 570
15.3 Cooperative Kernel Design 574
Summary 591
Exercises 592
16 Using the MicroC/OS-II Preemptive Kernel 594
16.1 Overview 595
16.2 Tasks and Task Switching 603
16.3 Interrupt Service Routines 609
16.4 Timers 610
16.5 Intertask Communication 614
16.6 μC/OS-Based Stopwatch Program 638
Summary 645
Exercises 646
APPENDICES 648
A Programming Conventions 648
B Bask I/O 651
C uC/OS Reference 672
REFERENCES 685
INDEX 687