PIC18F86K22-E/PT Microchip Technology, PIC18F86K22-E/PT Datasheet

no-image

PIC18F86K22-E/PT

Manufacturer Part Number
PIC18F86K22-E/PT
Description
64kB Flash, 4kB RAM, 1kB EE, NanoWatt XLP, GP 80 TQFP 12x12x1mm TRAY
Manufacturer
Microchip Technology
Series
PIC® XLP™ 18Fr
Datasheet

Specifications of PIC18F86K22-E/PT

Core Processor
PIC
Core Size
8-Bit
Speed
64MHz
Connectivity
EBI/EMI, I²C, LIN, SPI, UART/USART
Peripherals
Brown-out Detect/Reset, LVD, POR, PWM, WDT
Number Of I /o
69
Program Memory Size
64KB (32K x 16)
Program Memory Type
FLASH
Eeprom Size
1K x 8
Ram Size
4K x 8
Voltage - Supply (vcc/vdd)
1.8 V ~ 5.5 V
Data Converters
A/D 24x12b
Oscillator Type
Internal
Operating Temperature
-40°C ~ 125°C
Package / Case
80-TQFP
Lead Free Status / Rohs Status
Lead free / RoHS Compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC18F86K22-E/PT
Manufacturer:
Microchip Technology
Quantity:
10 000
PIC18F87K22 Family
Data Sheet
64/80-Pin, High-Performance,
1-Mbit Enhanced Flash Microcontrollers
with 12-Bit A/D and
nanoWatt XLP Technology
 2009-2011 Microchip Technology Inc.
DS39960D

Related parts for PIC18F86K22-E/PT

PIC18F86K22-E/PT Summary of contents

Page 1

... Enhanced Flash Microcontrollers  2009-2011 Microchip Technology Inc. PIC18F87K22 Family 64/80-Pin, High-Performance, with 12-Bit A/D and nanoWatt XLP Technology Data Sheet DS39960D ...

Page 2

... Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. © 2009-2011, Microchip Technology Incorporated, Printed in the U ...

Page 3

... PIC18F66K22 64K 32,768 PIC18F67K22 128K 65,536 PIC18F85K22 32K 16,383 PIC18F86K22 64K 32,768 PIC18F87K22 128K 65,536  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Special Microcontroller Features: • Operating Voltage Range: 1.8V to 5.5V • On-Chip 3.3V Regulator • Operating Speed MHz • ...

Page 4

... SPI (supports all four SPI modes C™ Master and Slave modes • Two Enhanced Addressable USART modules: - LIN/J2602 support - Auto-Baud Detect (ABD) • 12-Bit A/D Converter with Channels: - Auto-acquisition and Sleep operation - Differential input mode of operation • Integrated Voltage Reference  2009-2011 Microchip Technology Inc. ...

Page 5

... RF6/AN11/C1INA RF5/AN10/CV /C1INB REF RF4/AN9/C2INA RF3/AN8/C2INB/CTMUI RF2/AN7/C1OUT Note 1: The ECCP2 pin placement depends on the CCP2MX Configuration bit setting and whether the device is in Microcontroller or Extended Microcontroller mode. 2: Not available on the PIC18F65K22 and PIC18F85K22 devices.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY ...

Page 6

... Note 1: The ECCP2 pin placement depends on the CCP2MX Configuration bit setting and whether the device is in Microcontroller or Extended Microcontroller mode. 2: Not available on the PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit (CONFIG3H<1>). DS39960D-page PIC18F85K22 9 10 PIC18F86K22 11 PIC18F87K22 RJ2/WRL 60 RJ3/WRH 59 RB0/INT0/FLT0 58 RB1/INT1 57 RB2/INT2/CTED1 ...

Page 7

... Appendix A: Revision History............................................................................................................................................................. 533 Appendix B: Migration From PIC18F87J11 and PIC18F8722 to PIC18F87K22................................................................................ 534 Index .................................................................................................................................................................................................. 535 The Microchip Web Site ..................................................................................................................................................................... 547 Customer Change Notification Service .............................................................................................................................................. 547 Customer Support .............................................................................................................................................................................. 547 Reader Response .............................................................................................................................................................................. 548 Product Identification System ............................................................................................................................................................ 549  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY DS39960D-page 7 ...

Page 8

... When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are using. Customer Notification System Register on our web site at www.microchip.com DS39960D-page 8 to receive the most current information on all of our products.  2009-2011 Microchip Technology Inc. ...

Page 9

... This document contains device-specific information for the following devices: • PIC18F65K22 • PIC18F85K22 • PIC18F66K22 • PIC18F86K22 • PIC18F67K22 • PIC18F87K22 This family combines the traditional advantages of all PIC18 microcontrollers – namely, high computational performance and a rich feature set – with an extremely competitive price point ...

Page 10

... CPU. • The module is a 100-year clock and calendar with automatic leap year detection. The range of the clock is from 00:00:00 (midnight) on January 1, 2000 to 23:59:59 on December 31, 2099.  2009-2011 Microchip Technology Inc. for ...

Page 11

... The devices are differentiated from each other in these ways: • Flash Program Memory: - PIC18FX5K22 (PIC18F65K22 and PIC18F85K22) – 32 Kbytes - PIC18FX6K22 (PIC18F66K22 and PIC18F86K22) – 64 Kbytes - PIC18FX7K22 (PIC18F67K22 and PIC18F87K22) – 128 Kbytes • Data RAM: - All devices except PIC18FX5K22 – 4 Kbytes - PIC18FX5K22 – 2 Kbytes • ...

Page 12

... Two MSSPs and two Enhanced USARTs (EUSART) 16 Input Channels POR, BOR, RESET Instruction, Stack Full, Stack Underflow, MCLR, WDT (PWRT, OST) 75 Instructions, 83 with Extended Instruction Set Enabled 64-Pin QFN, 64-Pin TQFP PIC18F85K22 PIC18F86K22 DC – 64 MHz 32K 64K ( Mbytes with Extended Memory) 16,384 32,768 ...

Page 13

... I/O port pin descriptions. Note 1: RA6 and RA7 are only available as digital I/O in select oscillator modes. For more information, see 2: Configurations”. Unimplemented on the PIC18F65K22. 3:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Data Bus<8> Data Latch 8 8 Data Memory (2/4 Kbytes) ...

Page 14

... MSSP1/2 EUSART2 PORTA (1,2) RA0:RA7 PORTB 12 (1) RB0:RB7 4 PORTC Access Bank RC0:RC7 (1) 12 PORTD (1) RD0:RD7 PORTE (1) RE0:RE7 8 PORTF PRODL (1) RF1:RF7 8 PORTG 8 8 (1) RG0:RG5 8 PORTH (1) 8 RH0:RH7 PORTJ (1) RJ0:RJ7 Comparator 1/2/3 for Section 3.0 “Oscillator Configurations”  2009-2011 Microchip Technology Inc. ...

Page 15

... Alternate assignment for ECCP2 when the CCP2MX Configuration bit is cleared. 2: Not available on PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 4: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Buffer Type Type Master Clear (input) or programming voltage (input This pin is an active-low Reset to the device ...

Page 16

... Analog Input Timer1 clock input Timer3 external clock gate input. I Analog High/Low-Voltage Detect input. See the OSC2/CLKO/RA6 pin. See the OSC1/CLKI/RA7 pin. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 17

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 4: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Buffer Type Type PORTB is a bidirectional I/O port. PORTB can be software programmed for internal weak pull-ups on all inputs. ...

Page 18

... I/O ST EUSART synchronous clock (see related RX1/DT1). I/O ST Digital I/ EUSART asynchronous receive. I/O ST EUSART synchronous data (see related TX1/CK1). CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description 2 C™ mode  2009-2011 Microchip Technology Inc. ...

Page 19

... Alternate assignment for ECCP2 when the CCP2MX Configuration bit is cleared. 2: Not available on PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 4: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Buffer Type Type PORTD is a bidirectional I/O port. I/O ST Digital I/O ...

Page 20

... ECCP1 PWM Output B. I/O S/T Capture 6 input/Compare 6 output/PWM6 output. I/O ST Digital I/O. I/O ST Capture 2 input/Compare 2 output/PWM2 output. O — ECCP2 PWM Output A. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 21

... Alternate assignment for ECCP2 when the CCP2MX Configuration bit is cleared. 2: Not available on PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 4: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Buffer Type Type PORTF is a bidirectional I/O port. I/O ST Digital I/O ...

Page 22

... Timer5 external clock gate input. I/O ST Capture 5 input/Compare 5 output/PWM5 output. I Analog Analog Input 16. O — ECCP1 PWM Output D. I Analog Comparator 3 Input C. See the MCLR/RG5 pin. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 23

... Alternate assignment for ECCP2 when the CCP2MX Configuration bit is cleared. 2: Not available on PIC18F65K22 and PIC18F85K22 devices. 3: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 4: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Buffer Type Type P — ...

Page 24

... In certain oscillator modes, OSC2 pin outputs CLKO, which has 1/4 the frequency of OSC1 and denotes the instruction cycle rate. I/O TTL General purpose I/O pin. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 25

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type PORTA is a bidirectional I/O port. ...

Page 26

... In-Circuit Debugger and ICSP™ programming clock pin. I/O TTL Digital I/O. I TTL Interrupt-on-change pin. I/O ST In-Circuit Debugger and ICSP programming data pin. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 27

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type PORTC is a bidirectional I/O port. ...

Page 28

... External Memory Address/Data 4. I/O ST Digital I/ SPI data in I C™ data I/O. I/O TTL Parallel Slave Port data. I/O TTL External Memory Address/Data 5. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 29

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type I/O ST Digital I/O. ...

Page 30

... I/O TTL External Memory Address/Data 12. I/O ST Digital I/O. O — ECCP1 PWM Output C. I/O ST Capture 7 input/Compare 7 output/PWM7 output. I/O TTL External Memory Address/Data 13. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 31

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type I/O ST Digital I/O. ...

Page 32

... Comparator 1 Input B. I/O ST Digital I/O. I Analog Analog Input 11. I Analog Comparator 1 Input A. I/O ST Digital I/O. O Analog Analog Input SPI slave select input. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 33

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type PORTG is a bidirectional I/O port. ...

Page 34

... Comparator 1 Input D. I/O ST Digital I/O. I/O ST Capture 7 input/Compare 7 output/PWM7 output. O — ECCP1 PWM Output C. I Analog Analog Input 14. I Analog Comparator 1 Input C. CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 35

... Not available on PIC18F65K22 and PIC18F85K22 devices. 3: PSP is available only in Microcontroller mode. 4: The CC6, CCP7, CCP8 and CCP9 pin placement depends on the setting of the ECCPMX Configuration bit 5: (CONFIG3H<1>).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Pin Buffer Type Type I/O ST Digital I/O. ...

Page 36

... Positive supply for analog modules Enable for on-chip voltage regulator. Core logic power or external filter capacitor connection. P — External filter capacitor connection (regulator enabled/disabled). CMOS = CMOS compatible input or output Analog = Analog input O = Output OD = Open-Drain (no P diode to V Description ) DD  2009-2011 Microchip Technology Inc. ...

Page 37

... REF reference for analog modules is implemented The AV and AV pins must always be Note connected, regardless of whether any of the analog modules are being used. The minimum mandatory connections are shown in Figure 2-1.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY FIGURE 2- MCLR Pin”) ...

Page 38

... The DD may be beneficial. A typical Figure 2-1. Other circuit ) and fast signal transitions must IL (Figure 2-2). is replaced for normal run-time EXAMPLE OF MCLR PIN CONNECTIONS R1 R2 MCLR PIC18FXXKXX JP C1 and V specifications are met and V specifications are met. IL  2009-2011 Microchip Technology Inc. ...

Page 39

... Panasonic ECJ-4YB1C106K Murata GRM32DR71C106KA01L Murata GRM31CR61C106KC31L  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Some PIC18FXXKXX families, or some devices within a family, do not provide the option of enabling or disabling the on-chip voltage regulator: • Some devices (with the name, PIC18LFXXKXX) permanently disable the voltage regulator. ...

Page 40

... Channel Select” (i.e., PGCx/PGDx pins), programmed into the device, matches the physical connections for the ICSP to the Microchip debugger/emulator tool. For more information on available development tools connection requirements, refer to Section 30.0 “Development Support”.  2009-2011 Microchip Technology Inc Microchip ...

Page 41

... Unused I/O pins should be configured as outputs and driven to a logic low state. Alternatively, connect a 1 kΩ kΩ resistor unused pins and drive the SS output to logic low.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY FIGURE 2-5: (refer to Single-Sided and In-Line Layouts: for details). ...

Page 42

... PIC18F87K22 FAMILY NOTES: DS39960D-page 42  2009-2011 Microchip Technology Inc. ...

Page 43

... When the RA6 and RA7 pins are not used for an oscil- lator function or CLKOUT function, they are available as general purpose I/Os.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY To optimize power consumption when using EC/HS/ XT/LP/RC as the primary oscillator, the frequency input ...

Page 44

... INTSRC MFIOSEL FOSC<3:0> Setting 1101 1100 1011 1010 0101 0100 0011 0010 0001 0000 001x 100x (and OSCCON, OSCCON2) Peripherals CPU IDLEN Clock Control SCS<1:0> FOSC<3:0> IRCF<2:0>  2009-2011 Microchip Technology Inc. ...

Page 45

... INTSRC = OSCTUNE<7> and MFIOSEL = OSCCON2<0>. 5: Lowest power option for an internal source. 6:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The OSCTUNE register tuning and operation of the internal oscillator block. It also implements the PLLEN bit which controls the operation of the Phase Locked Loop (PLL) (see Frequency Multiplier” ...

Page 46

... MF-INTOSC is used in place of HF-INTOSC frequencies of 500 kHz, 250 kHz and 31.25 kHz 0 = MF-INTOSC is not used DS39960D-page 46 (1) (CONTINUED) (4) U-0 R/W-0 U-0 — SOSCGO — Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R-x R/W-0 MFIOFS MFIOSEL bit Bit is unknown ...

Page 47

... Center frequency; fast RC oscillator is running at the calibrated frequency 111111 • • • • 100000 = Minimum frequency  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 TUN4 TUN3 TUN2 U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared ...

Page 48

... The IDLEN bit (OSCCON<7>) determines if the device goes into Sleep mode or one of the Idle modes when the SLEEP instruction is executed.  2009-2011 Microchip Technology Inc. Design Operating Frequency 31.25-100 kHz 100 kHz to 4 MHz ...

Page 49

... This formula assumes that the new clock source is stable. Clock transitions are discussed in greater detail in Section 4.1.2 “Entering Power-Managed Modes”.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 3.4 RC Oscillator For timing-insensitive applications, the RC and RCIO Oscillator modes offer additional cost savings ...

Page 50

... DD CRYSTAL/CERAMIC RESONATOR OPERATION (HS OR HSPLL CONFIGURATION) OSC1 To Internal Logic XTAL ( Sleep OSC2 PIC18F87K22 ( Table 3-2 and Table 3-3 for initial values of ) may be required for AT S varies with the oscillator mode chosen.  2009-2011 Microchip Technology Inc. ...

Page 51

... This may be useful for customers who are concerned with EMI due to high-frequency crystals, or users who require higher clock speeds from an internal oscillator.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 3.5.3.1 HSPLL and ECPLL Modes The HSPLL and ECPLL modes provide the ability to ...

Page 52

... OSC2 functions as RA6, both for digital input and CPU”. output. Externally, this is identical to INTIO2 (Figure 3-9). 3-9). Both INTIO1 OSCILLATOR MODE I/O (OSC1) PIC18F87K22 OSC2 INTIO2 OSCILLATOR MODE I/O (OSC1) PIC18F87K22 I/O (OSC2) /4, OSC 3-8).  2009-2011 Microchip Technology Inc. ...

Page 53

... If the internally clocked timer value is much greater than expected, then the internal oscillator block is running too fast. To adjust for this, decrement the OSCTUNE register.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 3.6.4.3 Compensating with the CCP Module ...

Page 54

... For ROSEL (REVOCON<4>), the primary oscillator is available only when configured as the default via the Note 1: FOSC settings. This is regardless of whether the device is in Sleep mode. DS39960D-page 54 R/W-0 R/W-0 R/W-0 (1) ROSEL RODIV3 RODIV2 U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1)  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 RODIV1 RODIV0 bit Bit is unknown ...

Page 55

... I/O pin, RA6, direction is controlled by TRISA<6> See Section 5.0 “Reset” for time-outs due to Sleep and MCLR Reset. Note:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Real-Time Clock (RTC). Other features may be operat- ing that do not require a device clock source (i.e., MSSP slave, INTx pins and others) ...

Page 56

... PIC18F87K22 FAMILY NOTES: DS39960D-page 56  2009-2011 Microchip Technology Inc. ...

Page 57

... Note 1: Includes INTOSC (HF-INTOSC and MG-INTOSC) and INTOSC postscaler, as well as the LF-INTOSC 2: source.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The IDLEN bit (OSCCON<7>) controls CPU clocking, while the SCS<1:0> bits (OSCCON<1:0>) select the clock source. The individual modes, bit settings, clock ...

Page 58

... SOSCRUN bit is cleared, the OSTS bit is set and the primary clock is providing the clock. The IDLEN and SCS bits are not affected by the wake-up and the SOSC oscillator continues to run. Section 28.4 “Two-Speed Registers”.) Figure 4-1), the primary oscillator  2009-2011 Microchip Technology Inc. ...

Page 59

... TRANSITION TIMING FROM SEC_RUN MODE TO PRI_RUN MODE (HSPLL) Q1 SOSC OSC1 T PLL Clock Output CPU Clock Peripheral Clock Program Counter SCS<1:0> bits Changed Note 1024 OST OSC PLL 2: Clock transition typically occurs within 2-4 T  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY n-1 n (1) Clock Transition OSC OST (1) PLL ( ...

Page 60

... Status of MFIOFS or HFIOFS when INTOSC is Stable MFIOFS = 0, HFIOFS = 0 and clock source is LF-INTOSC x MFIOFS = 0, HFIOFS = 1 and clock source is HF-INTOSC 0 MFIOFS = 1, HFIOFS = 0 and clock source is MF-INTOSC 1 MFIOFS = 0, HFIOFS = 1 and clock source is HF-INTOSC 0 MFIOFS = 1, HFIOFS = 0 and clock source is MF-INTOSC Improper specifications are violated.  2009-2011 Microchip Technology Inc. ...

Page 61

... OST OSC PLL 2: Clock transition typically occurs within 2-4 T  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY On transitions from RC_RUN mode to PRI_RUN mode, (Parameter 39, the device continues to be clocked from the INTOSC multiplexer while the primary clock is started. When the primary clock becomes ready, a clock switch to the ...

Page 62

... IDLEN and SCS bits are not affected by the wake-up. While in any Idle mode or Sleep mode, a WDT time- out will result in a WDT wake-up to the Run mode currently specified by the SCS<1:0> bits PLL ( OSTS bit Set CSD 31-13) while it becomes ready  2009-2011 Microchip Technology Inc. ...

Page 63

... OSC1 CPU Clock Peripheral Clock Program Counter Wake Event  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 4.4.2 SEC_IDLE MODE In SEC_IDLE mode, the CPU is disabled but the peripherals continue to be clocked from the SOSC oscillator. This mode is entered from SEC_RUN by set- ting the IDLEN bit and executing a SLEEP instruction. If the device is in another Run mode, set the IDLEN bit first, then set the SCS< ...

Page 64

... Many peripheral modules have a corresponding PMD bit. There are four PMD registers in the PIC18F87K22 family devices: PMD0, PMD1, PMD2 and PMD3. These registers have bits associated with each module for disabling or enabling a particular peripheral. or eliminating their power  2009-2011 Microchip Technology Inc. ...

Page 65

... PMD is disabled for CCP4 bit 0 TMR12MD: TMR12MD Disable bit 1 = PMD is enabled and all TMR12MD clock sources are disabled 0 = PMD is disabled and TMR12MD is enabled Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 CCP7MD CCP6MD CCP5MD U = Unimplemented bit, read as ‘ ...

Page 66

... PMD is disabled for Comparator 1 Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1: DS39960D-page 66 R/W-0 R/W-0 R/W-0 (1) TMR6MD TMR5MD CMP3MD U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) (1) R/W-0 R/W-0 CMP2MD CMP1MD bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 67

... EMBMD: PMD EMB Enable/Disable bit 1 = PMD is enabled for EMB, disabling all of its clock sources 0 = PMD is disabled for EMB RTCCMD can only be set to ‘1’ after an EECON2 unlock sequence. Refer to Note 1: Clock and Calendar (RTCC)”  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 (1) ...

Page 68

... PMD is enabled for the Analog/Digital Converter, disabling all of its clock sources 0 = PMD is disabled for the Analog/Digital Converter DS39960D-page 68 R/W-0 R/W-0 R/W-0 UART2MD UART1MD SSP2MD U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 SSP1MD ADCMD bit Bit is unknown ...

Page 69

... WDT timer and postscaler, loses the currently selected clock source (if the Fail-Safe Clock Monitor is enabled) and modifies the IRCF bits in the OSCCON register (if the internal oscillator block is the device clock source).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 4.6.3 EXIT BY RESET ...

Page 70

... The peripheral can also be configured as a simple Programmable Low-Voltage Detect (LVD) or temperature sensor. For more information, see AN879, “Using Note: the Microchip Ultra Low-Power Wake-up Module” (DS00879). 4-9). ULTRA LOW-POWER WAKE-UP INITIALIZATION  2009-2011 Microchip Technology Inc. ...

Page 71

... OST (Parameter F12, Table 31-7 also designated as T Execution continues during T 4: The clock source is dependent upon the settings of the SCS (OSCCON<1:0>), IRCF (OSCCON<6:4>) 5: and FOSC (CONFIG1H<3:0>) bits.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY (5) Exit Delay LP, XT, HS HSPLL EC CSD (2) (2) ...

Page 72

... PIC18F87K22 FAMILY NOTES: DS39960D-page 72  2009-2011 Microchip Technology Inc. ...

Page 73

... DD Brown-out Reset PWRT 32 s PWRT 11-Bit Ripple Counter LF-INTOSC  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 5.1 RCON Register Device Reset events are tracked through the RCON register (Register register indicate that a specific Reset event has occurred. In most cases, these bits can only be set by the event and must be cleared by the application after the event ...

Page 74

... Brown-out Reset is said to have occurred when BOR is ‘0’ and POR is ‘1’ (assuming that POR was set to ‘1’ by software immediately after a Power-on Reset). DS39960D-page 74 R/W-1 R-1 R Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 POR BOR bit Bit is unknown ...

Page 75

... BOREN<1:0> (CONFIG2L<2:1>) and the SBOREN bit (RCON<6>). Typical power consumption is listed as Parameter in Section 31.0 “Electrical Characteristics”.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY In Zero-Power BOR (ZPBORMV), the module monitors the V voltage and re-arms the POR at about 2V. DD ZPBORMV does not cause a Reset, but re-arms the POR ...

Page 76

... MCLR is kept low long enough, the PWRT will expire. Bringing MCLR high will begin execution immediately (Figure 5-5). This is useful for testing purposes or for synchronizing more than one PIC18 device operating in parallel PWRT  2009-2011 Microchip Technology Inc. 33 for Figure 5-3, Figure 5-4, all depict ...

Page 77

... FIGURE 5-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED MCLR INTERNAL POR PWRT TIME-OUT INTERNAL RESET FIGURE 5-6: SLOW RISE TIME (MCLR TIED MCLR INTERNAL POR PWRT TIME-OUT INTERNAL RESET  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY T PWRT T PWRT , V RISE > 3. PWRT ): CASE 1 ...

Page 78

... Table 5-2 describes the Reset states for all of the Special Function Registers. These are categorized by Power-on and Brown-out Resets, Master Clear and WDT Resets, and WDT wake-ups. RCON Register ( POR Table 5-1. STKPTR Register BOR STKFUL STKUNF  2009-2011 Microchip Technology Inc. ...

Page 79

... One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up). 3: See Table 5-1 for Reset value for specific condition. 4:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY MCLR Resets, WDT Reset, Power-on Reset, RESET Instruction, Brown-out Reset Stack Resets, ...

Page 80

... PIC18F6XK22 PIC18F8XK22 TMR0H PIC18F6XK22 PIC18F8XK22 TMR0L PIC18F6XK22 PIC18F8XK22 T0CON PIC18F6XK22 PIC18F8XK22 SPBRGH1 PIC18F6XK22 PIC18F8XK22 OSCCON PIC18F6XK22 PIC18F8XK22 IPR5 PIC18F65K22 PIC18F85K22 PIC18F66K22 PIC18F86K22 IPR5 PIC18F67K22 PIC18F87K22 WDTCON PIC18F6XK22 PIC18F8XK22 RCON PIC18F6XK22 PIC18F8XK22 TMR1H PIC18F6XK22 PIC18F8XK22 TMR1L PIC18F6XK22 PIC18F8XK22 T1CON PIC18F6XK22 PIC18F8XK22 TMR2 ...

Page 81

... PIC18F66K22 PIC18F86K22 IPR4 PIC18F67K22 PIC18F87K22 PIR4 PIC18F65K22 PIC18F85K22 PIC18F66K22 PIC18F86K22 PIR4 PIC18F67K22 PIC18F87K22 PIE4 PIC18F65K22 PIC18F85K22 PIC18F66K22 PIC18F86K22 PIE4 PIC18F67K22 PIC18F87K22 CVRCON PIC18F6XK22 PIC18F8XK22 CMSTAT PIC18F6XK22 PIC18F8XK22 TMR3H PIC18F6XK22 PIC18F8XK22 TMR3L PIC18F6XK22 PIC18F8XK22 T3CON PIC18F6XK22 PIC18F8XK22 T3GCON PIC18F6XK22 PIC18F8XK22 SPBRG1 PIC18F6XK22 PIC18F8XK22 ...

Page 82

... Microchip Technology Inc. Wake-up via WDT or Interrupt u-uu uuuu u-uu uuuu u-uu uuuu u-uu uuuu u-uu uuuu u-uu uuuu uuuu uuuu ...

Page 83

... One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up). 3: See Table 5-1 for Reset value for specific condition. 4:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY MCLR Resets, WDT Reset, Power-on Reset, RESET Instruction, Brown-out Reset Stack Resets, ...

Page 84

... PIC18F87K22 PIC18F66K22 PIC18F86K22 CCPR10H PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 CCPR10L PIC18F67K22 PIC18F87K22 u = unchanged unknown unimplemented bit, read as ‘0’ value depends on condition. Legend: Shaded cells indicate conditions do not apply for the designated device. When the wake-up is due to an interrupt, and the GIEL or GIEH bit is set, the TOSU, TOSH and TOSL are Note 1: updated with the current value of the PC ...

Page 85

... PIC18F6XK22 PIC18F8XK22 T8CON PIC18F6XK22 PIC18F8XK22 PIC18F66K22 PIC18F86K22 TMR10 PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 PR10 PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 T10CON PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 TMR12 PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 PR12 PIC18F67K22 PIC18F87K22 PIC18F66K22 PIC18F86K22 T12CON PIC18F67K22 PIC18F87K22 CM2CON PIC18F6XK22 PIC18F8XK22 CM3CON PIC18F6XK22 PIC18F8XK22 CCPTMRS0 ...

Page 86

... PIC18F6XK22 PIC18F8XK22 PIC18F66K22 PIC18F86K22 PMD2 PIC18F67K22 PIC18F87K22 PMD2 PIC18F65K22 PIC18F85K22 PIC18F66K22 PIC18F86K22 PMD3 PIC18F67K22 PIC18F87K22 PMD3 PIC18F65K22 PIC18F85K22 u = unchanged unknown unimplemented bit, read as ‘0’ value depends on condition. Legend: Shaded cells indicate conditions do not apply for the designated device. When the wake-up is due to an interrupt, and the GIEL or GIEH bit is set, the TOSU, TOSH and TOSL are Note 1: updated with the current value of the PC ...

Page 87

... Unimplemented Read as ‘0’ Sizes of memory areas are not to scale. Sizes of program memory areas are enhanced to show detail. Note:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The data EEPROM, for practical purposes, can be regarded as a peripheral device because it is addressed and accessed through a set of control registers ...

Page 88

... PIC18F65K22 and PIC18F85K22 – 32 Kbytes of Flash memory, storing up to 16,384 single-word instructions • PIC18F66K22 and PIC18F86K22 – 64 Kbytes of Flash memory, storing up to 32,768 single-word instructions • PIC18F67K22 and PIC18F87K22 – 128 Kbytes of Flash memory, storing up to 65,536 single-word ...

Page 89

... TOSH TOSL 00h 1Ah 34h  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The stack operates as a 31-word by 21-bit RAM and a 5-bit Stack Pointer, STKPTR. The stack space is not part of either program or data space. The Stack Pointer is readable and writable and the address on the top of the stack is readable and writable through the Top-of-Stack Special Function Registers ...

Page 90

... Stack Pointer. The previous value pushed onto the stack then becomes the TOS value. R/W-0 R/W-0 R/W-0 SP4 SP3 SP2 U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) (1) and Instructions POP R/W-0 R/W-0 SP1 SP0 bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 91

... SUB1  RETURN FAST ;RESTORE VALUES SAVED ;IN FAST REGISTER STACK  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 6.1.5 LOOK-UP TABLES IN PROGRAM MEMORY There may be programming situations that require the creation of data structures, or look-up tables, in program memory. For PIC18 devices, look-up tables can be implemented in two ways: • ...

Page 92

... Q2, Q3 and Q4 cycles. Data memory is read during Q2 (operand read) and written during Q4 (destination write Execute INST (PC) Fetch INST ( Execute INST ( Execute 1 Fetch 2 Execute 2 Fetch 3 Execute 3 Fetch 4 Example 6-3 Internal Phase Clock Fetch INST ( Flush (NOP) Fetch SUB_1 Execute SUB_1  2009-2011 Microchip Technology Inc. ...

Page 93

... MOVFF 1111 0100 0101 0110 0010 0100 0000 0000 ADDWF  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The CALL and GOTO instructions have the absolute program memory address embedded into the instruc- tion. Since instructions are always stored on word boundaries, the data contained in the instruction is a word address. The word address is written to PC< ...

Page 94

... When this instruction executes, it ignores the BSR completely. All other instructions include only the low-order address as an operand and must use either the BSR or the Access Bank to locate their target registers. 6-7.  2009-2011 Microchip Technology Inc. ...

Page 95

... BSR value, to access these registers. 2: These addresses are unused for devices with 32 Kbytes of program memory (PIC18FX5K22). For those devices, read these addresses at 00h.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Data Memory Map ...

Page 96

... This is data RAM which is available for use by all instructions. GPRs start at the bottom of Bank 0 (address 000h) and grow upwards towards the bottom of the SFR area. GPRs are not initialized by a Power-on Reset and are unchanged on all other Resets. (2) From Opcode Mode”.  2009-2011 Microchip Technology Inc. ...

Page 97

... Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. To access these registers, 4: users must always load the proper BSR value.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The SFRs can be classified into two sets: those associated with the “ ...

Page 98

... INT0IF RBIF 0000 000x INT3IP RBIP 1111 1111 INT2IF INT1IF 1100 0000 ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 0000 xxxx xxxx xxxx xxxx ---- ----  2009-2011 Microchip Technology Inc. ...

Page 99

... This bit is available when Master Clear is disabled (MCLRE = 0). When MCLRE is set, the bit is unimplemented. Note 1: Unimplemented on 64-pin devices (PIC18F6XK22), read as ‘0’. 2: Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). 3:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Bit 5 Bit 4 Bit 3 — ...

Page 100

... LATE2 LATE1 LATE0 xxxx xxxx LATD2 LATD1 LATD0 xxxx xxxx LATC2 LATC1 LATC0 xxxx xxxx LATB2 LATB1 LATB0 xxxx xxxx LATA2 LATA1 LATA0 xxxx xxxx RJ2 RJ1 RJ0 xxxx xxxx RH2 RH1 RH0 xxxx xxxx  2009-2011 Microchip Technology Inc. ...

Page 101

... This bit is available when Master Clear is disabled (MCLRE = 0). When MCLRE is set, the bit is unimplemented. Note 1: Unimplemented on 64-pin devices (PIC18F6XK22), read as ‘0’. 2: Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). 3:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Bit 5 Bit 4 Bit 3 Bit 2 ...

Page 102

... T8CKPS1 T8CKPS0 -000 0000 0000 0000 1111 1111 T10CKPS1 T10CKPS0 -000 0000 0000 0000 1111 1111 T12CKPS1 T12CKPS0 -000 0000 CCH1 CCH0 0001 1111 CCH1 CCH0 0001 1111 C1TSEL1 C1TSEL0 0000 0000  2009-2011 Microchip Technology Inc. ...

Page 103

... This bit is available when Master Clear is disabled (MCLRE = 0). When MCLRE is set, the bit is unimplemented. Note 1: Unimplemented on 64-pin devices (PIC18F6XK22), read as ‘0’. 2: Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). 3:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Bit 5 Bit 4 Bit 3 — ...

Page 104

... Table 29-3. The C and DC bits operate, in subtraction, Note: as borrow and digit borrow bits, respectively. R/W-x R/W-x R/W Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) Table 29-2 and R/W-x R/W-x (1) ( bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 105

... Addressing by default. All of these instructions include some 8-bit literal address as their Least Significant Byte. This address specifies the instruction’s data source as either a register address in one of the banks  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY of data RAM (see Section 6.3.3 “General Purpose File” ...

Page 106

... RAM banking is not necessary. Thus, the current contents of the BSR and the Access RAM bit have no effect on determining the target address. ADDWF, INDF1, 1 FSR1H:FSR1L 000h Bank 0 100h Bank 1 200h Bank 2 300h 0 Bank 3 through Bank 13 E00h Bank 14 F00h Bank 15 FFFh Data Memory  2009-2011 Microchip Technology Inc. ...

Page 107

... In some applications, this can be used to implement some powerful program control structure, such as software stacks, inside of data memory.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 6.4.3.3 Operations by FSRs on FSRs Indirect Addressing operations that target other FSRs or virtual registers represent special cases ...

Page 108

... Figure 6-9. Those who desire to use byte-oriented or bit-oriented instructions in the Indexed Literal Offset mode should note the changes to assembler syntax for this mode. This is described in more detail in “Extended Instruction Syntax”.  2009-2011 Microchip Technology Inc. Section 29.2.1 ...

Page 109

... The bank is designated by the Bank Select Register (BSR). The address can be in any implemented bank in the data memory space.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 000h 060h Bank 0 100h Bank 1 through ...

Page 110

... BSR remains unchanged. Direct Addressing, using the BSR to select the data memory bank, operates in the same manner as previously described. Not Accessible Bank 0 Window Bank 1 Bank 2 through Bank 14 Bank 15 SFRs Data Memory 00h Bank 1 “Window” 5Fh 60h SFRs FFh Access Bank  2009-2011 Microchip Technology Inc. ...

Page 111

... TBLPTRH TBLPTRL Program Memory (TBLPTR) Note 1: The Table Pointer register points to a byte in program memory.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 7.1 Table Reads and Table Writes In order to read and write program memory, there are two operations that allow the processor to move bytes ...

Page 112

... The WR control bit initiates write operations. The bit cannot be cleared, only set, in software cleared in hardware at the completion of the write operation. The EEIF interrupt flag bit (PIR6<4>) is Note: set when the write is complete. It must be cleared in software. When set, Section 28.0 Table Latch (8-bit) TABLAT  2009-2011 Microchip Technology Inc. ...

Page 113

... The RD bit cannot be set when EEPGD = 1 or CFGS = 1 Does not initiate an EEPROM read When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the error Note 1: condition.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-x R/W-0 ...

Page 114

... TBLPTR based on Flash program memory operations. Operation on Table Pointer TBLPTR is not modified TBLPTR is incremented after the read/write TBLPTR is decremented after the read/write TBLPTR is incremented before the read/write TBLPTRH 8 7 TBLPTR<21:6> TABLE READ – TBLPTR<21:0> Memory”. TBLPTRL 0 TABLE WRITE TBLPTR<5:0>  2009-2011 Microchip Technology Inc. ...

Page 115

... WORD_EVEN TBLRD*+ MOVF TABLAT, W MOVF WORD_ODD  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY TBLPTR points to a byte address in program space. Executing TBLRD places the byte pointed to into TABLAT. In addition, the TBLPTR can be modified automatically for the next table read operation. The internal program memory is typically organized by words ...

Page 116

... TBLPTR with the base ; address of the memory block ; point to Flash program memory ; access Flash program memory ; enable write to memory ; enable Row Erase operation ; disable interrupts ; write 55h ; write 0AAh ; start erase (CPU stall) ; re-enable interrupts  2009-2011 Microchip Technology Inc. ...

Page 117

... TABLE WRITES TO FLASH PROGRAM MEMORY 8 TBLPTR = xxxxx0 TBLPTR = xxxxx1 Holding Register  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The long write is necessary for programming the internal Flash. Instruction execution is halted while in a long write cycle. The long write is terminated by the internal programming timer. ...

Page 118

... Self-write execution Note: EEPROM memory cannot be done while running in LP Oscillator mode (Low-Power mode). Therefore, executing a self-write will put the device into High-Power mode. IW  2009-2011 Microchip Technology Inc. to Flash and ...

Page 119

... MOVFF POSTINC0, WREG MOVWF TABLAT TBLWT+* DECFSZ COUNTER BRA WRITE_BYTE_TO_HREGS  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY ; number of bytes in erase block ; point to buffer ; Load TBLPTR with the base ; address of the memory block ; read into TABLAT, and inc ; get data ; store data ...

Page 120

... Program Memory Table Pointer Upper Byte (TBLPTR<20:16>) INT0IE RBIE — FREE WRERR — EEIP — — EEIF — — EEIE — Bit 2 Bit 1 Bit 0 TMR0IF INT0IF RBIF WREN WR RD CMP3IP CMP2IP CMP1IP CMP3IF CMP2IF CMP1IF CMP3IE CMP2IE CMP1IE  2009-2011 Microchip Technology Inc. ...

Page 121

... For the sake of clarity, only I/O port and external bus assignments are shown here. One or more additional Note: multiplexed features may be available on some pins.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The bus is implemented with 28 pins, multiplexed across four I/O ports. Three ports (PORTD, PORTE ...

Page 122

... Data Width when an 8-Bit Data Width mode is selected. R/W-0 U-0 U-0 WAIT0 — — Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. Bus”. States”. Section 8.6 (1) R/W-0 R/W-0 WM1 WM0 bit Bit is unknown ...

Page 123

... Microchip Technology Inc. PIC18F87K22 FAMILY 8.2.1 ADDRESS SHIFTING ON THE EXTERNAL BUS By default, the address presented on the external bus is the value of the PC. In practical terms, this means that addresses in the external memory device, below the top of on-chip memory, are unavailable to the microcontroller ...

Page 124

... BA0 for the byte address line and one I/O line to select between Byte and Word mode. The other 16-bit modes do not need BA0. JEDEC standard static RAM memories will use the signals for byte selection.  2009-2011 Microchip Technology Inc. register ...

Page 125

... Upper order address lines are used only for 20-bit address widths. Note 1: This signal only applies to table writes. See 2:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY During a TBLWT instruction cycle, the TABLAT data is presented on the upper and lower bytes of the AD<15:0> bus. The appropriate WRH or WRL control line is strobed on the LSb of the TBLPTR. D< ...

Page 126

... A<20:1> 373 D<15:0> 373 Section 7.1 “Table Reads and Table cycle to an odd address JEDEC Word A<x:0> EPROM Memory D<15:0> ( Address Bus Data Bus Control Lines Writes”.  2009-2011 Microchip Technology Inc. ...

Page 127

... Upper order address lines are used only for 20-bit address width. 2: Demultiplexing is only required when multiple memory devices are accessed. 3:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Flash and SRAM devices use different control signal combinations to implement Byte Select mode. JEDEC standard Flash memories require that a controller I/O port pin be connected to the memory’ ...

Page 128

... Opcode Fetch TBLRD 92h MOVLW 55h from 199E67h from 000102h TBLRD Cycle 1 TBLRD Cycle 00h 0E55h 3AABh Opcode Fetch Sleep Mode, MOVLW 55h from 007556h SLEEP Opcode Fetch ADDLW 55h from 000104h MOVLW Bus Inactive  2009-2011 Microchip Technology Inc. ...

Page 129

... Note 1: address widths except 8-bit. This signal only applies to table writes. See 2:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY will enable one byte of program memory for a portion of the instruction cycle, then BA0 will change and the second byte will be enabled to form the 16-bit instruc- tion word ...

Page 130

... Opcode Fetch TBLRD 92h MOVLW 55h from 199E67h from 000102h TBLRD Cycle 1 TBLRD Cycle 00h 3Ah 55h ABh 0Eh Opcode Fetch Sleep Mode, MOVLW 55h from 007556h SLEEP Opcode Fetch ADDLW 55h from 000104h MOVLW Bus Inactive  2009-2011 Microchip Technology Inc. ...

Page 131

... Legend: — = unimplemented, read as ‘0’. Shaded cells are not used during External Memory Bus access. Unimplemented in 64-pin devices (PIC18F6XK22), read as ‘0’. Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY In Sleep and Idle modes, the microcontroller core does not need to access data; bus operations are suspended ...

Page 132

... PIC18F87K22 FAMILY NOTES: DS39960D-page 132  2009-2011 Microchip Technology Inc. ...

Page 133

... EEPROM for read and write operations. EEADRH holds the two MSbs of the address; the upper 6 bits are ignored. The 10-bit range of the pair can address a memory range of 1024 bytes (00h to 3FFh).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 9.2 EECON1 and EECON2 Registers Access to the data EEPROM is controlled by two registers: EECON1 and EECON2 ...

Page 134

... When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the error Note 1: condition. DS39960D-page 134 R/W-0 R/W-x R/W-0 (1) FREE WRERR WREN U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1)  2009-2011 Microchip Technology Inc. R/S-0 R/S bit Bit is unknown ...

Page 135

... The WREN bit should be kept clear at all times, except when updating the EEPROM. The WREN bit is not cleared by hardware.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY After a write sequence has been initiated, EECON1, EEADRH:EEADR and EEDATA cannot be modified. ...

Page 136

... Data Memory Value to write ; Point to DATA memory ; Access EEPROM ; Enable writes ; Disable Interrupts ; ; Write 55h ; ; Write 0AAh ; Set WR bit to begin write ; Wait for write to complete GOTO $-2 ; Enable Interrupts ; User code execution ; Disable writes on write complete (EEIF set)  2009-2011 Microchip Technology Inc. ...

Page 137

... LOOP INCFSZ EEADRH, F BRA LOOP BCF EECON1, WREN BSF INTCON, GIE  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 9.8 Using the Data EEPROM The data EEPROM is a high-endurance, byte address- able array that has been optimized for the storage of frequently changing variables or other data that is updated often) ...

Page 138

... DS39960D-page 138 Bit 5 Bit 4 Bit 3 TMR0IE INT0IE RBIE TMR0IF — FREE WRERR WREN — EEIP — CMP3IP — EEIF — CMP3IF — EEIE — CMP3IE Bit 2 Bit 1 Bit 0 INT0IF RBIF WR RD CMP2IP CMP1IP CMP2IF CMP1IF CMP2IE CMP1IE  2009-2011 Microchip Technology Inc. ...

Page 139

... Unsigned Hardware Multiply Without Hardware Multiply Signed Hardware Multiply Without Hardware Multiply Unsigned Hardware Multiply Without Hardware Multiply Signed Hardware Multiply  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY EXAMPLE 10-1: MOVF ARG1, W MULWF ARG2 EXAMPLE 10-2: MOVF ARG1, W MULWF ARG2 BTFSC ...

Page 140

... WREG ; RES3 ARG1H ARG2L ; ARG1H * ARG2L -> ; PRODH:PRODL PRODL RES1 Add cross PRODH products RES2 WREG ; RES3 ARG2H ARG2H:ARG2L neg? SIGN_ARG1 ; no, check ARG1 ARG1L RES2 ; ARG1H RES3 ; SIGN_ARG1 ARG1H ARG1H:ARG1L neg? CONT_CODE ; no, done ARG2L RES2 ; ARG2H RES3  2009-2011 Microchip Technology Inc. ...

Page 141

... Individual interrupts can be disabled through their corresponding enable bits.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY When the IPEN bit is cleared (default state), the interrupt priority feature is disabled and interrupts are ...

Page 142

... IPEN PEIE/GIEL IPEN TMR0IF IPEN TMR0IE TMR0IP RBIF RBIE RBIP INT1IF INT1IE INT1IP INT2IF INT2IE INT2IP INT3IF INT3IE INT3IP  2009-2011 Microchip Technology Inc. Wake- Idle or Sleep modes Interrupt to CPU Vector to Location 0008h GIE/GIEH Interrupt to CPU Vector to Location 0018h GIE/GIEH PEIE/GIEL ...

Page 143

... A mismatch condition will continue to set this bit. Reading PORTB, and then waiting one additional instruction Note 1: cycle, will end the mismatch condition and allow the bit to be cleared.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Interrupt flag bits are set when an interrupt ...

Page 144

... Global Interrupt Enable bit. User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. This feature allows for software polling. DS39960D-page 144 R/W-1 R/W-1 R/W-1 INTEDG2 INTEDG3 TMR0IP U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-1 R/W-1 INT3IP RBIP bit Bit is unknown ...

Page 145

... Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding Note: enable bit or the Global Interrupt Enable bit. User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. This feature allows for software polling.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 ...

Page 146

... R-0 R/W-0 R/W-0 TX1IF SSP1IF TMR1GIF U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. should ensure the R/W-0 R/W-0 TMR2IF TMR1IF bit Bit is unknown ...

Page 147

... TMR3 register overflowed (must be cleared in software TMR3 register did not overflow bit 0 TMR3GIF: TMR3 Gate Interrupt Flag bit 1 = Timer gate interrupt occurred (must be cleared in software timer gate interrupt occurred  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 BCL2IF BCL1IF HLVDIF U = Unimplemented bit, read as ‘ ...

Page 148

... RTCCIF: RTCC Interrupt Flag bit 1 = RTCC interrupt occurred (must be cleared in software RTCC interrupt occurred DS39960D-page 148 R-0 R/W-0 R/W-0 TX2IF CTMUIF CCP2IF U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 CCP1IF RTCCIF bit Bit is unknown ...

Page 149

... Compare Mode TMR register compare match occurred (must be cleared in software TMR register compare match occurred PWM Mode: Not used in PWM mode. Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 CCP7IF CCP6IF CCP5IF U = Unimplemented bit, read as ‘ ...

Page 150

... Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1: DS39960D-page 150 R/W-0 R/W-0 R/W-0 (1) (1) TMR8IF TMR7IF TMR6IF U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) (1) (1) (1) R/W-0 R/W-0 TMR5IF TMR4IF bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 151

... CMP2IF: CMP2 Interrupt Flag bit 1 = CMP2 interrupt occurred (must be cleared in software CMP2 interrupt occurred bit 0 CMP1IF: CM1 Interrupt Flag bit 1 = CMP1 interrupt occurred (must be cleared in software CMP1 interrupt occurred  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 U-0 R/W-0 EEIF — ...

Page 152

... TMR1IE: TMR1 Overflow Interrupt Enable bit 1 = Enables the TMR1 overflow interrupt 0 = Disables the TMR1 overflow interrupt DS39960D-page 152 R/W-0 R/W-0 R/W-0 TX1IE SSP1IE TMR1GIE U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 TMR2IE TMR1IE bit Bit is unknown ...

Page 153

... Disabled bit 1 TMR3IE: TMR3 Overflow Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 TMR3GIE: Timer3 Gate Interrupt Enable bit 1 = Enabled 0 = Disabled  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 BCL2IE BCL1IE HLVDIE U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared ...

Page 154

... U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared R/W-0 R/W-0 R/W-0 CCP7IE CCP6IE CCP5IE U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1)  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 CCP1IE RTCCIE bit Bit is unknown R/W-0 R/W-0 CCP4IE CCP3IE bit 0 ...

Page 155

... Disables the TMR5 overflow interrupt bit 0 TMR4IE: TMR4 to PR4 Match Interrupt Enable bit 1 = Enables the TMR4 to PR4 match interrupt 0 = Disables the TMR4 to PR4 match interrupt Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-0 R/W-0 R/W-0 (1) (1) ...

Page 156

... Interrupt is enabled 0 = interrupt is disabled bit 0 CMP1IE: CMP1 Enable bit 1 = Interrupt is enabled 0 = interrupt is disabled DS39960D-page 156 R/W-0 U-0 R/W-0 EEIE — CMP3IE U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 CMP2IE CMP1IE bit Bit is unknown ...

Page 157

... TMR2IP: TMR2 to PR2 Match Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 TMR1IP: TMR1 Overflow Interrupt Priority bit 1 = High priority 0 = Low priority  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-1 R/W-1 R/W-1 TX1IP SSP1IP TMR1GIP U = Unimplemented bit, read as ‘0’ ...

Page 158

... Low priority bit 0 TMR3GIP: TMR3 Gate Interrupt Priority bit 1 = High priority 0 = Low priority DS39960D-page 158 R/W-1 R/W-1 R/W-1 BCL2IP BCL1IP HLVDIP U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared  2009-2011 Microchip Technology Inc. R/W-1 R/W-1 TMR3IP TMR3GIP bit Bit is unknown ...

Page 159

... Value at POR ‘1’ = Bit is set bit 7-0 CCP<10:3>IP: CCP<10:3> Interrupt Priority bits 1 = High priority 0 = Low priority Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R-1 R/W-1 R/W-1 TX2IP CTMUIP CCP2IP U = Unimplemented bit, read as ‘0’ ...

Page 160

... Unimplemented on devices with a program memory of 32 Kbytes (PIC18FX5K22). Note 1: DS39960D-page 160 R/W-1 R/W-1 R/W-1 (1) (1) TMR8IP TMR7IP TMR6IP U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) (1) (1) (1) R/W-1 R/W-1 TMR5IP TMR4IP bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 161

... Low priority bit 1 CMP2IP: CMP2 Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 CMP1IP: CMP1 Interrupt Priority bit 1 = High priority 0 = Low priority  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY R/W-1 U-0 R/W-1 EEIP — CMP3IP U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared ...

Page 162

... For details of bit operation, see DS39960D-page 162 R/W-1 R-1 R Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared Register 5-1. Register 5-1. Register 5-1. Register 5-1. Register 5-1. Register 5-1.  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 POR BOR bit Bit is unknown ...

Page 163

... MOVFF BSR_TEMP, BSR MOVF W_TEMP, W MOVFF STATUS_TEMP, STATUS  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 11.7 TMR0 Interrupt In 8-bit mode (the default), an overflow in the TMR0 register (FFh  00h) will set flag bit, TMR0IF. In 16-bit mode, an overflow in the TMR0H:TMR0L register pair (FFFFh  ...

Page 164

... TMR1IE HLVDIE TMR3IE TMR3GIE CCP2IE CCP1IE RTCCIE CCP5IE CCP4IE CCP3IE TMR6IE TMR5IE TMR4IE CMP3IE CMP2IE CMP1IE TMR1GIP TMR2IP TMR1IP HLVDIP TMR3IP TMR3GIP CCP2IP CCP1IP RTCCIP CCP5IP CCP4IP CCP3IP TMR6IP TMR5IP TMR4IP CMP3IP CMP2IP CMP1IP PD POR BOR  2009-2011 Microchip Technology Inc. ...

Page 165

... TRIS Latch RD TRIS PORT  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 12.1 I/O Port Pin Capabilities When developing an application, the capabilities of the port pins must be considered. Outputs on some pins have higher output drive strength than others. Similarly, some pins can tolerate higher than V All of the digital ports are 5.5V input tolerant. The ana- log ports have the same tolerance – ...

Page 166

... To enable the actual RTCC output, the RTCOE (RTCCFG<2>) bit must be set. Note 1: Unimplemented on 64-pin devices (PIC18F6XK22), read as ‘0’. 2: DS39960D-page 166 U-0 U-0 R/W-0 (1) — — RTSECSEL1 U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (2) (1)  2009-2011 Microchip Technology Inc. R/W-0 U-0 (1) RTSECSEL0 — bit Bit is unknown ...

Page 167

... Open-drain capability is enabled 0 = Open-drain capability is disabled bit 4-1 Unimplemented: Read as ‘0’ bit 0 SSP2OD: MSSP2 Open-Drain Output Enable bit 1 = Open-drain capability is enabled 0 = Open-drain capability is disabled  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY FIGURE 12-2: USING THE OPEN-DRAIN OUTPUT (USART SHOWN AS EXAMPLE) 3.3V PIC18F87K22 ...

Page 168

... Open-drain capability is disabled Not implemented on devices with 32-byte program memory (PIC18FX5K22). Note 1: DS39960D-page 168 R/W-0 R/W-0 R/W-0 CCP7OD CCP6OD CCP5OD U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared (1) (1)  2009-2011 Microchip Technology Inc. R/W-0 R/W-0 CCP4OD CCP3OD bit Bit is unknown ...

Page 169

... PIC18F87K22 family devices can make any analog pin analog or digital, depending on an application’s needs. The ports’ analog/digital functionality is controlled by registers: ANCON0, ANCON1 and ANCON2.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY U-0 U-0 U-0 — ...

Page 170

... Select bank with ANCON1 register MOVLW 00h ; Configure A/D MOVWF ANCON1 ; for digital inputs BANKSEL TRISA ; Select bank with TRISA register MOVLW 0BFh ; Value used to initialize ; data direction MOVWF TRISA ; Set RA<7, 5:0> as inputs, ; RA<6> as output  2009-2011 Microchip Technology Inc. normally ...

Page 171

... Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by PORTA. These bits are enabled depending on the oscillator mode selected. When not enabled as PORTA pins, Note 1: they are disabled and read as ‘x’.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY I/O I/O ...

Page 172

... PORTB<1> data input; weak pull-up when RBPU bit is cleared External Interrupt 1 input. O DIG LATB<2> data output. I TTL PORTB<2> data input; weak pull-up when RBPU bit is cleared External Interrupt 2 input CTMU Edge 1 input. can wake the device from delay. CY Description  2009-2011 Microchip Technology Inc. ...

Page 173

... PEIE/GIEL INTCON2 RBPU INTEDG0 INTCON3 INT2IP INT1IP ODCON1 SSP1OD CCP2OD Legend: Shaded cells are not used by PORTB.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY I/O I/O Type O DIG LATB<3> data output. I TTL PORTB<3> data input; weak pull-up when RBPU bit is cleared. ...

Page 174

... May be configured for tri-state during Enhanced PWM shutdown events; takes priority over port data. INITIALIZING PORTC ; Initialize PORTC by ; clearing output ; data latches ; Alternate method ; to clear output ; data latches ; Value used to ; initialize data ; direction ; Set RC<3:0> as inputs ; RC<5:4> as outputs ; RC<7:6> as inputs  2009-2011 Microchip Technology Inc. ...

Page 175

... TRISC TRISC7 TRISC6 ODCON1 SSP1OD CCP2OD ODCON3 U2OD U1OD Legend: Shaded cells are not used by PORTC.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY I/O Description Type DIG LATC<3> data output. ST PORTC<3> data input. DIG SPI clock output (MSSP module); takes priority over port data. ...

Page 176

... TTL External Memory Address/Data 2. Port” and SPI functionality on INITIALIZING PORTD ; Initialize PORTD by ; clearing output ; data latches ; Alternate method ; to clear output ; data latches ; Value used to ; initialize data ; direction ; Set RD<3:0> as inputs ; RD<5:4> as outputs ; RD<7:6> as inputs Description  2009-2011 Microchip Technology Inc. ...

Page 177

... TRISD TRISD7 TRISD6 PADCFG1 RDPU REPU ODCON1 SSP1OD CCP2OD Legend: Shaded cells are not used by PORTD. Unimplemented on PIC18F6XK22 devices, read as ‘0’. Note 1:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY I/O I/O Type O DIG LATD<3> data output PORTD<3> data input. I/O TTL Parallel Slave Port data ...

Page 178

... External memory interface, Data Bit 9 output. I TTL External memory interface, Data Bit 9 input. Output”. INITIALIZING PORTE ; Initialize PORTE by ; clearing output ; data latches ; Alternate method ; to clear output ; data latches ; Value used to ; initialize data ; direction ; Set RE<1:0> as inputs ; RE<7:2> as outputs Description  2009-2011 Microchip Technology Inc. ...

Page 179

... Don’t care (TRIS bit does not affect port direction or is overridden for this option). Alternate assignment for ECCP2 when the CCP2MX Configuration bit is cleared and in Microcontroller mode. Note 1: This feature is only available on PIC18F8XKXX devices. 2:  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY I/O I/O Type ...

Page 180

... LATE4 LATE3 TRISE5 TRISE4 TRISE3 (2) RJPU — — RTSECSEL1 RTSECSEL0 CCP1OD — — CCP8OD CCP7OD CCP6OD Description Bit 2 Bit 1 Bit 0 RE2 RE1 RE0 LATE2 LATE1 LATE0 TRISE2 TRISE1 TRISE0 — — — SSP2OD CCP5OD CCP4OD CCP3OD  2009-2011 Microchip Technology Inc. ...

Page 181

... O = Output Input, ANA = Analog Signal, DIG = Digital Output Schmitt Trigger Buffer Input, Legend: TTL = TTL Buffer Input Don’t care (TRIS bit does not affect port direction or is overridden for this option).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY EXAMPLE 12-6: ...

Page 182

... Bit 4 Bit 3 RF5 RF4 RF3 LATF5 LATF4 LATF3 TRISF5 TRISF4 TRISF3 ANSEL5 ANSEL4 ANSEL3 ANSEL13 ANSEL12 ANSEL11 Description Bit 2 Bit 1 Bit 0 RF2 RF1 — LATF2 LATF1 — TRISF2 TRISF1 — ANSEL2 ANSEL1 ANSEL0 ANSEL10 ANSEL9 ANSEL8  2009-2011 Microchip Technology Inc. ...

Page 183

... O = Output Input, ANA = Analog Signal, DIG = Digital Output Schmitt Trigger Buffer Input, Legend Don’t care (TRIS bit does not affect port direction or is overridden for this option).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTG pin ...

Page 184

... TRISG4 TRISG3 ANSEL21 ANSEL20 ANSEL19 CCP1OD — — (1) CCP8OD CCP7OD CCP6OD — — — Description Bit 2 Bit 1 Bit 0 RG2 RG1 RG0 TRISG2 TRISG1 TRISG0 ANSEL18 ANSEL17 ANSEL16 — — SSP2OD CCP5OD CCP4OD CCP3OD — — CTMUDS  2009-2011 Microchip Technology Inc. ...

Page 185

... A19 Output Input, ANA = Analog Signal, DIG = Digital Output Schmitt Trigger Buffer Input, Legend Don’t care (TRIS bit does not affect port direction or is overridden for this option).  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY EXAMPLE 12-8: CLRF PORTH CLRF ...

Page 186

... CCP6 compare/PWM output; takes priority over port data CCP6 capture input. O — ECCP1 PWM Output B. May be configured for tri-state during Enhanced PWM. I ANA A/D Input Channel 15. Default input configuration on POR; does not affect digital input. Description  2009-2011 Microchip Technology Inc. ...

Page 187

... PORTJ pins function as control outputs for the inter- face. This occurs automatically when the interface is enabled by clearing the EBDIS (MEMCON<7>). The TRISJ bits are also overridden.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Bit 5 Bit 4 Bit 3 RH5 RH4 RH3 LATH5 ...

Page 188

... External memory interface upper byte enable control output; takes priority over digital I/O. Bit 5 Bit 4 Bit 3 RJ5 RJ4 RJ3 LATJ5 LATJ4 LATJ3 TRISJ5 TRISJ4 TRISJ3 (1) RJPU — — RTSECSEL1 RTSECSEL0 Description Bit 2 Bit 1 Bit 0 RJ2 RJ1 RJ0 LATJ2 LATJ1 LATJ0 TRISJ2 TRISJ1 TRISJ0 —  2009-2011 Microchip Technology Inc. ...

Page 189

... PSP. When this happens, the IBF and OBF bits can be polled and the appropriate action taken. The timing for the control signals in Write and Read modes is shown in Figure 12-4 and respectively.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY FIGURE 12-3: Data Bus WR LATD or PORTD Data Latch ...

Page 190

... Unimplemented: Read as ‘0’ FIGURE 12-4: PARALLEL SLAVE PORT WRITE WAVEFORMS PORTD<7:0> IBF OBF PSPIF DS39960D-page 190 R/W-0 U-0 PSPMODE — Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared U-0 U-0 U-0 — — — bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 191

... PIR1 PSPIF ADIF PIE1 PSPIE ADIE IPR1 PSPIP ADIP PMD1 PSPMD CTMUMD Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by the Parallel Slave Port.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Bit 5 Bit 4 Bit 3 RD5 RD4 RD3 LATD5 ...

Page 192

... PIC18F87K22 FAMILY NOTES: DS39960D-page 192  2009-2011 Microchip Technology Inc. ...

Page 193

... Prescale value 001 = 1:4 Prescale value 000 = 1:2 Prescale value  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY The T0CON register aspects of the module’s operation, including the prescale selection both readable and writable. Figure 13-1 provides a simplified block diagram of the Timer0 module in 8-bit mode ...

Page 194

... Delay There is a delay between OSC Figure 13-2). TMR0H is updated with the Set TMR0L TMR0IF on Overflow 8 8 Internal Data Bus Set TMR0 TMR0IF High Byte on Overflow 8 Read TMR0L Write TMR0L 8 8 TMR0H 8 8 Internal Data Bus  2009-2011 Microchip Technology Inc. ...

Page 195

... GIE/GIEH PEIE/GIEL T0CON TMR0ON T08BIT Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by Timer0.  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY 13.3.1 SWITCHING PRESCALER ASSIGNMENT The prescaler assignment is fully under software control and can be changed “on-the-fly” during program execution ...

Page 196

... PIC18F87K22 FAMILY NOTES: DS39960D-page 196  2009-2011 Microchip Technology Inc. ...

Page 197

... Stops Timer1 The F clock source should not be selected if the timer will be used with the ECCP capture/compare features. Note 1: OSC  2009-2011 Microchip Technology Inc. PIC18F87K22 FAMILY Figure 14-1 displays a simplified block diagram of the Timer1 module. The Timer1 oscillator can also be used as a low-power clock source for the microcontroller in power-managed operation ...

Page 198

... TMR2 to match PR2 output 00 = Timer1 gate pin Programming the T1GCON prior to T1CON is recommended. Note 1: DS39960D-page 198 (T1GCON), (1) R/W-0 R/W-0 R-x T1GVAL T1GSPM T1GGO/T1DONE U = Unimplemented bit, read as ‘0’ ‘0’ = Bit is cleared R/W-0 R/W-0 T1GSS1 T1GSS0 bit Bit is unknown  2009-2011 Microchip Technology Inc. ...

Page 199

... Microchip Technology Inc. PIC18F87K22 FAMILY 14.3.2 EXTERNAL CLOCK SOURCE When the external clock source is selected, the Timer1 module may work as a timer or a counter. When enabled to count, Timer1 is incremented on the rising edge of the external clock input, T1CKI. Either of these external clock sources can be synchronized to the ...

Page 200

... TMR1L Q D TMR1CS<1:0> T1SYNC (4) 10 Prescaler OSC Internal 01 0 T1CKPS<1:0> Clock F /4 OSC Internal 00 Clock (1) 0 Data Bus T1GVAL T1GCON Q1 EN Interrupt Set TMR1GIF det TMR1GE Synchronized 0 Clock Input 1 Synchronize (3) det OSC Sleep Input Internal Clock  2009-2011 Microchip Technology Inc. ...

Related keywords