NEW DATABASE - 350 MILLION DATASHEETS FROM 8500 MANUFACTURERS
/DS33023A ISO9001 AEC-A100/QS9000 10-BIT DS31001A PIC16CXXX DS31002A DS31003A - Datasheet Archive
PICmicroTM Mid-Range MCU Family Reference Manual © 1997 Microchip Technology Inc. December 1997 /DS33023A M Internationally
M PICmicroTM Mid-Range MCU Family Reference Manual © 1997 Microchip Technology Inc. December 1997 /DS33023A /DS33023A M Internationally Recognized Quality System Certifications Microchip's Quality System embodies the requirements of ISO9001 ISO9001:1994. Our Microchip Chandler and Tempe Design and Manufacturing facilities have been certified to ISO 9001. The Microchip Kaohsiung Test facility, and primary Assembly houses have been certified to ISO 9002. ISO certification plans are in-process for an estimated certification grant by year-end 1997. In addition, Microchip has received numerous customer certifications, including a Delco issued certificate of compliance to AEC-A100/QS9000 AEC-A100/QS9000. "All rights reserved. Copyright © 1997, Microchip Technology Incorporated, USA. Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip's products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All other trademarks mentioned herein are the property of their respective companies. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights." December 1997 /DS33023A /DS33023A Microchip received ISO 9001 Quality System certification for its worldwide headquarters, design, and wafer fabrication facilities in January, 1997. Our field-programmable PICmicroTM 8-bit MCUs, Serial EEPROMs, related specialty memory products and development systems conform to the stringent quality standards of the International Standard Organization (ISO). Trademarks The Microchip name, logo, PIC, KEELOQ, PICMASTER, PICSTART, PRO MATE, and SEEVAL are registered trademarks of Microchip Technology Incorporated in the U.S.A. MPLAB, PICmicro, ICSP and In-Circuit Serial Programming are trademarks of Microchip Technology Incorporated. Serialized Quick-Turn Production is a Service Mark of Microchip Technology Incorporated. All other trademarks mentioned herein are property of their respective companies. © 1997 Microchip Technology Inc. M Table of Contents PAGE SECTION 1. INTRODUCTION 1-1 Introduction .1-2 Manual Objective .1-3 Device Structure .1-4 Development Support .1-6 Device Varieties .1-7 Style and Symbol Conventions .1-12 Related Documents .1-14 Related Application Notes .1-17 Revision History .1-18 SECTION 2. OSCILLATOR 2-1 Introduction .2-2 Oscillator Configurations .2-2 Crystal Oscillators / Ceramic Resonators .2-4 External RC Oscillator .2-12 Internal 4 MHz RC Oscillator .2-13 Effects of Sleep Mode on the On-chip Oscillator .2-17 Effects of Device Reset on the On-chip Oscillator .2-17 Design Tips .2-18 Related Application Notes .2-19 Revision History .2-20 SECTION 3. RESET 3-1 Introduction .3-2 Power-on Reset (POR), Power-up Timer (PWRT), Oscillator Start-up Timer (OST), Brown-out Reset (BOR), and Parity Error Reset (PER) .3-4 Registers and Status Bit Values .3-10 Design Tips .3-16 Related Application Notes .3-17 Revision History .3-18 SECTION 4. ARCHITECTURE 4-1 Introduction .4-2 Clocking Scheme/Instruction Cycle .4-5 Instruction Flow/Pipelining .4-6 I/O Descriptions .4-7 Design Tips .4-12 Related Application Notes .4-13 Revision History .4-14 © 1997 Microchip Technology Inc. DS00097D-page iii M Table of Contents PAGE SECTION 5. CPU AND ALU 5-1 Introduction .5-2 General Instruction Format .5-4 Central Processing Unit (CPU) .5-4 Instruction Clock .5-4 Arithmetic Logical Unit (ALU) .5-5 STATUS Register .5-6 OPTION_REG Register .5-8 PCON Register .5-9 Design Tips .5-10 Related Application Notes .5-11 Revision History .5-12 SECTION 6. MEMORY ORGANIZATION 6-1 Introduction .6-2 Program Memory Organization .6-2 Data Memory Organization .6-8 Initialization .6-14 Design Tips .6-16 Related Application Notes .6-17 Revision History .6-18 SECTION 7. DATA EEPROM 7-1 Introduction .7-2 Control Register .7-3 EEADR .7-4 EECON1 and EECON2 Registers .7-4 Reading the EEPROM Data Memory .7-5 Writing to the EEPROM Data Memory .7-5 Write Verify .7-6 Protection Against Spurious Writes .7-7 Data EEPROM Operation During Code Protected Configuration .7-7 Initialization .7-7 Design Tips .7-8 Related Application Notes .7-9 Revision History .7-10 SECTION 8. INTERRUPTS 8-1 Introduction .8-2 Control Registers .8-5 Interrupt Latency .8-10 INT and External Interrupts .8-10 Context Saving During Interrupts .8-11 Initialization .8-14 Design Tips .8-16 Related Application Notes .8-17 Revision History .8-18 DS00097D-page iv © 1997 Microchip Technology Inc. M Table of Contents PAGE SECTION 9. I/O PORTS 9-1 Introduction .9-2 PORTA and the TRISA Register .9-4 PORTB and the TRISB Register .9-6 PORTC and the TRISC Register .9-8 PORTD and the TRISD Register .9-9 PORTE and the TRISE Register .9-10 PORTF and the TRISF Register .9-11 PORTG and the TRISG Register .9-12 GPIO and the TRISGP Register .9-13 I/O Programming Considerations .9-14 Initialization .9-16 Design Tips .9-17 Related Application Notes .9-19 Revision History .9-20 SECTION 10. PARALLEL SLAVE PORT 10-1 Introduction .10-2 Control Register .10-3 Operation .10-4 Operation in Sleep Mode .10-5 Effect of a Reset .10-5 PSP Waveforms .10-5 Design Tips .10-6 Related Application Notes .10-7 Revision History .10-8 © 1997 Microchip Technology Inc. DS00097D-page v M Table of Contents PAGE SECTION 11. TIMER0 11-1 Introduction .11-2 Control Register .11-3 Operation .11-4 TMR0 Interrupt .11-5 Using Timer0 with an External Clock .11-6 TMR0 Prescaler .11-7 Design Tips .11-10 Related Application Notes .11-11 Revision History .11-12 SECTION 12. TIMER1 12-1 Introduction .12-2 Control Register .12-3 Timer1 Operation in Timer Mode .12-4 Timer1 Operation in Synchronized Counter Mode .12-4 Timer1 Operation in Asynchronous Counter Mode .12-5 Timer1 Oscillator .12-7 Sleep Operation .12-9 Resetting Timer1 Using a CCP Trigger Output .12-9 Resetting of Timer1 Register Pair (TMR1H:TMR1L) .12-9 Timer1 Prescaler .12-9 Initialization .12-10 Design Tips .12-12 Related Application Notes .12-13 Revision History .12-14 SECTION 13. TIMER2 13-1 Introduction .13-2 Control Register .13-3 Timer Clock Source .13-4 Timer (TMR2) and Period (PR2) Registers .13-4 TMR2 Match Output .13-4 Clearing the Timer2 Prescaler and Postscaler .13-4 Sleep Operation .13-4 Initialization .13-5 Design Tips .13-6 Related Application Notes .13-7 Revision History .13-8 SECTION 14. COMPARE/CAPTURE/PWM (CCP) 14-1 Introduction .14-2 Control Register .14-3 Capture Mode .14-4 Compare Mode .14-6 PWM Mode .14-8 Initialization .14-12 Design Tips .14-15 Related Application Notes .14-17 Revision History .14-18 DS00097D-page vi © 1997 Microchip Technology Inc. M Table of Contents PAGE SECTION 15. SYNCHRONOUS SERIAL PORT (SSP) 15-1 Introduction .15-2 Control Registers .15-3 SPI Mode .15-6 SSP I2C Operation .15-16 Initialization .15-26 Design Tips .15-28 Related Application Notes .15-29 Revision History .15-30 SECTION 16. BASIC SYCHRONOUS SERIAL PORT (BSSP) 16-1 Introduction .16-2 Control Registers .16-3 SPI Mode .16-6 SSP I2C Operation .16-15 Initialization .16-23 Design Tips .16-24 Related Application Notes .16-25 Revision History .16-26 SECTION 17. MASTER SYNCHRONOUS SERIAL PORT (MSSP) 17-1 Introduction .17-2 Control Register .17-4 SPI Mode .17-9 SSP I2CTM Operation .17-18 Connection Considerations for I2C Bus .17-56 Initialization .17-57 Design Tips .17-58 Related Application Notes .17-59 Revision History .17-60 SECTION 18. USART 18-1 Introduction .18-2 Control Registers .18-3 USART Baud Rate Generator (BRG) .18-5 USART Asynchronous Mode .18-8 USART Synchronous Master Mode .18-15 USART Synchronous Slave Mode .18-19 Initialization .18-21 Design Tips .18-22 Related Application Notes .18-23 Revision History .18-24 © 1997 Microchip Technology Inc. DS00097D-page vii M Table of Contents PAGE SECTION 19. VOLTAGE REFERENCE 19-1 Introduction .19-2 Control Register .19-3 Configuring the Voltage Reference .19-4 Voltage Reference Accuracy/Error .19-5 Operation During Sleep .19-5 Effects of a Reset .19-5 Connection Considerations .19-6 Initialization .19-7 Design Tips .19-8 Related Application Notes .19-9 Revision History .19-10 SECTION 20. COMPARATOR 20-1 Introduction .20-2 Control Register .20-3 Comparator Configuration .20-4 Comparator Operation .20-6 Comparator Reference .20-6 Comparator Response Time .20-8 Comparator Outputs .20-8 Comparator Interrupts .20-9 Comparator Operation During SLEEP .20-9 Effects of a RESET .20-9 Analog Input Connection Considerations .20-10 Initialization .20-11 Design Tips .20-12 Related Application Notes .20-13 Revision History .20-14 SECTION 21. 8-BIT A/D CONVERTER 21-1 Introduction .21-2 Control Registers .21-3 Operation .21-5 A/D Acquisition Requirements .21-6 Selecting the A/D Conversion Clock .21-8 Configuring Analog Port Pins .21-9 A/D Conversions .21-10 A/D Operation During Sleep .21-12 A/D Accuracy/Error .21-13 Effects of a RESET .21-13 Use of the CCP Trigger .21-14 Connection Considerations .21-14 Transfer Function .21-14 Initialization .21-15 Design Tips .21-16 Related Application Notes .21-17 Revision History .21-18 DS00097D-page viii © 1997 Microchip Technology Inc. M Table of Contents PAGE SECTION 22. BASIC 8-BIT A/D CONVERTER 22-1 Introduction .22-2 Control Registers .22-3 A/D Acquisition Requirements .22-6 Selecting the A/D Conversion Clock .22-8 Configuring Analog Port Pins .22-10 A/D Conversions .22-11 A/D Operation During Sleep .22-14 A/D Accuracy/Error .22-15 Effects of a RESET .22-16 Connection Considerations .22-16 Transfer Function .22-16 Initialization .22-17 Design Tips .22-18 Related Application Notes .22-19 Revision History .22-20 SECTION 23. 10-BIT 10-BIT A/D CONVERTER 23-1 Introduction .23-2 Control Register .23-3 Operation .23-5 A/D Acquisition Requirements .23-6 Selecting the A/D Conversion Clock .23-8 Configuring Analog Port Pins .23-9 A/D Conversions .23-10 Operation During Sleep .23-14 Effects of a Reset .23-14 A/D Accuracy/Error .23-15 Connection Considerations .23-16 Transfer Function .23-16 Initialization .23-17 Design Tips .23-18 Related Application Notes .23-19 Revision History .23-20 SECTION 24. SLOPE A/D 24-1 Introduction .24-2 Control Registers .24-3 Conversion Process .24-6 Other Analog Modules .24-12 Calibration Parameters .24-13 Design Tips .24-14 Related Application Notes .24-15 Revision History .24-16 © 1997 Microchip Technology Inc. DS00097D-page ix M Table of Contents PAGE SECTION 25. LCD 25-1 Introduction .25-2 Control Register .25-3 LCD Timing .25-6 LCD Interrupts .25-12 Pixel Control .25-13 Voltage Generation .25-15 Operation During Sleep .25-16 Effects of a Reset .25-17 Configuring the LCD Module .25-17 Discrimination Ratio .25-18 LCD Voltage Generation .25-20 Contrast .25-22 LCD Glass .25-22 Initialization .25-23 Design Tips .25-24 Related Application Notes .25-25 Revision History .25-26 SECTION 26. WATCHDOG TIMER AND SLEEP MODE 26-1 Introduction .26-2 Control Register .26-3 Watchdog Timer (WDT) Operation .26-4 SLEEP (Power-Down) Mode .26-7 Initialization .26-9 Design Tips .26-10 Related Application Notes .26-11 Revision History .26-12 SECTION 27. DEVICE CONFIGURATION BITS 27-1 Introduction .27-2 Configuration Word Bits .27-4 Program Verification/Code Protection .27-8 ID Locations .27-9 Design Tips .27-10 Related Application Notes .27-11 Revision History .27-12 SECTION 28. IN-CIRCUIT SERIAL PROGRAMMINGTM 28-1 Introduction .28-2 Entering In-Circuit Serial Programming Mode .28-3 Application Circuit .28-4 Programmer .28-6 Programming Environment .28-6 Other Benefits .28-7 Field Programming of PICmicro OTP MCUs .28-8 Field Programming of FLASH PICmicros .28-10 Design Tips .28-12 Related Application Notes .28-13 Revision History .28-14 DS00097D-page x © 1997 Microchip Technology Inc. M Table of Contents PAGE SECTION 29. INSTRUCTION SET 29-1 Introduction .29-2 Instruction Formats .29-4 Special Function Registers as Source/Destination .29-6 Q Cycle Activity .29-7 Instruction Descriptions .29-8 Design Tips .29-45 Related Application Notes .29-47 Revision History .29-48 SECTION 30. ELECTRICAL SPECIFICATIONS 30-1 Introduction .30-2 Absolute Maximums .30-3 Device Selection Table .30-4 Device Voltage Specifications .30-5 Device Current Specifications .30-6 Input Threshold Levels .30-9 I/O Current Specifications .30-10 Output Drive Levels .30-11 I/O Capacitive Loading .30-12 Data EEPROM / Flash .30-13 LCD .30-14 Comparators and Voltage Reference .30-15 Timing Parameter Symbology .30-16 Example External Clock Timing Waveforms and Requirements .30-17 Example Power-up and Reset Timing Waveforms and Requirements .30-19 Example Timer0 and Timer1 Timing Waveforms and Requirements .30-20 Example CCP Timing Waveforms and Requirements .30-21 Example Parallel Slave Port (PSP) Timing Waveforms and Requirements .30-22 Example SSP and Master SSP SPI Mode Timing Waveforms and Requirements .30-23 Example SSP I2C Mode Timing Waveforms and Requirements .30-27 Example Master SSP I2C Mode Timing Waveforms and Requirements .30-30 Example USART/SCI Timing Waveforms and Requirements .30-32 Example 8-bit A/D Timing Waveforms and Requirements .30-34 Example 10-bit A/D Timing Waveforms and Requirements .30-36 Example Slope A/D Timing Waveforms and Requirements .30-38 Example LCD Timing Waveforms and Requirements .30-40 Related Application Notes .30-41 Revision History .30-42 SECTION 31. DEVICE CHARACTERISTICS 31-1 Introduction .31-2 Characterization vs. Electrical Specification .31-2 DC and AC Characteristics Graphs and Tables .31-2 Revision History .31-22 © 1997 Microchip Technology Inc. DS00097D-page xi M Table of Contents PAGE SECTION 32. DEVELOPMENT TOOLS 32-1 Introduction .32-2 The Integrated Development Environment (IDE) .32-3 MPLAB Software Language Support .32-6 MPLAB-SIM Simulator Software .32-8 MPLAB Emulator Hardware Support .32-9 MPLAB Programmer Support .32-10 Supplemental Tools .32-11 Development Boards .32-12 Development Tools for Other Microchip Products .32-14 Related Application Notes .32-15 Revision History .32-16 SECTION 33. CODE DEVELOPMENT 33-1 Revision History .33-2 SECTION 34. APPENDIX 34-1 I2CTM Overview .34-2 List of LCD Glass Manufacturers . 34-11 Device Enhancement .34-13 Revision History . 34-19 SECTION 35. GLOSSARY 35-1 Revision History .35-14 DS00097D-page xii © 1997 Microchip Technology Inc. M 1 Introduction Section 1. Introduction HIGHLIGHTS This section of the manual contains the following major topics: 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Introduction .1-2 Manual Objective .1-3 Device Structure .1-4 Development Support .1-6 Device Varieties.1-7 Style and Symbol Conventions .1-12 Related Documents .1-14 Related Application Notes.1-17 Revision History .1-18 © 1997 Microchip Technology Inc. DS31001A DS31001A page 1-1 PICmicro MID-RANGE MCU FAMILY 1.1 Introduction Microchip is the Embedded Control Solutions Company®. The company's focus is on products that meet the needs of the embedded control market. We are a leading supplier of: · · · · 8-bit General Purpose Microcontrollers (PICmicroTM MCUs) Speciality and standard non-volatile memory devices Security devices (KEELOQ®) Application specific standard products Please request a Microchip Product Line Card for a listing of all the interesting products that we have to offer. This literature can be obtained from your local sales office, or downloaded from the Microchip web site (www.microchip.com). In the past, 8-bit MCU users were fixed on the traditional MCU model for production, a ROM device was required. Microchip has been the leader in changing this perception by showing that OTP devices can give a better lifetime product cost compared to ROM versions. Microchip has a strength is in EPROM technology. That made it the memory technology of choice for the PICmicro MCU's program memory. Microchip has minimized the cost difference between EPROM and ROM memory technology, and therefore Microchip can pass these benefits onto our customers. This is not true for other MCU vendors, and is seen in the price difference between their EPROM and ROM versions. The growth of Microchip's 8-bit MCU market share is a testament to the PICmicro MCUs ability to meet the needs of many. This growth has made the PICmicro architecture one of the top three architectures available in the general market today. This growth was fueled by the Microchip vision of the benefits of a low cost OTP solution. Some of the benefits for the customer include: · · · · · · · Quick time to market Allows code changes to product, during production run No Non-Recurring Engineering (NRE) charges for Mask Revisions Ability to easily serialize the product Ability to store calibration data, without additional hardware Better able to maximize PICmicro MCU inventory Less risk, since the same device is used for development as well as for production. Microchip's PICmicro 8-bit MCUs offer a price/performance ratio that allows them to be considered for any traditional 8-bit MCU application as well as some traditional 4-bit applications (Base-Line family), dedicated logic replacement and low-end DSP applications (High-End family). These features and price-performance mix make PICmicro MCUs an attractive solution for most applications. DS31001A-page 1-2 © 1997 Microchip Technology Inc. Section 1. Introduction 1.2 1 Manual Objective 1. 2. 3. Base-Line: 12-bit Instruction Word length Mid-Range: 14-bit Instruction Word length High-End: 16-bit Instruction Word length This manual focuses on the Mid-Range devices, which are also referred to as the PIC16CXXX PIC16CXXX MCU family. The operation of the PIC16CXXX PIC16CXXX MCU family architecture and peripheral modules is explained, but does not cover the specifics of each device. Therefore, it is not intended to replace the device data sheets, but complement them. In other words, this guide supplies the general details and operation of the PICmicro architecture and peripheral modules, while the data sheet s give specific details such as device memory mapping. Initialization examples are given throughout this manual. These examples sometimes need to be written as device specific as opposed to family generic, though they are valid for most other devices. Some modifications may be required for devices with variations in register file mappings. Note: © 1997 Microchip Technology Inc. The first few Mid-Range devices have minor device variations when compared to this general description. We have tried to describe these variations throughout this manual. Please refer to the specific device data sheet for complete information on the device. DS31001A-page 1-3 Introduction PICmicro devices are grouped by the size of their Instruction Word. The three current PICmicro families are: PICmicro MID-RANGE MCU FAMILY 1.3 Device Structure Each part of a device can be placed into one of three groups: 1. 2. 3. 1.3.1 Core Peripherals Special Features The Core The core pertains to the basic features that are required to make the device operate. These include: 1. 2. 3. 4. 5. 6. 7. 1.3.2 Device Oscillator Reset logic CPU (Central Processing Unit) operation ALU (Arithmetic Logical Unit) operation Device memory map organization Interrupt operation Instruction set Revision "DS31002A DS31002A" Revision "DS31003A DS31003A" Revision "DS31005A DS31005A" Revision "DS31005A DS31005A" Revision "DS31006A DS31006A" Revision "DS31008A DS31008A" Revision "DS31029A DS31029A" Peripherals Peripherals are the features that add a differentiation from a microprocessor. These ease in interfacing to the external world (such as general purpose I/O, LCD drivers, A/D inputs, and PWM outputs), and internal tasks such as keeping different time bases (such as timers). The peripherals that are discussed are: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. DS31001A-page 1-4 General purpose I/O Timer0 Timer1 Timer2 Capture, Compare, and PWM (CCP) Synchronous Serial Port (SSP) Basic Synchronous Serial Port (SSP) Master Synchronous Serial Port (MSSP) USART (SCI) Voltage References Comparators 8-bit Analog to Digital (A/D) Basic 8-bit Analog to Digital (A/D) 10-bit Analog to Digital (A/D) Slope Analog to Digital (A/D) w/ Thermister Liquid Crystal Display (LCD) Drivers Parallel Slave Port (PSP) Revision "DS31009A DS31009A" Revision "DS31011A DS31011A" Revision "DS31012A DS31012A" Revision "DS31013A DS31013A" Revision "DS31014A DS31014A" Revision "DS31015A DS31015A" Revision "DS31016A DS31016A" Revision "DS31017A DS31017A" Revision "DS31018A DS31018A" Revision "DS31019A DS31019A" Revision "DS31020A DS31020A" Revision "DS31021A DS31021A" Revision "DS31022A DS31022A" Revision "DS31023A DS31023A" Revision "DS31024A DS31024A" Revision "DS31025A DS31025A" Revision "DS31010A DS31010A" © 1997 Microchip Technology Inc. Section 1. Introduction 1.3.3 1 Special Features · Decrease system cost · Increase system reliability · Increase design flexibility The Mid-Range PICmicro MCUs offer several features that help achieve these goals. The special features discussed are: 1. 2. 3. 4. 5. 6. 7. Device Configuration bits On-chip Power-on Reset (POR) Brown-out Reset (BOR) logic Watchdog Timer Low power mode (Sleep) Internal RC device oscillator In-Circuit Serial ProgrammingTM (ICSPTM) © 1997 Microchip Technology Inc. Revision "DS31027A DS31027A" Revision "DS31003A DS31003A" Revision "DS31003A DS31003A" Revision "DS31026A DS31026A" Revision "DS31026A DS31026A" Revision "DS31002A DS31002A" Revision "DS31028A DS31028A" DS31001A-page 1-5 Introduction Special features are the unique features that help to do one or more of the following things: PICmicro MID-RANGE MCU FAMILY 1.4 Development Support Microchip offers a wide range of development tools that allow users to efficiently develop and debug application code. Microchip's development tools can be broken down into four categories: 1. 2. 3. 4. Code generation Software debug Device programmer Product evaluation boards All tools developed by Microchip operate under the MPLABTM Integrated Development Environment (IDE), while some third party tools may not. The code generation tools include: · MPASM · MPLAB-C · MP-DriveWayTM These software development programs include device header files. Each header file defines the register names (as shown in the device data sheet) to the specified address or bit location. Using the header files eases code migration, and reduces the tediousness of memorizing a register's address or a bit's position in a register. Note: Microchip strongly recommends that the supplied header files be used in the source code of your program. This eases code migration as well as increases the quality and depth of the technical support that Microchip can offer. Tools which ease in debugging software are: · PICMASTER® In-Circuit Emulator · ICEPIC In-Circuit Emulator · MPLAB-SIM Software Simulator After generating and debugging the application software, the device will need to be programmed. Microchip offers two levels of programmers: 1. 2. PICSTART® Plus programmer PROMATE® II programmer Demonstration boards allow the developer of software code to evaluate the capability and suitability of the device to the application. The demo boards offered are: · · · · PICDEM-1 PICDEM-2 PICDEM-3 PICDEM-14A PICDEM-14A A full description of each of Microchip's development tools is discussed in the "Development Tools" section. As new tools are developed, product briefs and user guides may be obtained from the Microchip web site (www.microchip.com) or from your local Microchip Sales Office. Code development recommendations and techniques are provided in the "Code Development" section. Microchip offers other reference tools to speed the development cycle. These include: · · · · · · Application Notes Reference Designs Microchip web site Microchip BBS Local Sales Offices with Field Application Support Corporate Support Line Additional avenues of assistance can be found in many Web User Groups including the MIT reflector PIClist. The Microchip web site lists other sites that may be useful references. DS31001A-page 1-6 © 1997 Microchip Technology Inc. Section 1. Introduction 1.5 1 Device Varieties · · · · · Memory technology Operating voltage Operating temperature range Operating frequency Packaging Microchip has a large number of options and option combinations, one of which should fulfill your requirements. 1.5.1 Memory Varieties Memory technology has no effect on the logical operation of a device. Due to the different processing steps required, some electrical characteristics may vary between devices with the same feature set/pinout but with different memory technologies. An example is the electrical characteristic VIL (Input Low Voltage), which may have some difference between a typical EPROM device and a typical ROM device. Each device has a variety of frequency ranges and packaging options available. Depending on application and production requirements, the proper device options can be identified using the information in the Product Selection System section at the end of each data sheet. When placing orders, please use the "Product Identification System" at the back of the data sheet to specify the correct part number. When discussing the functionality of the device, the memory technology and the voltage range do not matter. Microchip offers three program memory types. The memory type is designated in the part number by the first letter(s) after the family affiliation designators. 1. 2. 3. 1.5.1.1 C, as in PIC16CXXX PIC16CXXX. These devices have EPROM type memory. CR, as in PIC16CRXXX PIC16CRXXX. These devices have ROM type memory. F, as in PIC16FXXX PIC16FXXX. These devices have Flash type memory. EPROM Microchip focuses on Erasable Programmable Read Only Memory (EPROM) technology to give the customers flexibility throughout their entire design cycle. With this technology Microchip offers various packaging options as well as services. 1.5.1.2 Read Only Memory (ROM) Devices Microchip offers a masked Read Only Memory (ROM) version of several of the highest volume parts, thus giving customers a lower cost option for high volume, mature products. ROM devices do not allow serialization information in the program memory space. For information on submitting ROM code, please contact your local Microchip sales office. 1.5.1.3 Flash Memory Devices These devices are electrically erasable, and can therefore be offered in a low cost plastic package. Being electrically erasable, these devices can be both erased and reprogrammed without removal from the circuit. A device will have the same specifications whether it is used for prototype development, pilot programs, or production. © 1997 Microchip Technology Inc. DS31001A-page 1-7 Introduction Once the functional requirements of the device are specified, some other decisions need to be made. These include: PICmicro MID-RANGE MCU FAMILY 1.5.2 Operating Voltage Range Options All Mid-Range PICmicroTM MCUs operate over the standard voltage range. Devices are also offered which operate over an extended voltage range (and reduced frequency range). Table 1-1 shows all possible memory types and voltage range designators for the PIC16CXXX PIC16CXXX MCU family. The designators are in bold typeface. Table 1-1: Device Memory Type and Voltage Range Designators Voltage Range Memory Type Standard EPROM ROM Flash Extended PIC16CXXX PIC16CXXX PIC16CRXXX PIC16CRXXX PIC16FXXX PIC16FXXX PIC16LCXXX PIC16LCXXX PIC16LCRXXX PIC16LCRXXX PIC16LFXXX PIC16LFXXX Note:Not all memory types may be available for a particular device. As you can see in Table 1-2, Microchip specifications its extended range devices at a more conservative voltage range until device characterization has ensured they will be able to meet the goal of their final design specifications. Table 1-2: Typical Voltage Ranges for Each Device Type Typical Voltage Range (1) EPROM ROM Flash Standard Extended C 4.5 - 6.0V CR 4.5 - 6.0V F 4.5 - 6.0V Before device characterization LC 3.0 - 6.0V LCR 3.0 - 6.0V LF 3.0 - 6.0V Final specification (2) LC 2.5 - 6.0V LCR 2.5 - 6.0V LF 2.0 - 6.0V Note 1: Devices fabricated in Microchip's 120K Process Technology will have a maximum limit on VDD of 5.5V. New device data sheets will specify Microchip's technology designation 2: This voltage range depends on the results of device characterization. DS31001A-page 1-8 © 1997 Microchip Technology Inc. Section 1. Introduction 1.5.3 1 Packaging Varieties The first is a device with an erasure window. Typically these are found in packages with a ceramic body. These devices are used for the development phase, since the device's program memory can be erased and reprogrammed many times. The second package type is a low cost plastic package. This package type is used in production where device cost is to be kept to a minimum. Lastly, there is the DIE option. A DIE is an unpackaged device that has been tested. DIEs are used in low cost designs and designs where board space is at a minimum. Table 1-3 shows a quick summary of this. Table 1-3: Typical Package Uses Package Type Typical Usage Windowed Plastic DIE Development Mode Production Special Applications, such as those which require minimum board space © 1997 Microchip Technology Inc. DS31001A-page 1-9 Introduction Depending on the development phase of your project, one of three package types would be used: PICmicro MID-RANGE MCU FAMILY 1.5.3.4 UV Erasable Devices The UV erasable version of EPROM program memory devices is optimal for prototype development and pilot programs. These devices can be erased and reprogrammed to any of the configuration modes. Third party programmers are also available; refer to Microchip's Third Party Guide (DS00104 DS00104) for a list of sources. The amount of time required to completely erase a UV erasable device depends on: the wavelength of the light, its intensity, distance from UV source, the process technology of the device (how small are the memory cells). Note: 1.5.3.5 Fluorescent lights and sunlight both emit ultraviolet light at the erasure wavelength. Leaving a UV erasable device's window uncovered could cause, over time, the devices memory cells to become erased. The erasure time for a fluorescent light is about three years, while sunlight requires only about one week. To prevent the memory cells from losing data, an opaque label should be placed over the erasure window. One-Time-Programmable (OTP) Devices The availability of OTP devices is especially useful for customers expecting code changes and updates. OTP devices, packaged in plastic packages, permit the user to program them once. In addition to the program and data EPROM memories, the configuration bits must be programmed. 1.5.3.6 Flash Devices A Flash device allows its memory to be changed by an electric charge. This means that the system can be designed so that programming may be performed in-circuit. Since no window is required, the lower cost plastic packages can used for these devices. 1.5.3.7 EEPROM Devices An EEPROM device allows its memory to be erased by an electric charge. This means that the system can be designed so that erasure and reprogramming may be performed in-circuit. Since no window is required, the lower cost plastic packages can used for these devices. DS31001A-page 1-10 © 1997 Microchip Technology Inc. Section 1. Introduction 1.5.3.8 1 ROM Devices 1.5.3.9 DIE The DIE option allows the board size to become as small as physically possible. The DIE Support document (DS30258 DS30258) explains general information about using and designing with DIE. There are also individual specification sheets that detail DIE specific information. Manufacturing with DIE requires special knowledge and equipment. This means that the number of manufacturing houses that support DIE will be limited. If you decide to use the DIE option, please research your manufacturing sites to ensure that they will be able to meet the specialized requirements of DIE use. 1.5.3.10 Specialized Services For OTP customers with established code, Microchip offers two specialized services. These two services, Quick Turn Production Programming and Serialized Quick Turn Production Programming, that allow customers to shorten their manufacturing cycle time. 1.5.3.11 Quick Turn Production (QTP) Programming Microchip offers this programming service for factory production orders. This service is made available for users who choose not to program a medium to high quantity of units and whose code patterns have stabilized. The devices are identical to the OTP devices but with all EPROM locations and configuration options already programmed by the factory. Certain code and prototype verification procedures apply before production shipments are available. Please contact your local Microchip sales office for more details. 1.5.3.12 Serialized Quick Turn Production (SQTPSM) Programming Microchip offers a this unique programming service where a few user-defined locations in each device are programmed with different serial numbers. The serial numbers may be random, pseudo-random or sequential. Serial programming allows each device to have a unique number which can serve as an entry-code, password or ID number. © 1997 Microchip Technology Inc. DS31001A-page 1-11 Introduction ROM devices have their program memory fixed at the time of the silicon manufacture. Since the program memory cannot be changed, the device can be housed in the lower cost plastic package. PICmicro MID-RANGE MCU FAMILY 1.6 Style and Symbol Conventions Throughout this document, certain style and font format changes are used. Most format changes imply a distinction should be made for the emphasized text. The MCU industry has many symbols and non-conventional word definitions/abbreviations. Table 1-4 provides a description for many of the conventions contained in this document. A glossary is provided in the "Glossary" section, which contains more word and abbreviation definitions that are used throughout this manual. 1.6.1 Document Conventions Table 1-4 defines some of the symbols and terms used throughout this manual. Table 1-4: Document Conventions Symbol or Term Description set clear reset To force a bit/register to a value of logic `1'. To force a bit/register to a value of logic `0'. 1) To force a register/bit to its default state. 2) A condition in which the device places itself after a device reset occurs. Some bits will be forced to `0' (such as interrupt enable bits), while others will be forced to `1' (such as the I/O data direction bits). 0xnn or nnh Designates the number `nn' in the hexadecimal number system. These conventions are used in the code examples. B'bbbbbbbb' Designates the number `bbbbbbbb' in the binary number system. This convention is used in the text and in figures and tables. R-M-W Read - Modify - Write. This is when a register or port is read, then the value is modified, and that value is then written back to the register or port. This action can occur from a single instruction (such as bit set file, BSF) or a sequence of instructions. : (colon) Used to specify a range, or the concatenation of registers / bits / pins. An example is TMR1H:TMR1L is the concatenation of two 8-bit registers to form a 16-bit timer value, while SSPM3:SSPM0 are 4-bits used to specify the mode of the SSP module. Concatenation order (left-right) usually specifies a positional relationship (MSb to LSb, higher to lower). Specifies bit(s) locations in a particular register. An example is SSPCON (or SSPCON) specifies the register and associated bits or bit positions. Courier Font Used for code examples, binary numbers, and for Instruction Mnemonics in the text. Times Font Used for equations and variables. Times, Bold Font, Used in explanatory text for items called out from a graphic/equaItalics tion/example. Note Notes present information that we wish to reemphasize, either to help you avoid a common pitfall, or make you aware of operating differences between some device family members. A Note is always in a shaded box (as below), unless used in a table, where it is at the bottom of the table (as in this table). Note: This is a note in a note box. Caution(1) A caution statement describes a situation that could potentially damage software or equipment. Warning(1) A warning statement describes a situation that could potentially cause personnel harm. Note 1: The information in a caution or a warning is provided for your protection. Please read each caution and warning carefully. DS31001A-page 1-12 © 1997 Microchip Technology Inc. Section 1. Introduction 1.6.2 1 Electrical Specifications The "Electrical Specifications" section shows all the specifications that are documented for all devices. No one device has all these specifications. This section is intended to let you know the types of parameters that Microchip specifies. The value of each specification is device dependent, though we strongly attempt to keep them consistent across all devices. Table 1-5: Electrical Specification Parameter Numbering Convention Parameter Number Format Comment Dxxx DC Specification Axxx DC Specification for Analog peripherals xxx Timing (AC) Specification PDxxx Device Programming DC Specification Pxxx Device Programming Timing (AC) Specification Legend: xxx: represents a number. © 1997 Microchip Technology Inc. DS31001A-page 1-13 Introduction Throughout this manual there will be references to electrical specification parameter numbers. A parameter number represents a unique set of characteristics and conditions that is consistent between every data sheet, though the actual parameter value may vary from device to device. PICmicro MID-RANGE MCU FAMILY 1.7 Related Documents Microchip, as well as other sources, offers additional documentation which can aid in your development with PICmicro MCUs. These lists contain the most common documentation but other documents may also be available. Please check the Microchip web site (www.microchip.com) for the latest published technical documentation. 1.7.1 Microchip Documentation The following documents are available from Microchip. Many of these documents provide application specific information that give actual examples of using, programming and designing with PICmicro MCUs. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. DS31001A-page 1-14 MPASM User's Guide (DS33014 DS33014) This document explains how to use Microchip's MPASM assembler. MPLABTM-C Compiler User's Guide (DS51014 DS51014) This document explains how to use Microchip's MPLAB-C C compiler. MPLAB User's Guide (DS51025 DS51025) This document explains how to use Microchip's MPLAB Integrated Development Environment. MPLAB Editor User's Guide (DS30420 DS30420) This document explains how to use Microchip's MPLAB built-in editor. PICMASTER® User's Guide (DS30421 DS30421) This document explains how to use Microchip's PICMASTER In-Circuit Emulator. MPSIM User's Guide (DS30027 DS30027) This document explains how to use Microchip's MPLAB Simulator. PRO MATE® User's Guide (DS30082 DS30082) This document explains how to use Microchip's PRO MATE universal programmer. PICSTART®-Plus User's Guide (DS51028 DS51028) This document explains how to use Microchip's PICSTART-Plus low-cost universal programmer. fuzzyTECH®-MP User's Guide (DS30389 DS30389) This document explains how to use the fuzzyTECH-MP fuzzy logic code generator. MP-DriveWayTM User's Guide (DS51027 DS51027) This document explains how to use the MP-DriveWay code generator. fuzzyTECH-MP Fuzzy Logic Handbook (DS30238 DS30238) This document explains the basics of fuzzyTECH-MP fuzzy. Embedded Control Handbook Volume I (DS00092 DS00092) This document contains a plethora of application notes. This is useful for insight on how to use the device (or parts of it) as well as getting started on your particular application due to the availability of extensive code files. Embedded Control Handbook Volume II (DS00167 DS00167) This document contains the Math Libraries for PICmicro MCUs. In-Circuit Serial Programming GuideTM (DS30277 DS30277) This document discusses implementing In-Circuit Serial Programming. PICDEM-1 User's Guide (DS351079 DS351079) This document explains how to use Microchip's PICDEM-1 demo board. PICDEM-2 User's Guide (DS30374 DS30374) This document explains how to use Microchip's PICDEM-2 demo board. PICDEM-3 User's Guide (DS33015 DS33015) This document explains how to use Microchip's PICDEM-3 demo board. Third Party Guide (DS00104 DS00104) This document lists Microchip's third parties, as well as various consultants. DIE Support (DS30258 DS30258) This document gives information on using Microchip products in DIE form. © 1997 Microchip Technology Inc. Section 1. Introduction 1.7.2 1 Third Party Documentation DOCUMENT LANGUAGE The PIC16C5X PIC16C5X Microcontroller: A Practical Approach to Embedded Control Bill Rigby/ Terry Dalby, Tecksystems Inc. 0-9654740-0-3. English Easy PIC'n David Benson, Square 1 Electronics 0-9654162-0-8. English A Beginners Guide to the Microchip PIC® Nigel Gardner, Bluebird Electronics 1-899013-01-6. English PIC Microcontroller Operation and Applications DN de Beer, Cape Technikon . English Digital Systems and Programmable Interface Controllers WP Verburg, Pretoria Technikon . English Mikroprozessor PIC16C5X PIC16C5X Michael Rose, Hüthig 3-7785-2169-1.German Mikroprozessor PIC17C42 PIC17C42 Michael Rose, Hüthig 3-7785-2170-5.German Les Microcontrolleurs PIC et mise en oeuvre Christian Tavernier, Dunod 2-10-002647-X 2-10-002647-X .French Micontrolleurs PIC a structure RISC C.F. Urbain, Publitronic 2-86661-058-X 2-86661-058-X .French New Possibilities with the Microchip PIC RIGA . Russian © 1997 Microchip Technology Inc. DS31001A-page 1-15 Introduction There are several documents available from third party sources around the world. Microchip does not review these documents for technical accuracy, however they may be a helpful source for understanding the operation of Microchip MCU devices. This is not necessarily a complete list, but are the documents that we were aware of at the time of printing. For more information on how to contact some of these sources, as well as any new sources that we become aware of, please visit the Microchip web site. PICmicro MID-RANGE MCU FAMILY DOCUMENT LANGUAGE PIC16C5X/71/84 PIC16C5X/71/84 Development and Design, Part 1 United Tech Electronic Co. Ltd 957-21-0807-7. Chinese PIC16C5X/71/84 PIC16C5X/71/84 Development and Design, Part 2 United Tech Electronic Co. Ltd 957-21-1152-3. Chinese PIC16C5X/71/84 PIC16C5X/71/84 Development and Design, Part 3 United Tech Electronic Co. Ltd 957-21-1187-6. Chinese PIC16C5X/71/84 PIC16C5X/71/84 Development and Design, Part 4 United Tech Electronic Co. Ltd 957-21-1251-1. Chinese PIC16C5X/71/84 PIC16C5X/71/84 Development and Design, Part 5 United Tech Electronic Co. Ltd 957-21-1257-0. Chinese PIC16C84 PIC16C84 MCU Architecture and Software Development ICC Company 957-8716-79-6. Chinese DS31001A-page 1-16 © 1997 Microchip Technology Inc. Section 1. Introduction 1.8 1 Related Application Notes Title Application Note # A Comparison of Low End 8-bit Microcontrollers AN520 AN520 PIC16C54A PIC16C54A EMI Results AN577 AN577 Continuous Improvement AN503 AN503 Improving the Susceptibility of an Application to ESD AN595 AN595 Plastic Packaging and the Effects of Surface Mount Soldering Techniques AN598 AN598 © 1997 Microchip Technology Inc. DS31001A-page 1-17 Introduction This section lists application notes that are related to this section of the manual. These application notes may not be written specifically for the PIC16CXXX PIC16CXXX Mid-Range MCU family (that is they may be written for the Base-Line, or the High-End families), but the concepts are pertinent, and could be used (with modification and possible limitations). The current application notes related to an introduction to Microchip's PICmicro MCUs are: PICmicro MID-RANGE MCU FAMILY 1.9 Revision History Revision A This is the initial released revision of Microchip's PICmicro MCUs Introduction. DS31001A-page 1-18 © 1997 Microchip Technology Inc. M Section 2. Oscillator HIGHLIGHTS This section of the manual contains the following major topics: Introduction .2-2 Oscillator Configurations .2-2 Crystal Oscillators / Ceramic Resonators .2-4 External RC Oscillator.2-12 Internal 4 MHz RC Oscillator .2-13 Effects of Sleep Mode on the On-chip Oscillator .2-17 Effects of Device Reset on the On-chip Oscillator .2-17 Design Tips .2-18 Related Application Notes.2-19 Revision History .2-20 © 1997 Microchip Technology Inc. DS31002A DS31002A page 2-1 Oscillator 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2 PICmicro MID-RANGE MCU FAMILY 2.1 Introduction The internal oscillator circuit is used to generate the device clock. The device clock is required for the device to execute instructions and for the peripherals to function. Four device clock periods generate one internal instruction clock (TCY) cycle. There are up to eight different modes which the oscillator may have. There are two modes which allow the selection of the internal RC oscillator clock out (CLKOUT) to be driven on an I/O pin, or allow that I/O pin to be used for a general purpose function. The oscillator mode is selected by the device configuration bits. The device configuration bits are nonvolatile memory locations and the operating mode is determined by the value written during device programming. The oscillator modes are: · · · · · · · · LP XT HS RC EXTRC EXTRC INTRC INTRC Low Frequency (Power) Crystal Crystal/Resonator High Speed Crystal/Resonator External Resistor/Capacitor (same as EXTRC with CLKOUT) External Resistor/Capacitor External Resistor/Capacitor with CLKOUT Internal 4 MHz Resistor/Capacitor Internal 4 MHz Resistor/Capacitor with CLKOUT These oscillator options are made available to allow a single device type the flexibility to fit applications with different oscillator requirements. The RC oscillator option saves system cost while the LP crystal option saves power. Configuration bits are used to select the various options. For more details on the device configuration bits, see the "Device Characteristics" section. 2.2 Oscillator Configurations 2.2.1 Oscillator Types Mid-Range devices can have up to eight different oscillator modes. The user can program up to three device configuration bits (FOSC2, FOSC1 and FOSC0) to select one of these eight modes: · · · · · · · · LP XT HS RC EXTRC EXTRC INTRC INTRC Low Frequency (Power) Crystal Crystal/Resonator High Speed Crystal/Resonator External Resistor/Capacitor (same as EXTRC with CLKOUT) External Resistor/Capacitor External Resistor/Capacitor with CLKOUT Internal 4 MHz Resistor/Capacitor Internal 4 MHz Resistor/Capacitor with CLKOUT The main difference between the LP, XT, and HS modes is the gain of the internal inverter of the oscillator circuit which allows the different frequency ranges. Table 2-1 and Table 2-2 give information to aid in selecting an oscillator mode. In general, use the oscillator option with the lowest possible gain which still meet specifications. This will result in lower dynamic currents (IDD). The frequency range of each oscillator mode is the recommended (tested) frequency cutoffs, but the selection of a different gain mode is acceptable as long as a thorough validation is performed (voltage, temperature, component variations (Resistor, Capacitor, and internal microcontroller oscillator circuitry). The RC mode and the EXTRC with CLKOUT mode have the same functionality. They are named like this to help describe their operation vs. the other oscillator modes. DS31002A-page 2-2 © 1997 Microchip Technology Inc. Section 2. Oscillator Table 2-1: Selecting the Oscillator Mode for Devices with FOSC1:FOSC0 Configuration bits OSC FOSC1:FOSC0 Mode RC 1 0 HS 0 1 XT 0 0 LP Table 2-2: 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 © 1997 Microchip Technology Inc. - Least expensive solution for device oscillation (only an external resistor and capacitor is required). Most variation in time-base. Device's default mode. High Gain High frequency application. Oscillator circuit's mode consumes the most current of the three crystal modes. Medium Gain Standard crystal/resonator frequency. Oscillator circuit's mode consumes the middle current of the three crystal modes. Low Gain Low power/frequency applications. Oscillator circuit's mode consumes the least current of the three crystal modes. Selecting the Oscillator Mode for Devices with FOSC2:FOSC0 Configuration bits FOSC2:FOSC0 1 1 1 Comment OSC Mode EXTRC with CLKOUT EXTRC OSC Feedback Inverter Gain Comment - Inexpensive solution for device oscillation. Most variation in timebase. CLKOUT is enabled on pin. Device's default mode