Chào các bạn. Xin giới thiệu với các bạn một trong những cuốn sách rất cơ bản để tìm hiểu việc lập trình C cho các loại vi điều khiển. Cuốn sách gồm 11 chương và phần phụ lục: Table of Contents: Chapter 1: Introduction . 11 Why C? 12 Why AVR? .12 Goals .14 Chapter 2: Quick Start Guide 17 Software 19 WinAVR – Oh, Whenever .19 Programmers Notepad .19 AVRStudio – FREE and darn well worth it. .20 Br@y++ Terminal: 20 Hardware .21 Constructing Your Development Platform 21 Blinking LEDs – Your First C Program .27 Write it in Programmers Notepad .27 Download to the Butterfly with AVRStudio 31 Blinky Goes Live 33 Simulation with AVRStudio 35 GOOD GRIEF! .37 Chapter 3: A Brief Introduction to C – What Makes Blinky Blink? .39 Comments .39 Include Files 39 Expressions, Statements, and Blocks 39 Operators .40 Flow Control .40 Functions .41 The Main() Thing 42 Chapter 4: C Types, Operators, and Expressions 45 Data Types and Sizes .45 Variable Names .49 Constants .49 Declarations .50 Arithmetic Operators .50 Relational and Logical Operators 52 Bitwise Operators 53 Assignment Operators and Expressions 61 Conditional Expressions 62 Precedence and Order of Evaluation . 62 Projects 65 Port Input and Output 65 Cylon Eye Speed and Polarity Control . 70 Chapter 5: C Control Flow 73 Statements and Blocks 73 If-Else and Else-If . 74 Switch 75 Loops – While, For and Do-while . 78 Break and Continue . 79 Goto and Labels 80 A few practical examples: strlen, atoi, itoa, reverse 81 Chapter 6: C Functions and Program Structures . 87 Function Basics . 87 Returns 89 Variables External, Static, and Register 90 Scope . 91 Headers 92 Blocks 92 Initialization 92 Recursion 93 Preprocessor 94 Projects 98 Is anybody out there? Communicating with a PC . 98 Chapter 7: Microcontroller Interrupts and Timers 109 Interrupts . 109 Projects 114 Grab your joystick – and test your interrupts 114 Timers/Counters 119 Calibrating the Butterfly oscillator: 121 Projects 128 Precision Blinking . 128 Pulse Width Modulation – LED Brightness Control 134 Pulse Width Modulation - Motor Speed Control 137 Speedometer 144 Chapter 8: C Pointers and Arrays 153 Addresses of variables 153 Function Arguments 157 Arrays 159 FIFOs and LIFOs: Stacks and Queues (Circular Buffers) 167 Function Pointers .169 Complex Pointer and Array Algorithms 170 Projects 171 Messenger 171 Does anybody know what time it is? A Real Time Clock .178 Music to my ears. “Play it again Sam.” .189 Chapter 9 – Digital Meets Analog – ADC and DAC 207 But First - A Debugging Tale 207 Analog to Digital Conversion .210 Projects 216 DAC and ADC - Function Generator / Digital Oscilloscope 227 Chapter 10: C Structures .241 Structure Basics .241 Structures and Functions .243 Structure Arrays .246 Typedef 246 Unions .247 Bit-fields 247 Projects 251 Finite State Machine 251 Chapter 11 The Butterfly LCD 261 PC to LCD test program 262 Conclusion .270 Appendix 1: Project Kits .273 Appendix 2: Soldering Tutorial .275 Appendix 3: Debugging Tale 279 Appendix 4: ASCII Table .283 Appendix 5: Decimal, Hexadecimal, and Binary 285 Appendix 6: Motor Speed Control Wheel .287 Appendix 7: HyperTerminal 289 Index 295 Table of Figures: Figure 1: Dennis Ritchie, inventor of the C programming language stands next to Ken Thompson, original inventor of Unix, designing the original Unix operating system at Bell Labs on a PDP-11 11 Figure 2: The Butterfly front . 21 Figure 3: RS-232 connections . 22 Figure 4: Battery holder, switch, and batteries. 23 Figure 5: External battery connection to Butterfly . 23 Figure 6: Butterfly hooked up to RS-232 24 Figure 7: Bray's Terminal 24 Figure 8: Enter name to send to the Butterfly . 25 Figure 9: Blinky wiring diagram and photo of wired board 26 Figure 10: Hardware setup for Blinky . 27 Figure 11: From the cover of the Battlestar Galactica comic Red Cylon 34 Figure 12: from page 92 of the ATMega169 data book 58 Figure 13 ATMega169 Block Diagram . 65 Figure 14: Port I/O switch input and LED output . 69 Figure 15: Bit 7 high Figure 16: Bit 7 low . 71 Figure 17: Pulse Width Modulation Duty Cycle . 134 Figure 18: Motor Speed Control Schematic and Parts 137 Figure 19: Motor Speed Control Breadboard Labeled 138 Figure 20: Motor Speed Control Hardware 138 Figure 21: Motor Base 139 Figure 22: Motor Wheel Stationary and Spinning 139 Figure 23: Opto Interrupt Switch - H21A1 . 145 Figure 24: Opto Interrupter Glued on Motor Base . 145 Figure 25: Speedometer 146 Figure 26: The PDP-11 could be programmed by switches, though Dennis Ritchie used a Teletype machine to write the C programming language. . 153 Figure 27: 10-bit successive approximation ADC Figure . 211 Figure 28: Potentiometer Schematic . 225 Figure 29: Voltage measurement . 226 Figure 30: R-2R resistor ladder . 228 Figure 31: Breadboard of R-2R DAC . 228 Figure 32: Breadboard R-2R DAC wiring 229 Figure 33: R-2R DAC with Oscilloscope . 229 Figure 34: Function Generator / Digital Oscilloscope on HyperTerminal 230 Figure 35: Sine Wave Figure 36: Square Wave 231 Figure 37: Triangle Wave Figure 38: Sawtooth Wave .231 Figure 39 Butterfly Menu 253 Figure 40: Cheap soldering iron, solder and wick from JAMECO .276 Figure 41: Seasoning the tip 276 Nếu các bạn chưa có tài khoản trên trangquynh.net, các bạn có thể đăng kí TẠI ĐÂY để tải tài liệu ngay bây giờ hoặc các bạn có thể bấm VÀO ĐÂY để xem các tài liệu khác.