The Microcontroller Idea Book - Jan Axelson.pdf

(3353 KB) Pobierz
The
Microcontroller Idea Book
Circuits, Programs, & Applications
featuring the 8052-BASIC Microcontroller
Jan Axelson
Lakeview Research
Madison, WI
copyright 1994, 1997 by Jan Axelson
Lakeview Research
5310 Chinook Ln.
Madison, WI 53704
USA
Phone: 608-241-5824
Fax: 608-241-5848
Email: jaxelson@lvr.com
WWW: http://www/lvr.com
No part of this book, except the programs and program listings, may be reproduced in any
form, or stored in a database or retrieval system, or transmitted or distributed in any form,
by any means, electronic, mechanical photocopying, recording, or otherwise, without the
prior written permission of Lakeview Research or the author, except as permitted by the
Copyright Act of 1976. The programs and program listings, or any portion of these, may be
stored and executed in a computer system and may be incorporated into computer programs
developed by the reader.
Trademarks
Macintosh is a registered trademark of Apple Computer. Procomm Plus and Datastorm are
registered trademarks of Datastorm Technologies, Inc. VT100 is a registered trademark of
Digital Equipment Corporation. IBM is a registered trademark of International Business
Machines Corporation. MCS-BASIC-52 and Intel are registered trademarks of Intel Corpo-
ration. Microsoft, MS-DOS, GW-BASIC, and Microsoft Windows are registered trademarks
of Microsoft Corporation. Philips is a registered trademark of Philips International BV.
The author and publisher have used their best efforts in preparing this book and the
materials in it. The author built and tested the electronic circuits described, ran and tested
the computer programs presented, and reviewed all materials for completeness and
accuracy. The author and publisher make no warranty with regard to the circuit
schematics, program listings, and other materials in this book. The author and publisher
take no responsibility for any damages resulting from any use of the material in this book.
ISBN 0-9650819-4-X
Table of Contents
Chapter 1
Microcontroller Basics
What’s a Microcontroller? 1
A Little History 2
New Tools 3
Project Steps 4
Inside the 8052-BASIC
Possibilities 11
Limits 13
What You Need 14
The 8051 Family 16
Elements of the 8052 and 8052-BASIC 17
Powering Up
About the Circuit 23
Circuit Construction 30
Powering Up 35
Basic Tests 38
Simple Programs to Try 40
Exiting Programs 44
Saving Programs
Nonvolatile Memory Options 47
Adding NVRAM or EEPROM 50
Using the Programming Commands 53
Adding Bootup Options 54
1
Chapter 2
11
Chapter 3
23
Chapter 4
47
iii
Erasing NV Memory 55
Adding more NVRAM or EEPROM 56
Adding EPROM 56
EPROM-programming Circuits 57
Power Supplies for Programming 61
Storing Programs on Disk 63
Chapter 5
Programming
Programming Basics 65
BASIC-52 Bugs and Things to Watch Out For 69
Finding Program Errors 70
BASIC-52 Keywords by Function 72
Quick Reference to BASIC-52 74
Inputs and Outputs
The Memory Map 87
Uses for I/O Ports 89
Adding Ports 89
The 8255 Programmable Peripheral Interface 98
Switches and Keypads
Simple Switches 109
Adding a Keypad 116
Displays
Using LEDs 125
7-segment Displays 129
Displaying Messages 138
Inside the Display Controller 140
Mounting Displays in an Enclosure 152
Using Sensors to Detect and Measure
Sensor Basics 153
Choosing Sensors 154
On/off Sensors 155
Analog Sensors 156
Sensor Examples 163
Level Translating 167
Choosing a Converter 169
Clocks and Calendars
BASIC-52’s Real-time Clock 171
A Watchdog Timekeeper 174
65
Chapter 6
87
Chapter 7
109
Chapter 8
125
Chapter 9
153
Chapter 10
171
iv
Zgłoś jeśli naruszono regulamin