Do you want a low cost way to learn C programming for microcontrollers? This book shows you how to use Atmel's $19.99 AVR Butterfly board and the FREE WinAVR C compiler to make a very inexpensive system for using C to develop microcontroller projects. Students will find the thorough coverage of C explained in the context of microcontrollers to be an invaluable learning aide. Professionals, even those who already know C, will find many useful tested software and hardware examples that will speed their development work. Test drive the book by going to
www.smileymicros.com and downloading the FREE 30 page pdf file: Quick Start Guide for using the WinAVR Compiler with ATMEL's AVR Butterfly which contains the first two chapters of the book and has all you need to get started with the AVR Butterfly and WinAVR. In addition to an in-depth coverage of C, the book has projects for: 7Port I/O reading switches and blinking LEDs 7UART communication with a PC 7Using interrupts, timers, and counters 7Pulse Width Modulation for LED brightness and motor speed control 7Creating a Real Time Clock 7Making music 7ADC: Analog to Digital Conversion 7DAC: Digital to Analog Conversion 7Voltage, light, and temperature measurement 7Making a slow Function Generator and Digital Oscilloscope 7LCD programming 7Writing a Finite State Machine The author (an Electrical Engineer, Official Atmel AVR Consultant, and award winning writer) makes the sometimes-tedious job of learning C easier by often breaking the in-depth technical exposition with humor and anecdotes detailing his personal experience and misadventures.
Author(s): Joe Pardue
Publisher: Smiley Micros
Year: 2005
Language: English
Pages: 298
Chapter 1: Introduction
Why C?
Why AVR?
Goals
Chapter 2: Quick Start Guide
Software
WinAVR – Oh, Whenever…
Programmers Notepad
AVRStudio – FREE and darn well worth it.
Br@y++ Terminal:
Hardware
Constructing Your Development Platform
Blinking LEDs – Your First C Program
Write it in Programmers Notepad
Download to the Butterfly with AVRStudio
Blinky Goes Live
Simulation with AVRStudio
GOOD GRIEF!
Chapter 3: A Brief Introduction to C – What Makes Blinky Bli
Comments
Include Files
Expressions, Statements, and Blocks
Operators
Flow Control
Functions
The Main() Thing
Chapter 4: C Types, Operators, and Expressions
Data Types and Sizes
Seen on a shirt at a Robothon event:
Bits
Bytes
The long and short of it
Variable Names
Constants
Declarations
Arithmetic Operators
Relational and Logical Operators
Bitwise Operators
Testing Bits
Assignment Operators and Expressions
Conditional Expressions
Precedence and Order of Evaluation
Projects
Port Input and Output
Cylon Eye Speed and Polarity Control
Chapter 5: C Control Flow
Statements and Blocks
If-Else and Else-If
Switch
Loops – While, For and Do-while
Break and Continue
Goto and Labels
A few practical examples: strlen, atoi, itoa, reverse
Chapter 6: C Functions and Program Structures
Function Basics
Returns
Variables External, Static, and Register
Scope
Headers
Blocks
Initialization
Recursion
Preprocessor
Macro Substitution
Conditional Inclusion
Projects
Is anybody out there? Communicating with a PC
Demonstrator
PC_Comm
Using CommDemo:
Chapter 7: Microcontroller Interrupts and Timers
Interrupts
Projects
Grab your joystick – and test your interrupts
Using joystick
Timers/Counters
Calibrating the Butterfly oscillator:
OSCCAL_calibration() function – detailed explanation
ALL THIS AND WE HAVEN’T EVEN STARTED CALIBRATING YET!
Projects
Precision Blinking
Using Precision Blinking:
Pulse Width Modulation – LED Brightness Control
Pulse Width Modulation - Motor Speed Control
Speedometer
Chapter 8: C Pointers and Arrays
Addresses of variables
Function Arguments
Arrays
FIFOs and LIFOs: Stacks and Queues (Circular Buffers)
Stacks
Queues (Circular Buffers)
Function Pointers
Complex Pointer and Array Algorithms
Projects
Messenger
Arrays in RAM and ROM
Does anybody know what time it is? A Real Time Clock.
A one second interrupt
Converting Computer Time to Human Readable Time
The Real Timer Clock Software
Music to my ears. “Play it again Sam.”
More on pointers to arrays
Setting the frequency
Setting the duration
An example song array – Fur Elise
Using the Piezo-element to make sound
Initializing the Timer1 for PWM to the piezo-element.
Generating the tone using PWM from Timer1
Using the Timer0 interrupt to play a tune
Chapter 9 – Digital Meets Analog – ADC and DAC
But First - A Debugging Tale
Analog to Digital Conversion
What is Analog to Digital Conversion?
Analog to Digital Conversion by Successive Approximation
Analog to Digital Conversion with the ATMEGA169
Starting a Conversion
Conversion Timing
Changing Channels
Digital Noise Reduction
Conditioning the Analog Input Signal
Accuracy
Projects
Initializing the ADC
Reading the ADC
Light Meter
Temperature Meter
The @#%#&*#!!!! Volt Meter
Using ADC
DAC and ADC - Function Generator / Digital Oscilloscope
Chapter 10: C Structures
Structure Basics
Structures and Functions
Structure Arrays
Typedef
Unions
Bit-fields
Bit-Fields the C-way
Bit-fields the masking-way
Projects
Finite State Machine
Chapter 11 The Butterfly LCD
PC to LCD test program
Conclusion
Appendix 1: Project Kits
Data I/O
PWM Motor Control
Appendix 2: Soldering Tutorial
Appendix 3: Debugging Tale
Appendix 4: ASCII Table
Appendix 5: Decimal, Hexadecimal, and Binary
Appendix 6: Motor Speed Control Wheel
Appendix 7: HyperTerminal
Index