Fundamentals of Embedded Software with the ARM Cortex-M3 / Edition 1

Fundamentals of Embedded Software with the ARM Cortex-M3 / Edition 1

by Daniel Lewis
ISBN-10:
0132916541
ISBN-13:
9780132916547
Pub. Date:
02/02/2012
Publisher:
Pearson Education
ISBN-10:
0132916541
ISBN-13:
9780132916547
Pub. Date:
02/02/2012
Publisher:
Pearson Education
Fundamentals of Embedded Software with the ARM Cortex-M3 / Edition 1

Fundamentals of Embedded Software with the ARM Cortex-M3 / Edition 1

by Daniel Lewis

Hardcover

$213.32
Current price is , Original price is $213.32. You
$78.64 
  • SHIP THIS ITEM
    Not Eligible for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores
  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.


Overview

For sophomore-level courses in Assembly Language Programming in Computer Science, Embedded Systems Design, Real-Time Analysis, Computer Engineering, or Electrical Engineering curricula. Requires prior knowledge of C, C++, or Java. This text is useful for Computer Scientists, Computer Engineers, and Electrical Engineers involved with embedded software applications.

This book is intended to provide a highly motivating context in which to learn procedural programming languages. The ultimate goal of this text is to lay a foundation that supports the multi-threaded style of programming and high-reliability requirements of embedded software. It presents assembly the way it is most commonly used in practice - to implement small, fast, or special-purpose routines called from a main program written in a high-level language such as C. Students not only learn that assembly still has an important role to play, but their discovery of multi-threaded programming, preemptive and non-preemptive systems, shared resources, and scheduling helps sustain their interest, feeds their curiosity, and strengthens their preparation for subsequent courses on operating systems, real-time systems, networking, and microprocessor-based design.


Product Details

ISBN-13: 9780132916547
Publisher: Pearson Education
Publication date: 02/02/2012
Edition description: New Edition
Pages: 256
Product dimensions: 7.20(w) x 9.20(h) x 0.80(d)

About the Author

Dr. Daniel W. Lewis' efforts led to the creation of Santa Clara University’s Computer Engineering department in 1988, providing its leadership for the first 18 years. During his tenure, Lewis established unique co-op and study abroad options that fit within the normal undergraduate four-year plan, the first graduate-level academic certificate programs for working professionals, a new interdisciplinary major in Web Design and Engineering, and a interdisciplinary minor in Information Technology and Society. Since 2004, Lewis has focused on K-12 outreach in engineering and computing, raising more than $1.7M from NSF and private sources, and providing professional development for more than 200 K-12 teachers and summer camps for more than 2,000 K-12 students.

Prior to joining the University in 1975, Lewis worked for six years at General Electric’s Aerospace Division where he designed a fault-tolerant clocking system for one of the first triple-redundant automatic landing systems for commercial aircraft. He has consulted for a number of Bay Area companies, including the Singer-Link Company, where his design of new algorithms and a corresponding modular array of VLSI circuits became the basis of a new product line of real-time computer graphics systems.

Table of Contents

Preface xiii

Chapter 1 Introduction 1

1.1 What is an Embedded System? 1

1.2 What Is Unique about the Design Goals for Embedded Software? 3

1.3 What Does "Real-Time" Mean? 5

1.4 What Does "Multithreading" Mean? 5

1.5 How Powerful are Embedded Processors? 6

1.6 What Programming Languages are Used? 6

1.7 How Is Building an Embedded Application Different? 7

1.8 How Big are Typical Embedded Programs? 9

Problems 10

Chapter 2 Data Representation 11

2.1 Fixed-Precision Binary Numbers 11

2.2 Positional Number Systems 13

2.2.1 Binary-to-Decimal Conversion 14

2.2.2 Decimal-to-Binary Conversion 14

2.2.3 Hexadecimal: A Shorthand for Binary 17

2.2.4 Fixed Precision, Rollover, and Overflow 18

2.3 Binary Representation of Integers 19

2.3.1 Signed Integers 20

2.3.2 Positive and Negative Representations of the Same Magnitude 20

2.3.3 Interpreting the Value of a 2's-Complement Number 21

2.3.4 Changing the Sign of Numbers with Integer and Fractional Parts 22

2.3.5 Binary Addition and Subtraction 23

2.3.6 Range and Overflow 25

2.4 Binary Representation of Real Numbers 26

2.4.1 Floating-Point Real Numbers 26

2.4.2 Fixed-Point Real Numbers 28

2.5 ASCII Representation of Text 28

2.6 Binary-Coded Decimal (BCD) 31

Problems 32

Chapter 3 Implementing Arithmetic 35

3.1 2'S-Complement and Hardware Complexity 35

3.2 Multiplication and Division 38

3.2.1 Signed Versus Unsigned Multiplication 38

3.2.2 Shifting Instead of Multiplying or Dividing by Powers of 2 38

3.2.3 Multiplying by an Arbitrary Constant 40

3.2.4 Dividing by an Arbitrary Constant 41

3.3 Arithmetic for Fixed-Point Reals 41

3.3.1 Fixed-Point Using a Universal 16.16 Format 44

3.3.2 Fixed-Point Using a Universal 32.32 Format 45

3.3.3 Multiplication of 32.32 Fixed-Point Reals 46

3.3.4 Example: Multiplying two 4.4 Fixed-Point Reals 49

Problems 50

Chapter 4 Getting the Most out of C 52

4.1 Integer Data Types 52

4.1.1 Integer Range and the Standard Header File LIMITS.H 54

4.2 Boolean Data Types 56

4.3 Mixing Data Types 57

4.4 Manipulating Bits In Memory 58

4.4.1 Testing Bits 60

4.4.2 Setting, Clearing, and Inverting Bits 61

4.4.3 Extracting Bits 62

4.4.4 Inserting Bits 62

4.5 Manipulating Bits In Input/Output Ports 63

4.5.1 Write-Only I/O Devices 63

4.5.2 I/O Devices Differentiated by Reads Versus Writes 65

4.5.3 I/O Devices Differentiated by Sequential Access 65

4.5.4 I/O Devices Differentiated by Bits in the Written Data 66

4.6 Accessing Memory-Mapped I/O Devices 66

4.6.1 Accessing Data Using a Pointer 67

4.6.2 Arrays, Pointers, and the "Address of" Operator 68

4.7 Structures 69

4.7.1 Packed Structures 70

4.7.2 Bit Fields 71

4.8 Variant Access 72

4.8.1 Casting the Address of an Object 73

4.8.2 Using Unions 74

Problems 75

Chapter 5 Programming in Assembly Part 1: Computer Organization 80

5.1 Memory 82

5.1.1 Data Alignment 83

5.2 The Central Processing Unit (CPU) 85

5.2.1 Other Registers 86

5.2.2 The Fetch-Execute Cycle 86

5.3 Input/Output 89

5.4 Introduction to the ARM® Cortex™-M3 v7M Architecture 90

5.4.1 Internal Organization 90

5.4.2 Instruction Pipelining 91

5.4.3 Memory Model 93

5.4.4 Bit-Banding 93

5.5 ARM Assembly Language 96

5.5.1 Instruction Formats and Operands 96

5.5.2 Translating Assembly into Binary 98

Problems 98

Chapter 6 Programming in Assembly Part 2: Data Manipulation 102

6.1 Loading Constants into Registers 102

6.2 Loading Memory Data into Registers 103

6.3 Storing Data from Registers to Memory 105

6.4 Converting Simple C Assignment Statements into ARM Assembly 106

6.5 Memory Address Calculations 107

6.6 Memory Addressing Examples 108

6.6.1 Translating C Pointer Expressions to Assembly 109

6.6.2 Translating C Subscript Expressions to Assembly 111

6.6.3 Translating Structure References to Assembly 111

6.7 Stack Instructions 112

6.8 Data Processing Instructions 113

6.8.1 Updating the Flags in the APSR 113

6.8.2 Arithmetic Instructions 114

6.8.3 Bit Manipulation Instructions 115

6.8.4 Shift Instructions 116

6.8.5 Bit Field Manipulation Instructions 118

6.8.6 Miscellaneous Bit, Byte, and Half-Word Instructions 119

Problems 120

Chapter 7 Programming in Assembly Part 3: Control Structures 123

7.1 Instruction Sequencing 123

7.2 Implementing Decisions 124

7.2.1 Conditional Branch Instructions 124

7.2.2 If-Then and If-Then-Else Statements 125

7.2.3 Compound Conditionals 126

7.2.4 The "If-Then" (IT) Instruction 128

7.3 Implementing Loops 129

7.3.1 Speeding Up Array Access 131

7.4 Implementing Functions 132

7.4.1 Function Call and Return 132

7.4.2 Register Usage 133

7.4.3 Parameter Passing 134

7.4.4 Return Values 135

7.4.5 Temporary Variables 135

7.4.6 Preserving Registers 136

Problems 138

Chapter 8 Programming in Assembly Part 4: I/O Programming 140

8.1 The Cortex-M3 I/O Hardware 141

8.1.1 Interrupts and Exceptions 141

8.1.2 Thread and Handler Modes 142

8.1.3 Entering the Exception Handler 142

8.1.4 Returning from the Exception Handler 143

8.1.5 Latency Reduction 143

8.1.6 Priorities and Nested Exceptions 145

8.2 Synchronization, Transfer Rate, and Latency 146

8.3 Buffers and Queues 147

8.3.1 Double Buffering 149

8.4 Estimating I/O Performance Capability 150

8.4.1 Polled Waiting Loops 150

8.4.2 Interrupt-Driven I/O 152

8.4.3 Direct Memory Access 154

8.4.4 Comparison of Methods 155

Problems 156

Chapter 9 Concurrent Software 159

9.1 Foreground/Background Systems 159

9.1.1 Thread State and Serialization 159

9.1.2 Managing Latency 160

9.1.3 Interrupt Overrun 163

9.1.4 Moving Work into the Background 163

9.2 Multithreaded Programming 164

9.2.1 Concurrent Execution of Independent Threads 265

9.2.2 Context Switching 165

9.2.3 Non-preemptive (Cooperative) Multithreading 165

9.2.4 Preemptive Multithreading 267

9.3 Shared Resources and Critical Sections 167

9.3.1 Disabling Interrupts 269

9.3.2 Disabling Task Switching 169

9.3.3 Spin Locks 170

9.3.4 Mutex Objects 270

9.3.5 Semaphores 272

Problems 272

Chapter 10 Scheduling 174

10.1 Thread States 174

10.2 Pending Threads 175

10.3 Context Switching 176

10.4 Round-Robin Scheduling 178

10.5 Priority-Based Scheduling 178

10.5.1 Resource Starvation 178

10.5.2 Priority Inversion 179

10.5.3 The Priority Ceiling Protocol 180

10.5.4 The Priority Inheritance Protocol 180

10.6 Assigning Priorities 181

10.6.1 Deadline-Driven Scheduling 181

10.6.2 Rate-Monotonic Scheduling 182

10.7 Deadlock 183

10.8 Watchdog Timers 184

Problems 186

Chapter 11 Memory Management 189

11.1 Objects in C 189

11.2 Scope 190

11.2.1 Refining Local Scope 190

11.2.2 Refining Global Scope 191

11.3 Lifetime 192

11.4 Automatic Allocation 193

11.4.1 Storage Class "Register" 194

11.5 Static Allocation 195

11.6 Three Programs to Distinguish Static from Automatic 196

11.6.1 Object Creation 196

11.6.2 Object Initialization 196

11.6.3 Object Destruction 197

11.7 Dynamic Allocation 199

11.7.1 Fragmentation 199

11.7.2 Memory Allocation Pools 200

11.8 Automatic Allocation with Variable Size (alloca) 200

11.8.1 Variable-Size Arrays 201

11.9 Recursive Functions and Memory Allocation 202

Problems 203

Chapter 12 Shared Memory 209

12.1 Recognizing Shared Objects 209

12.1.1 Shared Global Data 210

12.1.2 Shared Private Data 210

12.1.3 Shared Functions 210

12.2 Reentrant Functions 220

12.3 Read-Only Data 211

12.3.1 Type Qualifier "const" 211

12.4 Coding Practices to Avoid 212

12.4.1 Functions That Keep Internal State in Local Static Objects 212

12.4.2 Functions That Return the Address of a Local Static Object 214

12.5 Accessing Shared Memory 215

12.5.1 The Effect of Processor Architecture 217

12.5.2 Read-Only and Write-Only Access 218

12.5.3 Type Qualifier "volatile" 219

Problems 221

Chapter 13 System Initialization 224

13.1 Memory Layout 224

13.2 The CPU and Vector Table 225

13.3 C Run-Time Environment 227

13.3.1 Copying Initial Values from Non-Volatile Memory into the Data Region 227

13.3.2 Zeroing Uninitialized Statics 227

13.3.3 Setting Up a Heap 228

13.4 System Timer 229

13.5 Other Peripheral Devices 229

Answers to Selected Problems 231

Index 234

From the B&N Reads Blog

Customer Reviews