Acknowledgments |
|
xxi | |
Author |
|
xxiii | |
Introduction |
|
xxv | |
|
Chapter 1 Computer Systems |
|
|
1 | (26) |
|
Basic Processor Architecture |
|
|
1 | (1) |
|
Components Of A Computer System |
|
|
2 | (3) |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
4 | (1) |
|
Classification Of Processors |
|
|
5 | (2) |
|
|
5 | (1) |
|
|
5 | (2) |
|
|
7 | (1) |
|
|
7 | (9) |
|
|
8 | (2) |
|
Binary, Octal, Hexadecimal, Decimal |
|
|
10 | (2) |
|
|
12 | (2) |
|
Repeated Division Algorithm |
|
|
14 | (1) |
|
Polynomial Evaluation Algorithm |
|
|
14 | (1) |
|
|
14 | (2) |
|
|
16 | (7) |
|
|
17 | (1) |
|
Applications of Boolean Operations |
|
|
18 | (2) |
|
|
20 | (1) |
|
|
20 | (1) |
|
|
21 | (1) |
|
Shifting and Rotating Bits |
|
|
22 | (1) |
|
|
23 | (4) |
|
Chapter 2 The Atmel AVR Microcontroller Family |
|
|
27 | (46) |
|
|
27 | (3) |
|
|
28 | (1) |
|
|
28 | (1) |
|
|
29 | (1) |
|
Machine Language For The Avr Microcontroller |
|
|
30 | (12) |
|
|
30 | (1) |
|
|
31 | (3) |
|
|
34 | (2) |
|
|
36 | (1) |
|
|
37 | (2) |
|
|
39 | (3) |
|
|
42 | (8) |
|
|
42 | (1) |
|
|
43 | (1) |
|
|
43 | (1) |
|
|
44 | (4) |
|
|
48 | (2) |
|
AVR Development Platforms |
|
|
50 | (3) |
|
|
50 | (2) |
|
The Atavrxplain Demonstration Kit |
|
|
52 | (1) |
|
Introduction To AVR Assembly Language |
|
|
53 | (2) |
|
Assembly Language Source Files |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
54 | (1) |
|
Sample AVR Assembly Language Program |
|
|
55 | (11) |
|
|
56 | (1) |
|
Explanation of the Statements |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
58 | (1) |
|
|
59 | (1) |
|
|
59 | (1) |
|
Downloading to the AVR Processor |
|
|
60 | (4) |
|
Adjusting the Clock Speed |
|
|
64 | (2) |
|
|
66 | (2) |
|
|
68 | (1) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
69 | (4) |
|
|
69 | (4) |
|
Chapter 3 Assembly Language |
|
|
73 | (36) |
|
|
75 | (4) |
|
The Assembler's Location Counters |
|
|
75 | (4) |
|
|
79 | (3) |
|
|
80 | (2) |
|
Data Definition Directives |
|
|
82 | (5) |
|
Operators Used In Expressions |
|
|
83 | (3) |
|
Functions Used In Expressions |
|
|
86 | (1) |
|
|
87 | (3) |
|
Zero-Operand Instructions |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
90 | (1) |
|
The Toggler Program: Sample I/O |
|
|
90 | (9) |
|
Avr Digital I/O Ports And Stk-500/Xplain Leds |
|
|
92 | (2) |
|
Avr Digital I/O Ports And Stk-500/Xplain Pushbuttons |
|
|
94 | (1) |
|
|
95 | (4) |
|
|
99 | (3) |
|
|
102 | (1) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
103 | (6) |
|
|
103 | (3) |
|
|
106 | (3) |
|
Chapter 4 Integer Data Representation |
|
|
109 | (36) |
|
|
109 | (6) |
|
|
115 | (1) |
|
|
116 | (7) |
|
|
116 | (5) |
|
|
121 | (1) |
|
|
121 | (1) |
|
|
122 | (1) |
|
|
123 | (1) |
|
|
124 | (4) |
|
Define Byte, Word, And Others |
|
|
124 | (1) |
|
|
125 | (3) |
|
|
128 | (7) |
|
|
128 | (2) |
|
|
130 | (2) |
|
|
132 | (2) |
|
|
134 | (1) |
|
|
135 | (2) |
|
|
137 | (5) |
|
|
142 | (3) |
|
Chapter 5 Avr Core: Startup, Reset, And Memories |
|
|
145 | (44) |
|
|
147 | (3) |
|
|
148 | (2) |
|
Basic System Organization |
|
|
150 | (4) |
|
|
150 | (1) |
|
General Purpose Registers |
|
|
150 | (1) |
|
I/O Registers And Data Space |
|
|
150 | (1) |
|
|
151 | (3) |
|
|
154 | (1) |
|
|
154 | (4) |
|
Program Indirect Addressing |
|
|
154 | (4) |
|
|
158 | (5) |
|
|
158 | (2) |
|
|
160 | (1) |
|
|
160 | (1) |
|
Data Indirect Addressing With Postincrement Or Predecrement |
|
|
161 | (1) |
|
Data Indirect Addressing With Displacement |
|
|
162 | (1) |
|
|
163 | (10) |
|
The Standard Include File |
|
|
166 | (1) |
|
|
167 | (1) |
|
|
167 | (1) |
|
Using EEPROM Data In The Avr Simulator |
|
|
168 | (3) |
|
Downloading EEPROM Data To The Microcontroller |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
173 | (3) |
|
|
176 | (1) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
177 | (12) |
|
Program 5.1A: Led Patterns |
|
|
177 | (3) |
|
The Standard Include File |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
182 | (1) |
|
Using EEPROM Data In The Avr Simulator 2 |
|
|
183 | (1) |
|
|
184 | (1) |
|
|
185 | (4) |
|
Chapter 6 The Stack And Function Calls |
|
|
189 | (52) |
|
|
189 | (2) |
|
|
190 | (1) |
|
|
190 | (1) |
|
|
191 | (5) |
|
|
192 | (1) |
|
Function Call Instructions |
|
|
193 | (2) |
|
Return Address And Ret Instructions |
|
|
195 | (1) |
|
Arguments, Parameters, And Return Values |
|
|
196 | (1) |
|
|
196 | (15) |
|
Arguments And Parameters: Call By Value/Call By Reference |
|
|
199 | (1) |
|
Memory Allocation For Parameters |
|
|
200 | (1) |
|
|
201 | (3) |
|
|
204 | (3) |
|
|
207 | (4) |
|
|
211 | (13) |
|
Parameter And Local Storage Access In Stack Frames |
|
|
215 | (1) |
|
Fibonacci Numbers Example |
|
|
215 | (3) |
|
Stack Frame Naming Conventions |
|
|
218 | (1) |
|
Function Fibonacci Continued |
|
|
219 | (2) |
|
Stack Cleanup: Automatic Parameter Removal |
|
|
221 | (1) |
|
|
222 | (2) |
|
Auxiliary Data Stack (Software Stack) |
|
|
224 | (6) |
|
Macros For The Data Stack |
|
|
226 | (2) |
|
Fibonacci With Data Stack |
|
|
228 | (2) |
|
Call By Reference Example |
|
|
230 | (3) |
|
|
233 | (5) |
|
|
238 | (3) |
|
Chapter 7 Serial Communications Using The Universal Synchronous And Asynchronous Serial Receiver And Transmitter |
|
|
241 | (34) |
|
|
241 | (2) |
|
Serial Communication Basics |
|
|
243 | (3) |
|
|
244 | (1) |
|
|
244 | (2) |
|
|
246 | (9) |
|
|
246 | (2) |
|
Data, Parity, And Stop Bits |
|
|
248 | (3) |
|
|
251 | (2) |
|
|
253 | (1) |
|
|
254 | (1) |
|
AVR Usart Transmit And Receive |
|
|
255 | (5) |
|
Enabling The Transmitter And Receiver |
|
|
255 | (1) |
|
|
256 | (3) |
|
|
259 | (1) |
|
Disabling The Transmitter Or Receiver |
|
|
259 | (1) |
|
Serial Transmission Errors |
|
|
260 | (2) |
|
|
260 | (2) |
|
|
262 | (1) |
|
Serial Communications Example |
|
|
262 | (4) |
|
|
266 | (1) |
|
|
266 | (2) |
|
|
268 | (2) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
270 | (5) |
|
|
270 | (5) |
|
Chapter 8 Logical Operations |
|
|
275 | (30) |
|
Bitwise Logical Operations |
|
|
275 | (3) |
|
|
276 | (2) |
|
Uses Of Logical Instructions |
|
|
278 | (4) |
|
Clearing, Setting, And Toggling |
|
|
280 | (1) |
|
|
281 | (1) |
|
|
282 | (5) |
|
|
284 | (1) |
|
Other Applications Of Shift And Rotate |
|
|
285 | (2) |
|
Special Bitwise Operations |
|
|
287 | (1) |
|
|
288 | (7) |
|
Timer/Counter 1 Configuration: Atmega16A |
|
|
289 | (1) |
|
Timer/Counter 1 Compare Match (Atmega16A) |
|
|
290 | (2) |
|
Timer/Counter Configuration: Atxmegal28A1 |
|
|
292 | (1) |
|
Timer/Counter Period: Atxmega128A1 |
|
|
293 | (2) |
|
Timer/Counter Example: Led Blinker |
|
|
295 | (2) |
|
|
297 | (2) |
|
|
299 | (2) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
301 | (4) |
|
|
301 | (4) |
|
Chapter 9 Control Structures |
|
|
305 | (50) |
|
Altering The Flow Of Control |
|
|
306 | (2) |
|
|
306 | (1) |
|
|
307 | (1) |
|
|
307 | (1) |
|
Jump And Conditional Branch Instructions |
|
|
308 | (3) |
|
|
310 | (1) |
|
Conditional Skip Instructions |
|
|
311 | (1) |
|
|
311 | (9) |
|
|
312 | (1) |
|
|
312 | (6) |
|
Multiway Selection Structure |
|
|
318 | (1) |
|
|
319 | (1) |
|
|
320 | (6) |
|
|
321 | (5) |
|
Pseudocode Development: A Checksum Program |
|
|
326 | (12) |
|
|
338 | (4) |
|
|
342 | (2) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
344 | (11) |
|
|
355 | (56) |
|
|
355 | (7) |
|
|
357 | (1) |
|
|
358 | (2) |
|
|
360 | (1) |
|
|
361 | (1) |
|
General External Interrupts |
|
|
362 | (6) |
|
External Interrupt Behavior |
|
|
363 | (1) |
|
External Interrupt Control Registers (Atmega16A) |
|
|
364 | (2) |
|
External Interrupt Control Registers (Xmega Series) |
|
|
366 | (1) |
|
Other External Interrupts |
|
|
367 | (1) |
|
Interrupt-Controlled Up/Down Counter |
|
|
368 | (4) |
|
|
372 | (5) |
|
AVR Timer/Counters Interrupts |
|
|
373 | (3) |
|
|
376 | (1) |
|
Interrupt-Based Switch Bounce Elimination |
|
|
377 | (8) |
|
|
385 | (7) |
|
|
392 | (3) |
|
|
395 | (3) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
398 | (13) |
|
Chapter 11 Arithmetic Operations |
|
|
411 | (66) |
|
|
411 | (7) |
|
|
411 | (1) |
|
|
412 | (1) |
|
|
412 | (2) |
|
Example: An 8-Bit Ripple Carry Addition |
|
|
414 | (2) |
|
|
416 | (1) |
|
|
416 | (1) |
|
|
417 | (1) |
|
Subtraction Using Addition |
|
|
418 | (1) |
|
AVR Addition And Subtraction |
|
|
418 | (11) |
|
16-Bit Addition And Subtraction |
|
|
419 | (2) |
|
|
421 | (2) |
|
|
423 | (1) |
|
|
424 | (1) |
|
|
425 | (3) |
|
|
428 | (1) |
|
Widening And Narrowing Conversions |
|
|
429 | (1) |
|
BCD Addition And Subtraction |
|
|
429 | (2) |
|
|
431 | (2) |
|
Multiplication And Division |
|
|
433 | (10) |
|
|
433 | (1) |
|
Extended Precision Multiplication |
|
|
434 | (2) |
|
|
436 | (3) |
|
|
439 | (4) |
|
Numeric I/O And Type Conversions |
|
|
443 | (3) |
|
|
443 | (2) |
|
|
445 | (1) |
|
|
446 | (13) |
|
|
459 | (3) |
|
|
462 | (2) |
|
Alternate Programs For The Xplain Demonstration Kit |
|
|
464 | (13) |
|
|
477 | (40) |
|
Declaring And Using Arrays |
|
|
477 | (3) |
|
|
478 | (1) |
|
|
479 | (1) |
|
|
480 | (5) |
|
|
483 | (2) |
|
|
485 | (3) |
|
|
485 | (1) |
|
|
485 | (3) |
|
|
488 | (4) |
|
Dynamic Memory Allocation |
|
|
488 | (1) |
|
String Constants And String Initialization |
|
|
489 | (2) |
|
|
491 | (1) |
|
Dynamic Memory Allocation |
|
|
492 | (11) |
|
|
493 | (10) |
|
|
503 | (5) |
|
|
506 | (2) |
|
|
508 | (3) |
|
|
511 | (4) |
|
|
515 | (2) |
|
|
517 | (22) |
|
IEEE Floating Point Representation |
|
|
517 | (8) |
|
|
518 | (1) |
|
Decoding Ieee Single Precision Codes |
|
|
519 | (1) |
|
Encoding Ieee Single Precision Codes |
|
|
520 | (2) |
|
|
522 | (1) |
|
|
523 | (1) |
|
Single Precision Range And Precision |
|
|
524 | (1) |
|
Addition And Subtraction Of Ieee Floating Point Numbers |
|
|
525 | (3) |
|
|
525 | (1) |
|
|
526 | (1) |
|
Comparison Of Floating Point Numbers |
|
|
527 | (1) |
|
Multiplication And Division Of Floating Point Numbers |
|
|
528 | (2) |
|
|
529 | (1) |
|
|
530 | (1) |
|
|
530 | (5) |
|
Encoding And Decoding Fixed Point Representations |
|
|
531 | (1) |
|
Fixed Point Addition And Subtraction |
|
|
531 | (1) |
|
Fixed Point Multiplication And Division |
|
|
532 | (1) |
|
|
533 | (1) |
|
AVR Fmul, Fmuls, And Fmulsu Instructions |
|
|
534 | (1) |
|
|
535 | (1) |
|
|
535 | (2) |
|
|
537 | (2) |
|
Chapter 14 Programming The AVR In C |
|
|
539 | (46) |
|
|
540 | (2) |
|
|
541 | (1) |
|
|
542 | (1) |
|
|
542 | (9) |
|
|
542 | (1) |
|
|
543 | (8) |
|
Fundamentals Of C Programming |
|
|
551 | (26) |
|
|
551 | (1) |
|
|
551 | (2) |
|
|
553 | (1) |
|
|
554 | (1) |
|
|
554 | (1) |
|
|
555 | (3) |
|
|
558 | (1) |
|
Gcc Compiler And Variable Allocation |
|
|
558 | (6) |
|
|
564 | (2) |
|
|
566 | (1) |
|
Literals, Characters, And Strings |
|
|
567 | (1) |
|
|
567 | (1) |
|
|
568 | (1) |
|
|
569 | (2) |
|
|
571 | (2) |
|
|
573 | (1) |
|
|
574 | (2) |
|
|
576 | (1) |
|
|
576 | (1) |
|
|
577 | (3) |
|
|
580 | (3) |
|
|
583 | (2) |
Appendix A Getting Started With The Xplain Evaluation Kit |
|
585 | (8) |
Index |
|
593 | |