| |
| |
Preface | |
| |
| |
| |
Introduction | |
| |
| |
| |
What is an Embedded System? | |
| |
| |
| |
What Is Unique about the Design Goals for Embedded Software? | |
| |
| |
| |
What Does "Real-Time" Mean? | |
| |
| |
| |
What Does "Multithreading" Mean? | |
| |
| |
| |
How Powerful are Embedded Processors? | |
| |
| |
| |
What Programming Languages are Used? | |
| |
| |
| |
How Is Building an Embedded Application Different? | |
| |
| |
| |
How Big are Typical Embedded Programs? | |
| |
| |
Problems | |
| |
| |
| |
Data Representation | |
| |
| |
| |
Fixed-Precision Binary Numbers | |
| |
| |
| |
Positional Number Systems | |
| |
| |
| |
Binary-to-Decimal Conversion | |
| |
| |
| |
Decimal-to-Binary Conversion | |
| |
| |
| |
Hexadecimal: A Shorthand for Binary | |
| |
| |
| |
Fixed Precision, Rollover, and Overflow | |
| |
| |
| |
Binary Representation of Integers | |
| |
| |
| |
Signed Integers | |
| |
| |
| |
Positive and Negative Representations of the Same Magnitude | |
| |
| |
| |
Interpreting the Value of a 2's-Complement Number | |
| |
| |
| |
Changing the Sign of Numbers with Integer and Fractional Parts | |
| |
| |
| |
Binary Addition and Subtraction | |
| |
| |
| |
Range and Overflow | |
| |
| |
| |
Binary Representation of Real Numbers | |
| |
| |
| |
Floating-Point Real Numbers | |
| |
| |
| |
Fixed-Point Real Numbers | |
| |
| |
| |
ASCII Representation of Text | |
| |
| |
| |
Binary-Coded Decimal (BCD) | |
| |
| |
Problems | |
| |
| |
| |
Implementing Arithmetic | |
| |
| |
| |
2'S-Complement and Hardware Complexity | |
| |
| |
| |
Multiplication and Division | |
| |
| |
| |
Signed Versus Unsigned Multiplication | |
| |
| |
| |
Shifting Instead of Multiplying or Dividing by Powers of 2 | |
| |
| |
| |
Multiplying by an Arbitrary Constant | |
| |
| |
| |
Dividing by an Arbitrary Constant | |
| |
| |
| |
Arithmetic for Fixed-Point Reals | |
| |
| |
| |
Fixed-Point Using a Universal 16.16 Format | |
| |
| |
| |
Fixed-Point Using a Universal 32.32 Format | |
| |
| |
| |
Multiplication of 32.32 Fixed-Point Reals | |
| |
| |
| |
Example: Multiplying two 4.4 Fixed-Point Reals | |
| |
| |
Problems | |
| |
| |
| |
Getting the Most out of C | |
| |
| |
| |
Integer Data Types | |
| |
| |
| |
Integer Range and the Standard Header File LIMITS.H | |
| |
| |
| |
Boolean Data Types | |
| |
| |
| |
Mixing Data Types | |
| |
| |
| |
Manipulating Bits In Memory | |
| |
| |
| |
Testing Bits | |
| |
| |
| |
Setting, Clearing, and Inverting Bits | |
| |
| |
| |
Extracting Bits | |
| |
| |
| |
Inserting Bits | |
| |
| |
| |
Manipulating Bits In Input/Output Ports | |
| |
| |
| |
Write-Only I/O Devices | |
| |
| |
| |
I/O Devices Differentiated by Reads Versus Writes | |
| |
| |
| |
I/O Devices Differentiated by Sequential Access | |
| |
| |
| |
I/O Devices Differentiated by Bits in the Written Data | |
| |
| |
| |
Accessing Memory-Mapped I/O Devices | |
| |
| |
| |
Accessing Data Using a Pointer | |
| |
| |
| |
Arrays, Pointers, and the "Address of" Operator | |
| |
| |
| |
Structures | |
| |
| |
| |
Packed Structures | |
| |
| |
| |
Bit Fields | |
| |
| |
| |
Variant Access | |
| |
| |
| |
Casting the Address of an Object | |
| |
| |
| |
Using Unions | |
| |
| |
Problems | |
| |
| |
| |
Programming in Assembly Part 1: Computer Organization | |
| |
| |
| |
Memory | |
| |
| |
| |
Data Alignment | |
| |
| |
| |
The Central Processing Unit (CPU) | |
| |
| |
| |
Other Registers | |
| |
| |
| |
The Fetch-Execute Cycle | |
| |
| |
| |
Input/Output | |
| |
| |
| |
Introduction to the ARM� Cortex™-M3 v7M Architecture | |
| |
| |
| |
Internal Organization | |
| |
| |
| |
Instruction Pipelining | |
| |
| |
| |
Memory Model | |
| |
| |
| |
Bit-Banding | |
| |
| |
| |
ARM Assembly Language | |
| |
| |
| |
Instruction Formats and Operands | |
| |
| |
| |
Translating Assembly into Binary | |
| |
| |
Problems | |
| |
| |
| |
Programming in Assembly Part 2: Data Manipulation | |
| |
| |
| |
Loading Constants into Registers | |
| |
| |
| |
Loading Memory Data into Registers | |
| |
| |
| |
Storing Data from Registers to Memory | |
| |
| |
| |
Converting Simple C Assignment Statements into ARM Assembly | |
| |
| |
| |
Memory Address Calculations | |
| |
| |
| |
Memory Addressing Examples | |
| |
| |
| |
Translating C Pointer Expressions to Assembly | |
| |
| |
| |
Translating C Subscript Expressions to Assembly | |
| |
| |
| |
Translating Structure References to Assembly | |
| |
| |
| |
Stack Instructions | |
| |
| |
| |
Data Processing Instructions | |
| |
| |
| |
Updating the Flags in the APSR | |
| |
| |
| |
Arithmetic Instructions | |
| |
| |
| |
Bit Manipulation Instructions | |
| |
| |
| |
Shift Instructions | |
| |
| |
| |
Bit Field Manipulation Instructions | |
| |
| |
| |
Miscellaneous Bit, Byte, and Half-Word Instructions | |
| |
| |
Problems | |
| |
| |
| |
Programming in Assembly Part 3: Control Structures | |
| |
| |
| |
Instruction Sequencing | |
| |
| |
| |
Implementing Decisions | |
| |
| |
| |
Conditional Branch Instructions | |
| |
| |
| |
If-Then and If-Then-Else Statements | |
| |
| |
| |
Compound Conditionals | |
| |
| |
| |
The "If-Then" (IT) Instruction | |
| |
| |
| |
Implementing Loops | |
| |
| |
| |
Speeding Up Array Access | |
| |
| |
| |
Implementing Functions | |
| |
| |
| |
Function Call and Return | |
| |
| |
| |
Register Usage | |
| |
| |
| |
Parameter Passing | |
| |
| |
| |
Return Values | |
| |
| |
| |
Temporary Variables | |
| |
| |
| |
Preserving Registers | |
| |
| |
Problems | |
| |
| |
| |
Programming in Assembly Part 4: I/O Programming | |
| |
| |
| |
The Cortex-M3 I/O Hardware | |
| |
| |
| |
Interrupts and Exceptions | |
| |
| |
| |
Thread and Handler Modes | |
| |
| |
| |
Entering the Exception Handler | |
| |
| |
| |
Returning from the Exception Handler | |
| |
| |
| |
Latency Reduction | |
| |
| |
| |
Priorities and Nested Exceptions | |
| |
| |
| |
Synchronization, Transfer Rate, and Latency | |
| |
| |
| |
Buffers and Queues | |
| |
| |
| |
Double Buffering | |
| |
| |
| |
Estimating I/O Performance Capability | |
| |
| |
| |
Polled Waiting Loops | |
| |
| |
| |
Interrupt-Driven I/O | |
| |
| |
| |
Direct Memory Access | |
| |
| |
| |
Comparison of Methods | |
| |
| |
Problems | |
| |
| |
| |
Concurrent Software | |
| |
| |
| |
Foreground/Background Systems | |
| |
| |
| |
Thread State and Serialization | |
| |
| |
| |
Managing Latency | |
| |
| |
| |
Interrupt Overrun | |
| |
| |
| |
Moving Work into the Background | |
| |
| |
| |
Multithreaded Programming | |
| |
| |
| |
Concurrent Execution of Independent Threads | |
| |
| |
| |
Context Switching | |
| |
| |
| |
Non-preemptive (Cooperative) Multithreading | |
| |
| |
| |
Preemptive Multithreading | |
| |
| |
| |
Shared Resources and Critical Sections | |
| |
| |
| |
Disabling Interrupts | |
| |
| |
| |
Disabling Task Switching | |
| |
| |
| |
Spin Locks | |
| |
| |
| |
Mutex Objects | |
| |
| |
| |
Semaphores | |
| |
| |
Problems | |
| |
| |
| |
Scheduling | |
| |
| |
| |
Thread States | |
| |
| |
| |
Pending Threads | |
| |
| |
| |
Context Switching | |
| |
| |
| |
Round-Robin Scheduling | |
| |
| |
| |
Priority-Based Scheduling | |
| |
| |
| |
Resource Starvation | |
| |
| |
| |
Priority Inversion | |
| |
| |
| |
The Priority Ceiling Protocol | |
| |
| |
| |
The Priority Inheritance Protocol | |
| |
| |
| |
Assigning Priorities | |
| |
| |
| |
Deadline-Driven Scheduling | |
| |
| |
| |
Rate-Monotonic Scheduling | |
| |
| |
| |
Deadlock | |
| |
| |
| |
Watchdog Timers | |
| |
| |
Problems | |
| |
| |
| |
Memory Management | |
| |
| |
| |
Objects in C | |
| |
| |
| |
Scope | |
| |
| |
| |
Refining Local Scope | |
| |
| |
| |
Refining Global Scope | |
| |
| |
| |
Lifetime | |
| |
| |
| |
Automatic Allocation | |
| |
| |
| |
Storage Class "Register" | |
| |
| |
| |
Static Allocation | |
| |
| |
| |
Three Programs to Distinguish Static from Automatic | |
| |
| |
| |
Object Creation | |
| |
| |
| |
Object Initialization | |
| |
| |
| |
Object Destruction | |
| |
| |
| |
Dynamic Allocation | |
| |
| |
| |
Fragmentation | |
| |
| |
| |
Memory Allocation Pools | |
| |
| |
| |
Automatic Allocation with Variable Size (alloca) | |
| |
| |
| |
Variable-Size Arrays | |
| |
| |
| |
Recursive Functions and Memory Allocation | |
| |
| |
Problems | |
| |
| |
| |
Shared Memory | |
| |
| |
| |
Recognizing Shared Objects | |
| |
| |
| |
Shared Global Data | |
| |
| |
| |
Shared Private Data | |
| |
| |
| |
Shared Functions | |
| |
| |
| |
Reentrant Functions | |
| |
| |
| |
Read-Only Data | |
| |
| |
| |
Type Qualifier "const" | |
| |
| |
| |
Coding Practices to Avoid | |
| |
| |
| |
Functions That Keep Internal State in Local Static Objects | |
| |
| |
| |
Functions That Return the Address of a Local Static Object | |
| |
| |
| |
Accessing Shared Memory | |
| |
| |
| |
The Effect of Processor Architecture | |
| |
| |
| |
Read-Only and Write-Only Access | |
| |
| |
| |
Type Qualifier "volatile" | |
| |
| |
Problems | |
| |
| |
| |
System Initialization | |
| |
| |
| |
Memory Layout | |
| |
| |
| |
The CPU and Vector Table | |
| |
| |
| |
C Run-Time Environment | |
| |
| |
| |
Copying Initial Values from Non-Volatile Memory into the Data Region | |
| |
| |
| |
Zeroing Uninitialized Statics | |
| |
| |
| |
Setting Up a Heap | |
| |
| |
| |
System Timer | |
| |
| |
| |
Other Peripheral Devices | |
| |
| |
Answers to Selected Problems | |
| |
| |
Index | |