Академический Документы
Профессиональный Документы
Культура Документы
PICmicro
Mid-Range MCU Family
Reference Manual
M
Internationally Recognized Quality
System Certifications
Microchips Quality System embodies the requirements
of 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.
Microchip received ISO 9001 Quality System certification for its worldwide headquarters, design, and wafer
fabrication facilities in January, 1997. Our field-programmable PICmicro 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.
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
DS33023A-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
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
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
DS33023A-page iv
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
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
DS33023A-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
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
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
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
DS33023A-page vi
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
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
17-1
Introduction .....................................................................................................................................................17-2
Control Register .............................................................................................................................................17-4
SPI Mode ........................................................................................................................................................17-9
SSP I2C 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
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
DS33023A-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
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
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
DS33023A-page viii
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
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
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
DS33023A-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
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
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
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
DS33023A-page x
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
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
31-1
Introduction .....................................................................................................................................................31-2
Characterization vs. Electrical Specification ...................................................................................................31-2
DC and AC Characteristics Graphs and Tables .............................................................................................31-2
Revision History ...........................................................................................................................................31-22
DS33023A-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
33-1
34-1
35-1
DS33023A-page xii