Pic 16F84A
This page intentionally left blank
PIC in Practice
A Project-Based Approach
D. W. Smith
AMSTERDAM BOSTON HEIDELBERG LONDON
NEW YORK OXFORD PARIS SAN DIEGO
SAN FRANCISCO SINGAPORE SYDNEY TOKYO
Newnes is an imprint of Elsevier
Newnes is an imprint of Elsevier
Linacre House, Jordan Hill, Oxford OX2 8DP
30 Corporate Road, Burlington, MA01803
First published 2002
Reprinted 2003 (twice), 2005
Second edition 2006
Copyright ß 2006, Dave Smith. All rights reserved
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any
form or by any means electronic, mechanical, photocopying, recording or otherwise without the
prior written permission of the publisher
Permission may be soughtdirectly from Elsevier’s Science & Technology Rights Department
in Oxford, UK: phone (+44) (0) 1865 843830; fax (+44) (0) 1865 853333; email: permissions@
elsevier.com. Alternatively you can submit your request online by visiting the Elsevier web site at
http://elsevier.com/locate/permissions, and selecting Obtaining permission to use Elsevier material
Notice
No responsibility is assumed by thepublisher for any injury and/or damage to persons or property
as a matter of products liability, negligence or otherwise, or from any use or operation of any
methods, products, instructions or ideas contained in the material herein. Because of rapid
advances in the medical sciences, in particular, independent verification of diagnoses and drug
dosages should be made
British Library Cataloguingin Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging in Publication Data
A catalogue record for this book is available from the Library of Congress
ISBN 13: 978-0 75-066826-2
ISBN 10: 0-75-066826-1
For information on all Newnes publications visit
our website at books.elsevier.com
Typeset by Cepha Imaging Pvt Ltd,Bangalore, India
Printed and bound in Great Britain
Contents
Introduction
1
ix
2
Introduction to the PIC microcontroller
1
The aim of the book
Program memory
Microcontroller clock
The microcontroller system
Types of microcontroller
Microcontroller specification
Using the microcontroller
1 Microcontroller hardware
2 Programming the microcontroller
1
2
3
3
4
5
6
69
3
Programming the 16F84 microcontroller
11
Microcontroller inputs and output (I/O)
Timing with the microcontroller
Programming the microcontroller
Entering data
The header for the 16F84
Program example
Saving and assembling the code
PICSTART PLUS programmer
Programming flowchart
Problem: flashing two LEDs
Solution to problem, flashing two LEDs
12
12
12
13
14
1619
23
26
26
27
4
Introductory projects
29
LED_Flasher2
SOS
Code for SOS circuit
Flashing 8 LEDs
Chasing 8 LEDs
Traffic lights
More than 8 outputs
29
30
30
33
35
39
45
Headers, porting code – which micro?
47
Factors affecting the choice of the microcontroller
Choosing the microcontroller
Headers
47
48
49
vi Contents
5
6
Using inputs
64Switch flowchart
Program development
Scanning (using multiple inputs)
Switch scanning
Control application – a hot air blower
66
67
73
73
77
8
82
82
87
88
Keypad scanning
93
Programming example for the keypad
7
Understanding the headers
The 16F84
16F84 memory map
The 16F818
94
9
Program examples
110
Counting events
Look up table
7-Segmentdisplay
Numbers larger than 255
Long time intervals
One hour delay
110
115
115
126
133
136
10
The 16C54 microcontroller
139
Header for the 16C54
16C54 memory map
139
142
11
Alpha numeric displays
143
Display pin identification
Configuring the display
Writing to the display
Program example
Program operation
Display configuration
Writing to the display...
Regístrate para leer el documento completo.