Suchen und Finden
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
7.3 The Large 8051 Family
216
7.3.1 8051 Development Tools
216
7.3.2 Silicon Laboratories Family
217
7.3.3 Atmel Family
217
7.3.4 Maxim (i.e. Dallas) Family
217
7.4 PIC Microcontrollers
219
7.4.1 PIC Development Tools
220
7.5 Rabbit Microprocessors
221
7.5.1 Rabbit Development Tools
222
7.6 Atmel AVR Microcontrollers
223
7.6.1 AVR 8-bit MCU
223
7.6.2 AVR 8-bit Development Tools
225
7.6.3 AVR 32-bit MCU
225
7.6.4 AVR 32-bit Development Tools
226
7.7 ARM Microprocessors
227
7.8 ColdFire Microprocessors (and Microcontrollers)
227
7.8.1 ColdFire Development Tools
228
7.9 Basic Stamp
229
7.9.1 Basic Stamp Development Tools
230
7.10 Review Questions
231
7.11 Exercises
231
8 Ethernet Applications and the Future of the Microcontroller
232
8.1 Objectives
232
8.2 Introduction
232
8.3 Introduction to TCP/IP
233
8.3.1 Link Layer
234
8.3.2 Internet Layer
234
8.3.3 Transport Layer
235
8.3.4 Application Layer
235
8.4 Circuit Cellar"672-.4 Project
236
8.4.1 The Role of the Ethernet Controller
236
8.4.2 The Role of the 8051
237
8.4.3 Code Organization
238
8.5 Silicon Labs Ethernet Development Kit
239
8.5.1 Stage 1: Setup the Hardware
240
8.5.2 Stage 2: Setup the Software and Checkout the Hardware
240
8.5.3 Stage 3: Creating an Embedded Ethernet Application using the Wizard
243
8.5.4 Stage 4: The uWeb Embedded Web Server
254
8.6 The Future of the Microcontroller
255
8.6.1 Dominant Market Share
256
8.6.2 Networking, Networking, Networking
257
8.6.3 New Applications and Role Blurring
257
8.6.4 Better and Cheaper Development Tools
257
8.6.5 Roll your Own Chips
257
8.7 Review Questions
258
8.7.1 Key to the review questions:
258
8.8 Exercises
259
8.8.1 Note: The ETHERNETDK kit is needed for these exercises.
259
9 Hands-On Labs
260
9.1 Lab 1: Getting Started with The 8051 – Reading and Writing Ports
261
9.2 Lab 2: Intro to the 7-segment LED (Direct Driven and Decoded)
267
9.3 Lab 3: Intro to A/D Conversion Using a Light Sensor
275
9.4 Lab 4: Intro to the Keypad
285
9.5 Lab 5: Intro to D/A Conversion Using a Speaker
293
9.6 Lab 6: 3-Wire RS232 Serial Communication
304
9.7 Lab 7: Intro to the LCD Display
312
9.8 Lab 8: Advanced RS232 Communications (Handshaking)
323
A C programming Primer
335
A.1 Overview
335
A.2 Data Types in C
336
A.2.1 Primitive Data Types
336
A.2.2 Enumerated Type
337
A.2.3 Pointer Type
338
A.2.4 Arrays
338
A.2.5 Char and Strings
340
A.2.6 Structures and Unions
341
A.2.7 User Defined Type with typedef
342
A.2.8 Variable Scope Specifiers
343
A.3 Operators
343
A.3.1 Arithmetic and Shift Operators
343
A.3.2 Bitwise Operators
344
A.3.3 Relational Operators
344
A.3.4 Logical Operators
345
A.4 Functions
345
A.4.1 Function Definition
345
A.4.2 Function Parameters
347
A.5 Control Structures
348
A.5.1 Selection Statements
349
A.5.2 Loop Statements
351
A.5.3 break and continue Statement in a Loop
355
A.5.4 goto Statements
356
A.6 Reserved Keywords
356
A.7 Command-line Arguments
357
B Getting Started with The Keil mVision IDE
358
B.1 Introduction to the Keil mVision IDE
358
B.2 Run a Keil mVision IDE Project
358
B.3 Build your First Keil Project
361
C Getting Started with Silicon Laboratories C8051F005DK Development
370
D Counter with 7-Segment Numeric Display
380
D.1 Overview
380
D.2 Equipment
381
D.3 Schematic
382
D.4 Building the Circuit
382
D.5 Code
383
References
387
Index
390
Alle Preise verstehen sich inklusive der gesetzlichen MwSt.