PIC-MDS Training Manual
Total Page:16
File Type:pdf, Size:1020Kb
PIC-MDS PIC Microcontroller Development System Training Manual Copyright © 1996, 1998 Sirius microSystems. All rights reserved. Second Printing. Parallax is a Trademark of Parallax, Inc. PICmicro™ is a Registered Trademark of Microchip Technology Inc. in the U.S.A. and other countries. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, or recording, or otherwise, without the prior written permission of Sirius microSystems. Sirius microSystems has taken care to trace ownership of copyright material contained in this text. However, Sirius microSystems will gladly accept any information that enables them to rectify any reference or credit in subsequent editions. For conditions, permissions and other rights under this copyright, contact Sirius microSystems: Sirius microSystems 172 Harvard Road Waterloo, ON N2J 3V3 Canada tel.: 519.886.4462 fax: 519.886.4253 http://www.siriusmicro.com ISBN 0-9681220-0-0 (Training Manual) ISBN 0-9681220-1-9 (Teacher’s Reference) Disclaimer of Liability This manual and the program subroutines included herein are written for the Sirius microSystems PICmicro™ Development System and are provided on an “as is” basis, without any warranty, either expressed or implied. These materials are provided for educational use only, and Sirius microSystems does not assume any liability for damages, either incidental or consequential, arising out of the application, use, or misuse of any of its software or hardware products. Sirius microSystems reserves the right, without further notice, to make changes to any of its training materials, software or hardware referred to in this manual in order to improve its function, design or reliability. Printed in Canada. Table of Contents 1 What are Microcontrollers?......................................9 10Microcontroller Features .................................................................. 10 Input/Output Ports ........................................................................... 10 Input Devices ................................................................................... 11 Output Devices ................................................................................ 12 Memory ............................................................................................ 12 Clock Circuit ..................................................................................... 15 Processing Unit ................................................................................ 15 Watch-Dog Timer ............................................................................. 15 Chapter Summary............................................................................ 16 Questions ......................................................................................... 17 Assignments .................................................................................... 17 2 How do Microcontrollers Work? ............................19 Processing Unit ................................................................................ 19 Memory ............................................................................................ 20 The Outside World Connection ....................................................... 20 How do Programs get into the Microcontroller? .............................. 20 Chapter Summary............................................................................ 21 Questions ......................................................................................... 22 3 The Microchip PIC family of Microcontrollers ......23 The PICmicro™ Product Range ...................................................... 23 The 18-pin PIC16CXX Product Line ............................................... 24 The PIC16F84 ................................................................................. 25 Program EEPROM .......................................................................... 25 Data EEPROM ................................................................................. 25 RAM ................................................................................................. 26 Input/Output Ports ........................................................................... 26 TMR0 ............................................................................................... 26 Watchdog Timer (WDT) ................................................................... 27 Power-Up Reset Timer (PWRT) ...................................................... 27 Oscillator .......................................................................................... 27 RAM Register Files .......................................................................... 28 STATUS ........................................................................................... 28 PCL & PCLATH ............................................................................... 28 IND0 & FSR ..................................................................................... 28 INTCON ........................................................................................... 28 Option .............................................................................................. 28 EEDATA & EEADR .......................................................................... 28 EECON1 & EECON2 ....................................................................... 28 The PIC16C711 ............................................................................... 29 Program EPROM ............................................................................. 29 Analog-to-Digital Converter ............................................................. 29 Chapter Summary............................................................................ 30 Questions ......................................................................................... 31 Assignment ...................................................................................... 31 ©1998 Sirius microSystems 3 4 Features of the PIC-MDS Development System ...33 Power Supply Circuit ....................................................................... 35 J1 ..................................................................................................... 35 VR1 .................................................................................................. 35 JU1 ................................................................................................... 35 JU2 ................................................................................................... 36 External I/O Connectors .................................................................. 36 CON1 ............................................................................................... 36 PICBUS ............................................................................................ 37 Microcontroller Related Circuits ....................................................... 37 Microcontroller Socket ..................................................................... 37 H2 .................................................................................................... 37 Reset Button .................................................................................... 38 Y1 ..................................................................................................... 38 JU3 ................................................................................................... 38 JU6 ................................................................................................... 39 VR3 & VR4 ...................................................................................... 39 Matrix Keypad .................................................................................. 39 LED Output Indicator Bar Graph ..................................................... 40 Intelligent LCD Display .................................................................... 40 VR2 .................................................................................................. 40 RS-232 Serial Port ........................................................................... 40 JU5 ................................................................................................... 40 H3 .................................................................................................... 41 Serial EEPROM ............................................................................... 41 JU4 ................................................................................................... 41 PIC-MDS Default Jumper Locations................................................ 41 Questions ......................................................................................... 42 5 Writing a Simple Program ......................................43 Examining Source Code—Microchip Code ..................................... 44 Source Code Conventions .............................................................. 45 Some Other Common Source Code Conventions .......................... 46 Examining the Program ................................................................... 47 The Maclib Directive ........................................................................ 47 The Device and ID Directives .......................................................... 47 The ORG Directive .......................................................................... 47 Program