Preface |
|
xiii | |
Introduction |
|
xxi | |
|
Embedded C Language Tutorial |
|
|
|
|
1 | (1) |
|
|
1 | (1) |
|
|
2 | (2) |
|
|
4 | (7) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
Enumerations and Definitions |
|
|
7 | (2) |
|
|
9 | (1) |
|
|
9 | (1) |
|
|
9 | (1) |
|
|
9 | (1) |
|
|
9 | (2) |
|
|
11 | (1) |
|
Operators and Expressions |
|
|
12 | (7) |
|
Assignment and Arithmetic Operators |
|
|
12 | (1) |
|
|
13 | (1) |
|
Logical and Relational Operators |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
Increment, Decrement, and Compound Assignment |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (1) |
|
Compound Assignment Operators |
|
|
17 | (1) |
|
The Conditional Expression |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
19 | (14) |
|
|
19 | (2) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
23 | (1) |
|
|
23 | (3) |
|
|
26 | (1) |
|
|
26 | (2) |
|
Break, Continue, and Goto |
|
|
28 | (1) |
|
|
28 | (1) |
|
|
28 | (1) |
|
|
29 | (4) |
|
|
33 | (8) |
|
Prototyping and Function Organization |
|
|
34 | (2) |
|
Functions that Return Values |
|
|
36 | (1) |
|
|
37 | (4) |
|
|
41 | (13) |
|
|
41 | (4) |
|
|
45 | (2) |
|
|
47 | (2) |
|
|
49 | (5) |
|
|
54 | (9) |
|
|
54 | (2) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
58 | (2) |
|
|
60 | (1) |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
63 | (6) |
|
|
63 | (2) |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
66 | (3) |
|
|
69 | (11) |
|
|
69 | (3) |
|
|
72 | (3) |
|
|
75 | (5) |
|
Programming Style, Standards, and Guidelines |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
81 | (2) |
|
|
83 | (4) |
|
The Atmel Risc Processors |
|
|
|
|
87 | (1) |
|
|
87 | (1) |
|
|
88 | (1) |
|
|
89 | (8) |
|
|
89 | (1) |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
90 | (2) |
|
|
92 | (2) |
|
|
94 | (3) |
|
Reset and Interrupt Functions |
|
|
97 | (8) |
|
|
98 | (3) |
|
|
101 | (1) |
|
|
102 | (3) |
|
|
105 | (4) |
|
|
109 | (23) |
|
Timer/Counter Prescalers and Input Selectors |
|
|
110 | (1) |
|
|
110 | (4) |
|
|
114 | (1) |
|
Timer 1 Prescaler and Selector |
|
|
115 | (1) |
|
Timer 1 Input Capture Mode |
|
|
115 | (4) |
|
Timer 1 Output Compare Mode |
|
|
119 | (4) |
|
Timer 1 Pulse Width Modulator Mode |
|
|
123 | (5) |
|
|
128 | (1) |
|
One--second recording interval using Timer 0 |
|
|
129 | (1) |
|
Engine rpm measurement using Timer 1 |
|
|
130 | (1) |
|
Drive shaft rpm measurement using Timer 1 |
|
|
131 | (1) |
|
Serial Communication Using the Usart |
|
|
132 | (9) |
|
|
141 | (10) |
|
Analog-to-Digital Background |
|
|
141 | (1) |
|
Analog-to-Digital Converter Peripheral |
|
|
142 | (4) |
|
Analog Comparator Peripheral |
|
|
146 | (3) |
|
Measuring engine temperature using the analog-to-digital converter (ADC) |
|
|
149 | (1) |
|
Sending collected data to the PC |
|
|
150 | (1) |
|
Serial Communication Using the SPI |
|
|
151 | (7) |
|
Serial Communication Using I2C |
|
|
158 | (2) |
|
The AVR Risc Assembly Language Instruction Set |
|
|
160 | (3) |
|
|
163 | (4) |
|
|
167 | (1) |
|
|
168 | (3) |
|
Standard I/O and Preprocessor Functions |
|
|
|
|
171 | (1) |
|
|
171 | (1) |
|
Character Input/Output Functions -- getchar() and putchar() |
|
|
172 | (6) |
|
Standard Output Functions |
|
|
178 | (5) |
|
|
178 | (1) |
|
Put String Flash---putsf() |
|
|
179 | (1) |
|
Print Formatted---printf() |
|
|
180 | (2) |
|
String Print Formatted---sprintf() |
|
|
182 | (1) |
|
|
183 | (5) |
|
|
184 | (1) |
|
|
185 | (2) |
|
Scan String Formatted---sscanf() |
|
|
187 | (1) |
|
|
188 | (13) |
|
|
188 | (1) |
|
|
189 | (2) |
|
The #ifdef, #ifndef, #else, and #endif Directives |
|
|
191 | (5) |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
|
|
199 | (1) |
|
|
199 | (1) |
|
|
199 | (1) |
|
|
200 | (1) |
|
Other Macros and Directives |
|
|
200 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
|
202 | (3) |
|
The Codevisionavr C Compiler and IDE |
|
|
|
|
205 | (1) |
|
|
205 | (1) |
|
|
206 | (10) |
|
|
206 | (1) |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
208 | (1) |
|
|
209 | (1) |
|
|
209 | (1) |
|
Open an Existing Source File |
|
|
209 | (1) |
|
|
209 | (1) |
|
Add an Existing File to the Project |
|
|
209 | (2) |
|
|
211 | (3) |
|
|
214 | (1) |
|
|
214 | (2) |
|
|
216 | (4) |
|
|
217 | (1) |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
218 | (1) |
|
(s)printf Features and (s)scanf Features |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
219 | (1) |
|
|
220 | (1) |
|
Compile and Make Projects |
|
|
220 | (2) |
|
|
220 | (1) |
|
|
221 | (1) |
|
Program the Target Device |
|
|
222 | (7) |
|
|
223 | (1) |
|
|
224 | (2) |
|
|
226 | (1) |
|
|
226 | (1) |
|
Boot Lock Bit 0 and Boot Lock Bit 1 |
|
|
226 | (1) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
227 | (1) |
|
|
227 | (1) |
|
|
228 | (1) |
|
Codewizardavr Code Generator |
|
|
229 | (18) |
|
|
232 | (1) |
|
|
233 | (1) |
|
|
234 | (1) |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (1) |
|
|
239 | (8) |
|
|
247 | (2) |
|
The ATMEL AVR Studio Debugger |
|
|
249 | (4) |
|
Create a COFF File for AVR Studio |
|
|
250 | (1) |
|
Launch AVR Studio from CodeVisionAVR |
|
|
250 | (1) |
|
|
250 | (1) |
|
|
250 | (1) |
|
Set and Clear Breakpoints |
|
|
251 | (1) |
|
View and Modify Registers and Variables |
|
|
252 | (1) |
|
View and Modify the Machine State |
|
|
252 | (1) |
|
|
253 | (1) |
|
|
253 | (2) |
|
|
255 | (2) |
|
|
|
|
257 | (1) |
|
|
257 | (1) |
|
Concept Development Phase |
|
|
257 | (1) |
|
Project Development Process Steps |
|
|
257 | (6) |
|
|
258 | (2) |
|
|
260 | (1) |
|
|
261 | (1) |
|
Build and Test the Prototype Hardware Phase |
|
|
262 | (1) |
|
System Integration and Software Development Phase |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
263 | (1) |
|
Project Development Process Summary |
|
|
263 | (1) |
|
Example Project: A Weather Monitor |
|
|
263 | (86) |
|
|
263 | (1) |
|
|
264 | (2) |
|
|
266 | (1) |
|
Operational Specification |
|
|
266 | (1) |
|
|
267 | (2) |
|
Measurement Considerations for the Design |
|
|
269 | (1) |
|
|
270 | (2) |
|
|
272 | (1) |
|
|
273 | (1) |
|
|
274 | (3) |
|
|
277 | (1) |
|
|
278 | (3) |
|
|
281 | (1) |
|
|
282 | (1) |
|
|
283 | (1) |
|
|
283 | (1) |
|
Hardware Design, Outdoor Unit |
|
|
284 | (1) |
|
|
284 | (2) |
|
|
286 | (1) |
|
|
286 | (1) |
|
|
286 | (1) |
|
Software Design, Outdoor Unit |
|
|
286 | (1) |
|
Hardware Design, Indoor Unit |
|
|
287 | (1) |
|
|
287 | (3) |
|
|
290 | (1) |
|
Software Design, Indoor Unit |
|
|
290 | (2) |
|
|
292 | (1) |
|
|
293 | (1) |
|
|
293 | (1) |
|
|
293 | (1) |
|
|
293 | (1) |
|
|
294 | (1) |
|
|
294 | (1) |
|
System Test for Complete Project |
|
|
294 | (1) |
|
Build and Test Prototype Hardware Phase |
|
|
294 | (1) |
|
|
295 | (2) |
|
|
297 | (4) |
|
System Integration and Software Development Phase, Outdoor Unit |
|
|
301 | (4) |
|
Temperature, Humidity, Wind Direction, and Battery Health |
|
|
305 | (1) |
|
|
305 | (1) |
|
|
306 | (1) |
|
|
306 | (6) |
|
System Integration and Software Development Phase, Indoor Unit |
|
|
312 | (1) |
|
|
312 | (2) |
|
|
314 | (2) |
|
The Buttons and the Beeper |
|
|
316 | (2) |
|
Decoding the RF Telemetry |
|
|
318 | (3) |
|
Collecting and Protecting Rainfall Data |
|
|
321 | (3) |
|
Converting from Counts to Real Units |
|
|
324 | (1) |
|
Routines for Controlling the LCD |
|
|
325 | (6) |
|
Keeping the Display Up to Date |
|
|
331 | (4) |
|
Editing the Time and Date |
|
|
335 | (4) |
|
|
339 | (4) |
|
|
343 | (1) |
|
Picking a Part for a Better Fit |
|
|
343 | (1) |
|
|
344 | (1) |
|
|
344 | (4) |
|
|
348 | (1) |
|
|
349 | (1) |
|
|
350 | (1) |
|
|
350 | (1) |
|
|
351 | (2) |
Appendix A Library Functions Reference |
|
353 | (100) |
Appendix B Getting Started with Codevisionavr and the STK500 |
|
453 | (18) |
Appendix C Programming the AVR Microcontrollers |
|
471 | (4) |
Appendix D Installing and Using TheCableAVR |
|
475 | (14) |
Appendix E The MEGAAVR-DEV Development Board |
|
489 | (4) |
Appendix F ASCII Table |
|
493 | (4) |
Appendix G AVR Instruction Set Summary |
|
497 | (6) |
Appendix H Answers to Selected Exercises |
|
503 | (6) |
Appendix I A ``Fast Start'' to Embedded C Programming and the AVR |
|
509 | (10) |
Index |
|
519 | |