| Embedded Software Development with C | 2 |
---|
| 1 Introduction to Embedded Systems | 14 |
| 1.1 Overview | 14 |
| 1.2 Categories of Embedded Systems | 15 |
| 1.3 Application Areas of Embedded Systems | 17 |
| 1.4 Characteristics of Embedded systems | 17 |
| 1.5 Hardware Overview | 19 |
| 1.5.1 Overall Architecture | 19 |
| 1.5.2 Memory | 22 |
| 1.5.3 Bus | 24 |
| 1.5.4 I/O Ports | 25 |
| 1.5.5 Clock Oscillator, Timer and Watchdog | 27 |
| 1.5.6 Analog to Digital Converter (ADC) and DAC | 28 |
| 1.6 Embedded Software Design and Development | 28 |
| 1.6.1 Software Engineering Life cycle | 29 |
| 1.6.2 Choose RTOS and Programming Language | 30 |
| 1.7 Practice Labs | 32 |
| 1.7.1 Getting Started with the Keil mVision3 C51 Development Kit | 32 |
| 1.7.2 Lab with 8051 Microcontroller Development Kit | 40 |
| 1.8 Summary | 48 |
| 1.9 Review questions | 49 |
| 1.10 Exercises | 50 |
| References | 50 |
| 2 Embedded Software Design and Development | 51 |
| 2.1 Overview | 51 |
| 2.2 Software Requirement Specification | 53 |
| 2.3 Embedded Software Modeling Analysis and Design | 54 |
| 2.3.1 Context Diagram | 54 |
| 2.3.2 Finite State Machine (FSM) and State Chart | 54 |
| 2.4 Time Requirement Analysis for Real-Time Systems | 61 |
| 2.4.1 Non-Preemptive Scheduling | 63 |
| 2.4.2 Pre-emptive Scheduling | 64 |
| 2.4.3 RMS | 65 |
| 2.4.4 Dynamic scheduling with EDF | 67 |
| 2.5 Multi-Tasking Design Methodology | 68 |
| 2.5.1 Polling | 69 |
| 2.5.2 Interrupts | 70 |
| 2.5.3 RTOS | 72 |
| 2.6 Software Design Issues | 74 |
| 2.6.1 Task Interactions | 74 |
| 2.6.2 Resource Sharing | 75 |
| 2.7 Lab Practice: A Traffic Light Control System Modelingand Design | 78 |
| 2.8 Summary | 80 |
| 2.9 Review Questions | 81 |
| 2.10 Exercises | 82 |
| References | 83 |
| 3 8051 Microcontroller | 84 |
| 3.1 Overview | 84 |
| 3.1.1 8051 Chip Pins | 85 |
| 3.1.2 System Clock and Oscillator Circuits | 86 |
| 3.1.3 8051 Internal Architecture | 87 |
| 3.2 Ports | 89 |
| 3.2.1 Port Reading and Writing | 89 |
| 3.2.2 The Port Alternate Functions | 90 |
| 3.3 Memory and SFR | 91 |
| 3.3.1 Memory | 91 |
| 3.3.2 Special Function Registers (SFRs) | 93 |
| 3.4 SFRs and Interrupts | 101 |
| 3.4.1 External Interrupts | 102 |
| 3.4.2 Timer/Counter Interrupts | 103 |
| 3.4.3 Serial Interrupts | 103 |
| 3.5 Summary | 105 |
| 3.6 Review Questions | 105 |
| 3.7 Exercises | 107 |
| References | 107 |
| 4 Embedded C Programming with 8051 | 108 |
| 4.1 Overview | 108 |
| 4.2 Memory in 8051 C Programming | 109 |
| 4.2.1 8051 Memory Types | 109 |
| 4.2.2 Memory Models | 110 |
| 4.3 Data Types of 8051 C | 111 |
| 4.4 Functions | 115 |
| 4.4.1 Interrupt Functions | 115 |
| 4.4.2 Reentrant Functions | 120 |
| 4.4.3 Real Time Function | 122 |
| 4.5 Pointers | 122 |
| 4.6 Mix C and Assembly Code | 123 |
| 4.7 Modular Programming in C | 124 |
| 4.7.1 Scope of Functions and Variables | 125 |
| 4.7.2 Header Files | 127 |
| 4.7.3 Multi-module C Programming | 127 |
| 4.8 Lab: Debug and Test Embedded C Program with the KeilmVision3 | 131 |
| 4.9 Practice Examples | 137 |
| 4.10 Summary | 144 |
| 4.11 Review Questions | 144 |
| 4.12 Programming Exercises | 146 |
| References | 146 |
| 5 Real-Time Operating Systems | 147 |
| 5.1 Overview | 147 |
| 5.2 RTX51-Tiny | 150 |
| 5.3 Task Scheduling | 152 |
| 5.3.1 Round Robin Multitasking | 152 |
| 5.3.2 Cooperative Multitasking | 155 |
| 5.3.3 Priority-Driven Preemptive Multitasking | 157 |
| 5.4 RTOS Events | 159 |
| 5.4.1 Signal Event Based Communication | 159 |
| 5.4.2 Message Event Based Communication | 159 |
| 5.4.3 Semaphores | 160 |
| 5.4.4 Attaching Interrupts to Tasks | 160 |
| 5.5 When to Use RTOS | 161 |
| 5.6 Practice Labs | 161 |
| 5.7 Summary | 184 |
| 5.8 Review Questions | 184 |
| 5.9 Exercises | 186 |
| References | 188 |
| 6 Serial Communications | 189 |
| 6.1 Introduction | 189 |
| 6.1.1 Serial vs. Parallel | 190 |
| 6.1.2 Simplex and Duplex | 190 |
| 6.2 UARTs and Transceivers | 191 |
| 6.2.1 UART | 191 |
| 6.2.2 Transceivers (aka Line Drivers) | 192 |
| 6.2.3 Asynchronous vs. Synchronous | 192 |
| 6.2.4 Data Transfer Rate | 193 |
| 6.3 Configuring the Serial Port | 194 |
| 6.4 Setting the Baud Rate | 195 |
| 6.5 Reading and Writing | 197 |
| 6.6 Handshaking | 198 |
| 6.6.1 Software Handshaking | 198 |
| 6.6.2 Hardware Handshaking | 198 |
| 6.7 Examples | 200 |
| 6.7.1 Example 1 – Hello World (Using STDIO) | 200 |
| 6.7.2 Example 2 – Hello World (Beyond the Serial Port) | 202 |
| 6.7.3 Example 3 – Interactive Console Using the Serial Port | 206 |
| 6.8 Summary | 210 |
| 6.9 Review Questions | 211 |
| 6.9.1 Key to the Review Questions: | 211 |
| 6.10 Exercises | 212 |
| 7 Survey of Popular Microcontrollers | 213 |
| 7.1 Introduction | 213 |
| 7.2 Features for Comparison | 214 |
| 7.2.1 Packages | 215 |