make_avr_programming.pdf

(47593 KB) Pobierz
Make: AVR
Programming
Elliot Williams
Make: AVR Programming
by Elliot Williams
Copyright © 2014 Elliot Williams. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc., 1160 Battery Street East, Suite 125, San Francisco, CA 94111.
Maker Media books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http:/
/my.safaribooksonline.com).
For more information, contact O’Reilly
Media’s corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Patrick Di Justo
Production Editor:
Kara Ebrahim
Copyeditor:
Kim Cofer
Proofreader:
Amanda Kersey
February 2014:
2014-01-24:
2014-02-14:
2015-03-03:
First Edition
Indexer:
Judy McConville
Cover Designer:
Shawn Wallace
Interior Designer:
Monica Kamsvaag
Illustrator:
Rebecca Demarest
Revision History for the First Edition:
First release
Second release
Third release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781449355784
for release details.
The Make logo and Maker Media logo are registered trademarks of Maker Media, Inc.
Make: AVR Program-
ming
and related trade dress are trademarks of Maker Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and Maker Media, Inc., was aware of a trademark
claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-35578-4
[LSI]
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Part I.
The Basics
1.
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What Is a Microcontroller? The Big Picture
. . . . . . . . . . . . . . . . . . . . . . . . 3
A Computer on a Chip…
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
…But a Very Small Computer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
What Can Microcontrollers Do?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Hardware: The Big Picture
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Core: Processor, Memory, and I/O
. . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Peripherals: Making Your Life Easier
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.
Programming AVRs
. . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Programming the AVR
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Toolchain
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
The Software Toolchain
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Linux Setup
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Windows Setup
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Mac Setup
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Arduino Setup
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Make and Makefiles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
AVR and the Arduino
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Arduino Pros
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Arduino Cons
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
iii
Zgłoś jeśli naruszono regulamin