Microchip Technology PIC18LF67K40 Manual

Microchip Technology PIC18LF67K40 Manual

64-pin, low-power, high-performance microcontrollers with xlp technology

Advertisement

Quick Links

64-Pin, Low-Power, High-Performance Microcontrollers
Description
PIC18(L)F67K40 microcontrollers feature Analog, Core Independent Peripherals and Communication Peripherals,
combined with eXtreme Low-Power (XLP) technology for a wide range of general purpose and low-power applications.
These 64-pin devices are equipped with a 10-bit ADC with Computation (ADCC) automating Capacitive Voltage Divider
(CVD) techniques for advanced touch sensing, averaging, filtering, oversampling and performing automatic threshold
comparisons. They also offer a set of Core Independent Peripherals such as Complementary Waveform Generator
(CWG), Windowed Watchdog Timer (WWDT), Cyclic Redundancy Check (CRC)/Memory Scan, Zero-Cross Detect
(ZCD) and Peripheral Pin Select (PPS), providing for increased design flexibility and lower system cost.
Core Features
• C Compiler Optimized RISC Architecture
• Only 83 Instructions
• Operating Speed:
- DC – 64 MHz clock input
- 62.5 ns minimum instruction cycle
• Programmable 2-Level Interrupt Priority
• 31-Level Deep Hardware Stack
• Four 8-Bit Timers (TMR2/4/6/8) with Hardware
Limit Timer (HLT)
• Five 16-Bit Timers (TMR0/1/3/5/7)
• Low-Current Power-on Reset (POR)
• Power-up Timer (PWRT)
• Brown-out Reset (BOR)
• Low-Power BOR (LPBOR) Option
• Programmable Code Protection
• Windowed Watchdog Timer (WWDT):
- Timer monitoring of overflow and underflow
events
- Variable prescaler selection
- Variable window size selection
- All sources configurable in hardware or
software
Memory
• 128K bytes Program Flash Memory
• 3568 Bytes Data SRAM Memory
• 1024 Bytes Data EEPROM
• Direct, Indirect and Relative Addressing modes
Operating Characteristics
• Operating Voltage Ranges:
- 1.8V to 3.6V (PIC18LF6xK40)
- 2.3V to 5.5V (PIC18F6xK40)
• Temperature Range:
- Industrial: -40°C to 85°C
- Extended: -40°C to 125°C
 2016 Microchip Technology Inc.
with XLP Technology
Power-Saving Operation Modes
• Doze: CPU and Peripherals Running at Different
Cycle Rates (typically CPU is lower)
• Idle: CPU Halted While Peripherals Operate
• Sleep: Lowest Power Consumption
• Peripheral Module Disable (PMD):
- Ability to selectively disable hardware module
eXtreme Low-Power (XLP) Features
• Sleep mode: 50 nA @ 1.8V, typical
• Windowed Watchdog Timer: 500 nA @ 1.8V,
typical
• Secondary Oscillator: 500 nA @ 32 kHz
• Operating Current:
- 8 uA @ 32 kHz, 1.8V, typical
- 32 uA/MHz @ 1.8V, typical
Digital Peripherals
• Complementary Waveform Generator (CWG):
- Rising and falling edge dead-band control
- Full-bridge, half-bridge, 1-channel drive
- Multiple signal sources
• Capture/Compare/PWM (CCP) modules:
- Five CCPs
- 16-bit resolution for Capture/Compare modes
- 10-bit resolution for PWM mode
• 10-Bit Pulse-Width Modulators (PWM):
- Two 10-bit PWMs
• Serial Communications:
- Five Enhanced USART (EUSART) with
- SPI
- I
• 59 I/O Pins and One Input Pin:
- Individually programmable pull-ups
- Slew rate control
- Interrupt-on-change
- Input level selection control
Preliminary
PIC18(L)F67K40
to minimize active power consumption of
unused peripherals
Auto-Baud Detect, Auto-wake-up on Start.
RS-232, RS-485, LIN compatible
2
C, SMBus and PMBus™ compatible
DS40001841B-page 1

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC18LF67K40 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Microchip Technology PIC18LF67K40

  • Page 1 - Industrial: -40°C to 85°C • 59 I/O Pins and One Input Pin: - Extended: -40°C to 125°C - Individually programmable pull-ups - Slew rate control - Interrupt-on-change - Input level selection control Preliminary  2016 Microchip Technology Inc. DS40001841B-page 1...
  • Page 2 - Internal connections to comparators, Fixed Voltage Reference and ADC • Three Comparators (CMP): - Five external inputs - External output via PPS • Fixed Voltage Reference (FVR) module: - 1.024V, 2.048V and 4.096V output levels Preliminary  2016 Microchip Technology Inc. DS40001841B-page 2...
  • Page 3 PIC18(L)F65/66K40 Data Sheet, 64-Pin, 8-bit Flash Microcontrollers DS40001841 PIC18(L)F67K40 Data Sheet, 64-Pin, 8-bit Flash Microcontrollers Note: For other small form-factor package availability and marking information, please visit http://www.microchip.com/packaging or contact your local sales office. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 3...
  • Page 4 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Note: It is recommended that the exposed bottom pad be connected to V . However, it must not be the only V connection to the device. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 4...
  • Page 5 Pin Allocation Tables TABLE 1: 64-PIN ALLOCATION TABLE (PIC18(L)F6XK40) ANA0 — C1IN4- T8IN — — — — — — — — — C2IN4- C3IN4- ANA1 — — T2IN — — — — — — — — — — ANA2 C1IN1+ —...
  • Page 6 TABLE 1: 64-PIN ALLOCATION TABLE (PIC18(L)F6XK40) (CONTINUED) IOCC1 SOSCI — — — T6IN — — — — — IOCC2 — — — — — CWG1IN — — — — — — — (3,4) IOCC3 — — — — — — —...
  • Page 7 TABLE 1: 64-PIN ALLOCATION TABLE (PIC18(L)F6XK40) (CONTINUED) ANE5 IOCE5 — — — CCP1 — — — — — — — — IOCE6 ANE6 — — — CCP3 — — SMT1WIN1 — — — — — SMT1SIG1 IOCE7 ANE7 — — —...
  • Page 8 TABLE 1: 64-PIN ALLOCATION TABLE (PIC18(L)F6XK40) (CONTINUED) — — — — — — — — — — — — — — — — — — — — — — — — — — — — 10, 38 — — — —...
  • Page 9: Table Of Contents

    40.0 Packaging Information................................621 Appendix A: Revision History................................628 Appendix B: Device Differences ................................ 629 The Microchip Website ..................................630 Customer Change Notification Service .............................. 630 Customer Support ....................................630 Product Identification System ................................631 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 9...
  • Page 10 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 website at www.microchip.com to receive the most current information on all of our products. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 10...
  • Page 11: Device Overview

    • Peripheral Module Disable: Modules that are mode, until the primary clock source is available. not being used in the code can be selectively disabled using the PMD module. This further reduces the power consumption. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 11...
  • Page 12 • Windowed Watchdog Timer (WWDT): - Timer monitoring of overflow and underflow events - Variable prescaler selection - Variable window size selection - All sources configurable in hardware or software Preliminary  2016 Microchip Technology Inc. DS40001841B-page 12...
  • Page 13 Programmable Brown-out Reset (BOR) POR, BOR, RESET Instruction, Stack Overflow, Resets (and Delays) Stack Underflow (PWRT, OST), MCLR, WDT 75 Instructions; Instruction Set 83 with Extended Instruction Set enabled Operating Frequency DC – 64 MHz Preliminary  2016 Microchip Technology Inc. DS40001841B-page 13...
  • Page 14 OSC1/CLKIN and OSC2/CLKOUT are only available in select oscillator modes and when these pins are not being used as digital I/O. Refer to Section 4.0 “Oscillator Module (with Fail-Safe Clock Monitor)” for additional information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 14...
  • Page 15 For example, in C the COG1CON0 enable bit • EUSART can be set with the G1EN = 1 instruction. In assembly, this bit can be set with the BSF • MSSP COG1CON0,G1EN instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 15...
  • Page 16: Guidelines For Getting Started With Pic18(L)F6Xk40 Microcontrollers

    R2: 100Ω to 470Ω device in the application. In other words, select the tank capacitor so that it meets the acceptable voltage sag at the device. Typical values range from 4.7 F to 47 F. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 16...
  • Page 17 MCLR from the external capacitor, C1, in the event of MCLR pin breakdown, due to Electrostatic Discharge (ESD) or Electrical Overstress (EOS). Ensure that the MCLR pin and V specifications are met. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 17...
  • Page 18 Selection for rfPIC™ and PICmicro Devices” ® • AN849, “Basic PICmicro Oscillator Design” ® • AN943, “Practical PICmicro Oscillator Analysis Oscillator and Design” Crystal • AN949, “Making Your Oscillator Work” OSCI DEVICE PINS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 18...
  • Page 19: Device Configuration

    Configuration Word 6 at 300000h through 30000Bh. Note: The DEBUG bit in Configuration Words is managed automatically device development tools including debuggers and programmers. For normal device operation, this bit should be maintained as a ‘1’. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 19...
  • Page 20 010 = HS (crystal oscillator) above 8 MHz; PFM set to high power 001 = XT (crystal oscillator) above 500 kHz, below 8 MHz; PFM set to medium power 000 = LP (crystal oscillator) optimized for 32.768 kHz; PFM set to low power Preliminary  2016 Microchip Technology Inc. DS40001841B-page 20...
  • Page 21 If FEXTOSC = HS, XT, LP, then this bit is ignored Otherwise: 1 = CLKOUT function is disabled; I/O or oscillator function on OSC2 0 = CLKOUT function is enabled; FOSC/4 clock appears at OSC2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 21...
  • Page 22 MCLRE: Master Clear (MCLR) Enable bit If LVP = RE3 pin function is MCLR If LVP = 1 = MCLR pin is MCLR 0 = MCLR pin function is port defined function Preliminary  2016 Microchip Technology Inc. DS40001841B-page 22...
  • Page 23 01 = Brown-out Reset Voltage (V ) set to 2.7V 00 = Brown-out Reset Voltage (V ) set to 2.85V Note 1: The higher voltage setting is recommended for operation at or above 16 MHz. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 23...
  • Page 24 00110 00110 1:1024 32 ms 00101 00101 1:512 16 ms 00100 00100 1:256 8 ms 00011 00011 1:128 4 ms 00010 00010 1:64 2 ms 00001 00001 1:32 1 ms 00000 00000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 24...
  • Page 25 WDTCWS<2:0>: WDT Window Select bits WINDOW at POR Software Keyed WDTCWS control of access Window delay Window opening Value WINDOW required? Percent of time Percent of time 37.5 62.5 62.5 37.5 87.5 12.5 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 25...
  • Page 26 WRTB: Boot Block Write Protection bit 1 = Boot Block NOT write-protected 0 = Boot Block write-protected bit 0 WRTC: Configuration Register Write Protection bit 1 = Configuration Register NOT write-protected 0 = Configuration Register write-protected Preliminary  2016 Microchip Technology Inc. DS40001841B-page 26...
  • Page 27 1 = Memory Boot Block NOT protected from table reads executed in other blocks 0 = Memory Boot Block protected from table reads executed in other blocks bit 0 Unimplemented: Read as ‘1’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 27...
  • Page 28 TABLE 3-1: SUMMARY OF CONFIGURATION WORDS Default/ Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Unprogrammed Value 30 0000h CONFIG1L — RSTOSC2 RSTOSC1 RSTOSC0 — FEXTOSC2 FEXTOSC1 FEXTOSC0 1111 1111 30 0001h CONFIG1H —...
  • Page 29 See Section 11.2 “User ID, Device ID and Configuration Word Access” for more information on accessing these memory locations. For more information on checksum calculation, see the “PIC18(L)F6XK40 Memory Programming Specification” (DS40001822). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 29...
  • Page 30 R = Readable bit ‘1’ = Bit is set 0’ = Bit is cleared x = Bit is unknown bit 15-0 DEV<15:0>: Device ID bits Device Device ID PIC18F67K40 6AC0h PIC18LF67K40 6B20h Preliminary  2016 Microchip Technology Inc. DS40001841B-page 30...
  • Page 31 These bits are used to identify a major revision. A major revision is indicated by an all-layer revision (A0, B0, C0, etc.). Revision A = 6’b00_0000 bit 5-0 MNRREV<5:0>: Minor Revision ID bits These bits are used to identify a minor revision. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 31...
  • Page 32: Oscillator Module (With Fail-Safe Clock Monitor)

    If an external clock source is selected, the FEXTOSC bits of Configuration Word 1 must be used in conjunction with the RSTOSC bits to select the External Clock mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 32...
  • Page 33 ® FIGURE 4-1: SIMPLIFIED PIC MCU CLOCK SOURCE BLOCK DIAGRAM Rev. 10-000208D 5/10/2016 CLKIN/OSC1 External Oscillator (EXTOSC) CLKOUT/OSC2 CDIV<4:0> 4x PLL COSC<2:0> SOSCIN/SOSCI Secondary 1001 Oscillator (SOSC) 1000 Sleep 0111 System Clock SOSCO 0110 LFINTOSC 0101 31 kHz 0100 SYSCMD Peripheral Clock Oscillator 0011...
  • Page 34 = 1 MHz (4 MHz/4) 4 MHz LFINTOSC SOSC Reserved 4 MHz EXTOSC + 4xPLL (1) Reserved 64 MHz = 64 MH Note 1: EXTOSC must meet the PLL specifications (Table 37-9). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 34...
  • Page 35 EXTOSC configured by the FEXTOSC bits of Configuration Word 1 (Register 3-1). HFINTOSC frequency is set with the HFFRQ bits of the OSCFRQ register (Register 4-5). EXTOSC must meet the PLL specifications (Table 37-9). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 35...
  • Page 36 If CSWHOLD = 0, the user may not see this bit set because, when the oscillator becomes ready there may be a delay of one instruction clock before this bit is set. The clock switch occurs in the next instruction cycle and this bit is cleared. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 36...
  • Page 37 PLLR: PLL is Ready bit The PLL is ready to be used 0 = The PLL is not enabled, the required input source is not ready, or the PLL is not locked. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 37...
  • Page 38 HFFRQ<3:0>: HFINTOSC Frequency Selection bits HFFRQ<3:0> Nominal Freq (MHz) 1001 1010 1111 Reserved 1110 1101 1100 1011 1000 0111 0110 0101 0100 0011 (1,2) 0010 0001 0000 Note 1: Refer to Table 4-1 for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 38...
  • Page 39 HFTUN<5:0>: HFINTOSC Frequency Tuning bits 01 1111 = Maximum frequency • • • 00 0000 = Center frequency. Oscillator module is running at the calibrated frequency (default value). • • • 10 0000 = Minimum frequency Preliminary  2016 Microchip Technology Inc. DS40001841B-page 39...
  • Page 40 2 ADOEN: ADC Oscillator Manual Request Enable bit 1 = ADC oscillator is explicitly enabled 0 = ADC oscillator could be enabled by requesting peripheral bit 1-0 Unimplemented: Read as ‘0’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 40...
  • Page 41 OSC2/CLKOUT is available for general purpose I/O or (above 8 MHz). CLKOUT. Figure 4-2 shows the pin connections for EC mode. Figure 4-3 Figure 4-4 show typical circuits for quartz crystal and ceramic resonators, respectively. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 41...
  • Page 42 2: The value of R varies with the Oscillator mode selected (typically between 2 M to 10 M. 3: An additional parallel feedback resistor (R may be required for proper ceramic resonator operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 42...
  • Page 43 • AN949, “Making Your Oscillator Work” (DS00949) • TB097, “Interfacing a Micro Crystal MS1V-T1K 32.768 kHz Tuning Fork Crystal to a PIC16F690/SS” (DS91097) • AN1288, “Design Practices for Low-Power External Oscillators” (DS01288) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 43...
  • Page 44 ADOEN bit of the OSCEN register. The ADCRC runs at a fixed frequency of 600 kHz. ADCRC is automatically enabled if it is selected as the clock source for the ADC module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 44...
  • Page 45 The device may enter Sleep while waiting for the switch as described in Section 4.4.3 “Clock Switch and Note: If the PLL fails to lock, the FSCM will Sleep”. trigger. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 45...
  • Page 46 WRITTEN OSC #1 OSC #2 ORDY NOSCR NOTE 1 CSWIF USER CSWHOLD CLEAR Note 1: CSWIF is asserted coincident with NOSCR, and may be cleared before or after clearing CSWHOLD = 0. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 46...
  • Page 47 CSWHOLD Note 1: CSWIF may be cleared before or after rewriting OSCCON1; CSWIF is not automatically cleared. 2: ORDY = 0 if OSCCON1 does not match OSCCON2; a new switch will begin. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 47...
  • Page 48 NOSC and NDIV bits of the OSCCON1 register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 48...
  • Page 49 Failure Detected OSCFIF Test Test Test Note: The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in this example have been chosen for clarity. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 49...
  • Page 50 Page — — — CSWEN — — FCMEN 13:8 CLKOUTEN CONFIG1 — RSTOSC<2:0> — FEXTOSC<2:0> Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used by clock sources. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 50...
  • Page 51: Reference Clock Output Module

    • Programmable clock divider • Selectable duty cycle FIGURE 5-1: CLOCK REFERENCE BLOCK DIAGRAM Rev. 10-000261B 5/11/2016 CLKRDIV<2:0> Counter Reset CLKREN CLKRDC<1:0> CLKRCLK Register CLKR Duty Cycle To Peripherals CLKREN CLKRCLK<3:0> Preliminary  2016 Microchip Technology Inc. DS40001841B-page 51...
  • Page 52 FIGURE 5-2: CLOCK REFERENCE TIMING Rev. 10-000264B 5/25/2016 CLKRCLK CLKREN CLKR Output CLKRDIV<2:0> = 001 CLKRDC<1:0> = 10 Duty Cycle (50%) CLKR Output CLKRCLK/2 CLKRDIV<2:0> = 001 CLKRDC<1:0> = 01 Duty Cycle (25%) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 52...
  • Page 53 The clock divider values can be changed while the module is enabled; however, in order to prevent glitches on the output, the DIV<2:0> bits should only be changed when the module is disabled (EN = 0). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 53...
  • Page 54 001 = Base clock value divided by 2 000 = Base clock value Note 1: Bits are valid for reference clock divider values of two or larger, the base clock cannot be further divided. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 54...
  • Page 55 — — CLK<2:0> PMD0 SYSCMD FVRMD HLVDMD CRCMD SCANMD NVMMD CLKRMD IOCMD RxyPPS — — RxyPPS<5:0> Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by the CLKR module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 55...
  • Page 56: Power-Saving Operation Modes

    Multi-cycle instructions are executed to completion before fetching 0004h. If the pre-fetched instruction clears GIE, the ISR will not occur, but DOZEN is still cleared and the CPU will resume exec ution at full speed. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 56...
  • Page 57 DOE = 0; // make main() go fast ADIF = 0; // else check other interrupts... if (TMR0IF) timerTick++; DOE = 1; // make main() go slow TMR0IF = 0; Preliminary  2016 Microchip Technology Inc. DS40001841B-page 57...
  • Page 58 Upon a wake from a Sleep event, the core will wait for a combination of three conditions before beginning execution. The conditions are: • PFM Ready • COSC-Selected Oscillator Ready • BOR Ready (unless BOR is disabled) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 58...
  • Page 59 The Normal mode is beneficial for applications Low-Power Sleep mode can be selected by setting the that need to wake from Sleep quickly and frequently. VREGPM bit of the VREGCON register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 59...
  • Page 60 Doze mode, except that in IDLE both the CPU and PFM are shut off. Note: If CLKOUTEN is enabled (CLKOUTEN = 0, Configuration Word 1H), the output will con- tinue operating while in Idle. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 60...
  • Page 61 0 = Normal Power mode enabled in Sleep Draws higher current in Sleep, faster wake-up bit 0 Reserved: Read as ‘1’. Maintain this bit set. Note 1: PIC18F6xK40 only. Section 37.0 “Electrical Specifications”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 61...
  • Page 62 When ROI = 1 or DOE = 1, DOZEN is changed by hardware interrupt entry and/or exit. Entering ICD overrides DOZEN, returning the CPU to full execution speed; this bit is not affected. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 62...
  • Page 63 VREGPM Reserved CPUDOZE IDLEN DOZEN — DOZE<2:0> WDTCON0 — — WDTPS<4:0> WDTCON1 — WDTPS<2:0> — WINDOW<2:0> Note — = unimplemented location, read as ‘0’. Shaded cells are not used in Power-Down mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 63...
  • Page 64: Peripheral Module Disable (Pmd)

    Depending on the module, it may take up to one full instruction cycle for the module to become active. There should be no interaction with the module (e.g., writing to registers) for at least one instruction after it has been re-enabled. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 64...
  • Page 65 ) to peripherals, however peripherals clocked by F /4 are not affected. Subject to SCANE bit in CONFIG4H. When enabling NVM, a delay of up to 1 µs may be required before accessing data. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 65...
  • Page 66 TMR1MD: Disable Timer TMR1 bit 1 = TMR1 module disabled 0 = TMR1 module enabled bit 0 TMR0MD: Disable Timer TMR0 bit 1 = TMR0 module disabled 0 = TMR0 module enabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 66...
  • Page 67 SMT1MD: Disable Comparator SMT1 bit 1 = SMT1 module disabled 0 = SMT1 module enabled bit 0 TMR8MD: Disable Comparator TMR8 bit 1 = TMR8 module disabled 0 = TMR8 module enabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 67...
  • Page 68 1 = C1 module disabled 0 = C1 module enabled bit 0 ZCDMD: Disable ZCD bit 1 = ZCD module disabled 0 = ZCD module enabled Note 1: Subject to ZCD bit in CONFIG2H. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 68...
  • Page 69 CCP2MD: Disable CCP2 Module bit 1 = CCP2 module disabled 0 = CCP2 module enabled bit 0 CCP1MD: Disable CCP1 Module bit 1 = CCP1 module disabled 0 = CCP1 module enabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 69...
  • Page 70 — PWM7MD PWM6MD CCP5MD CCP4MD CCP3MD CCP2MD CCP1MD PMD5 — USART5MD USART4MD USART3MD USART2MD USART1MD MSSP2MD MSSP1MD Legend: — = unimplemented, read as ‘0’. Shaded cells are not used by the PMD. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 70...
  • Page 71: Resets

    RESET Instruction Stack Underflow Stack Overflow /MCLR MCLRE WWDT Time-out/ Device Window voilation Reset Power-on Reset Brown-out Power-up Reset Timer LFINTOSC PWRTE LPBOR Reset Table 8-1 Note 1: for BOR active conditions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 71...
  • Page 72 Unimplemented: Read as ‘0’ bit 0 BORRDY: Brown-out Reset Circuit Ready Status bit 1 = The Brown-out Reset Circuit is active and armed 0 = The Brown-out Reset Circuit is disabled or is warming up Preliminary  2016 Microchip Technology Inc. DS40001841B-page 72...
  • Page 73 BOR: Brown-out Reset Status bit 1 = No Brown-out Reset occurred or set to ‘1’ by firmware 0 = A Brown-out Reset occurred (set to ‘0’ in hardware when a Brown-out Reset occurs) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 73...
  • Page 74 The device start-up will be delayed until the BOR is ready and V is higher than the BOR threshold. BOR protection is not active during Sleep. The device wake-up will be delayed until the BOR is ready. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 74...
  • Page 75 Begins immediately FIGURE 8-3: BROWN-OUT SITUATIONS Internal PWRT Reset Internal < T PWRT PWRT (1) Reset Internal PWRT Reset Note 1: T delay only if PWRTE bit is programmed to ‘0’. PWRT Preliminary  2016 Microchip Technology Inc. DS40001841B-page 75...
  • Page 76 MCLR pin low. 8.6.2 MCLR DISABLED When MCLR is disabled, the MCLR becomes input-only and pin functions such as internal weak pull-ups are under software control. See Section 15.1 “I/O Priorities” for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 76...
  • Page 77 FIGURE 8-4: RESET START-UP SEQUENCE Internal POR PWRT Power-up Timer MCLR MCLR Internal RESET Oscillator Modes External Crystal Oscillator Start-up Timer Oscillator Internal Oscillator Oscillator External Clock (EC) CLKIN Preliminary  2016 Microchip Technology Inc. DS40001841B-page 77...
  • Page 78 PC + 2. ‘ ’ If a Status bit is not implemented, that bit will be read as Status bits Z, C, DC are reset by POR/BOR (Register 10-2). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 78...
  • Page 79 PCON0 STKOVF STKUNF WDTWV RWDT RMCLR STATUS — WDTCON0 — — WDTPS<4:0> WDTCON1 — WDTCS<2:0> — WINDOW<2:0> Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used by Resets. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 79...
  • Page 80: Windowed Watchdog Timer (Wwdt)

    - WWDT is always off • Configurable time-out period is from 1 ms to 256s (nominal) • Configurable window size from 12.5% to 100% of the time-out period • Multiple Reset conditions Preliminary  2016 Microchip Technology Inc. DS40001841B-page 80...
  • Page 81 Comparator Sizes CLRWDT WINDOW RESET Reserved Reserved Reserved Reserved 18-bit Prescale Counter Reserved MFINTOSC/16 LFINTOSC 5-bit Overflow WDT Time-out WDT Counter Latch WDTE<1:0> = 01 WDTE<1:0> = 11 WDTE<1:0> = 10 Sleep Preliminary  2016 Microchip Technology Inc. DS40001841B-page 81...
  • Page 82 When WDTCPS <4:0> in CONFIG3L = 11111, the Reset value of WDTPS<4:0> is 01011. Otherwise, the Reset value of WDTPS<4:0> is equal to WDTCPS<4:0> in CONFIG3L. When WDTCPS <4:0> in CONFIG3L ≠ 11111, these bits are read-only. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 82...
  • Page 83 The Reset value of WINDOW<2:0> is determined by the value of WDTCWS<2:0> in the CONFIG3H register. If WDTCCS<2:0> in CONFIG3H ≠ 111, these bits are read-only. If WDTCWS<2:0> in CONFIG3H ≠ 111, these bits are read-only. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 83...
  • Page 84 Note 1: The 18-bit WDT prescale value, PSCNT<17:0> includes the WDTPSL, WDTPSH and the lower bits of the WDTTMR registers. PSCNT<17:0> is intended for debug operations and should be read during normal operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 84...
  • Page 85 Note 1: The 18-bit WDT prescale value, PSCNT<17:0> includes the WDTPSL, WDTPSH and the lower bits of the WDTTMR registers. PSCNT<17:0> is intended for debug operations and should be read during normal operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 85...
  • Page 86 WDTCON0 register. Executing a CLRWDT instruction without performing Disabled such an arming action will trigger a window violation regardless of whether the window is open or not. Table 9-2 for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 86...
  • Page 87 Unaffected FIGURE 9-2: WINDOW PERIOD AND DELAY Rev. 10-000 163A 11/8/201 3 CLRWDT Instruction (or other WDT reset) Window Period Window Closed Window Open Window Delay Time-out Event (window violation can occur) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 87...
  • Page 88 — WDTPSL PSCNT<7:0> WDTPSH PSCNT<15:8> WDTTMR WDTTMR<4:0> STATE PSCNT<17:16> Legend: x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by Windowed Watchdog Timer. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 88...
  • Page 89: Memory Organization

    Additional detailed information on the operation of the Program Flash Memory and Data EEPROM Memory is Note: For memory information on this family of provided in Section 11.0 “Nonvolatile Memory devices, see Table 10-1 Table 10-2. (NVM) Control”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 89...
  • Page 90 The stack is a separate SRAM panel, apart from all user memory panels. The addresses do not roll over. The region is read as ‘0’. Not code-protected. Device/Revision IDs are hard-coded in silicon. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 90...
  • Page 91 01 C000h Block 7 8 KW CP, WRT7, EBTR7 01 FFFFh 30 0000h 6 Words CONFIG WRTC 30 000Bh 31 0000h 31 00FFh 1 KW Data EEPROM CPD, WRTD 31 0100h 31 03FFh Preliminary  2016 Microchip Technology Inc. DS40001841B-page 91...
  • Page 92 TOSU:TOSH:TOSL and do a return. The user must disable the Global Interrupt Enable (GIE) bits while accessing the stack to prevent inadvertent stack corruption. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 92...
  • Page 93 PC, it will set the STKUNF bit and a Reset will be generated. This condition can be generated by the RETURN, RETLW and RETFIE instructions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 93...
  • Page 94 STATUS, WREG and BSR registers at the end of a subroutine call. To use the fast register stack for a subroutine call, a CALL label, FAST instruction must be executed to save the STATUS, Preliminary  2016 Microchip Technology Inc. DS40001841B-page 94...
  • Page 95 Data is transferred to or from program memory one byte at a time. Table read and table write operations are discussed further in Section 11.1.1 “Table Reads and Table Writes”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 95...
  • Page 96 All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction is “flushed” from the pipeline while the new instruction is being fetched and then executed. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 96...
  • Page 97 ; is RAM location 0? 1100 0001 0010 0011 MOVFF REG1, REG2 ; Yes, execute this word 1111 0100 0101 0110 ; 2nd word of instruction 0010 0100 0000 0000 ADDWF REG3 ; continue code Preliminary  2016 Microchip Technology Inc. DS40001841B-page 97...
  • Page 98 This instruction ignores the BSR completely when it executes. 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. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 98...
  • Page 99 FIGURE 10-4: DATA MEMORY MAP FOR PIC18(L)F6XK40 DEVICES Bank BSR<3:0> addr<7:0> PIC18(L)F66K40 Address PIC18(L)F65K40 PIC18(L)F67K40 addr<11:0> Access RAM Access RAM 000h 05Fh Bank 0 0000 060h 0FFh 100h Bank 1 0001 • Bank 2 • 0010 • Bank 3 0011 3FFh 400h Virtual Bank...
  • Page 100 The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>) to the registers of the Access Bank. The MOVFF instruction embeds the entire 12-bit address in the instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 100...
  • Page 101 The mapping of the Access Bank is slightly different when the extended instruction set is enabled (XINST Configuration bit = 1). This is discussed in more detail Section 10.7.3 “Mapping the Access Bank in Indexed Literal Offset Mode”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 101...
  • Page 102 FDAh FSR2H FB2h T6HLT F8Ah PORTB F62h ADPREVH FD9h FSR2L FB1h T6CON F89h PORTA F61h ADPREVL FD8h STATUS FB0h T6PR F88h TRISH F60h ADCON0 Note 1: This is not a physical register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 102...
  • Page 103 E9Bh IOCCF F3Ah CWG1CON0 F12h SMT1CPWU EEAh RCREG3 EC2h LVDCON0 E9Ah ANSELB F39h CWG1DBF F11h SMT1CPWH EE9h BAUDCON4 EC1h ANSELH E99h WPUB F38h CWG1DBR F10h SMT1CPWL EE8h TXSTA4 EC0h WPUH E98h ODCONB Preliminary  2016 Microchip Technology Inc. DS40001841B-page 103...
  • Page 104 T7GPPS E73h RE1PPS E4Bh BORCON E23h IPR4 DFBh T7CKIPPS E72h RE0PPS E4Ah VREGCON E22h IPR3 DFAh T5GPPS E71h RD7PPS E49h OSCFREQ E21h IPR2 DF9h T5CKIPPS Note 1: Not available on LF parts. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 104...
  • Page 105 Uses contents of FSR0 to address data memory – value of FSR1 pre-incremented (not a physical register) – value of -------- FSR0 offset by W Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 105...
  • Page 106 — CS<3:0> ----0000 FBEh T2HLT PSYNC CPOL CSYNC MODE<4:0> 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 106...
  • Page 107 RCEN RSEN 00000000 F95h SSP1CON1 WCOL SSPOV SSPEN SSPM<3:0> 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 107...
  • Page 108 ADERRL<7:0> 00000000 F6Dh ADUTHH ADUTHH<15:8> 00000000 F6Ch ADUTHL ADUTHL<7:0> 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 108...
  • Page 109 — xxxxxxx0 F44h CRCSHIFTH SHIFT<15:8> 00000000 F43h CRCSHIFTL SHIFT<7:0> 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 109...
  • Page 110 — WSEL<4:0> --00000 F1Ah SMT1SIG — — — SSEL<4:0> --00000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 110...
  • Page 111 EUSART2 Transmit Register 00000000 EF1h RC2REG EUSART2 Receive Register 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 111...
  • Page 112 INTP INTN -----100 EC8h CM3CON0 — — — SYNC 00-0--00 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 112...
  • Page 113 SLRCONC SLRC7 SLRC6 SLRC5 SLRC4 SLRC3 SLRC2 SLRC1 SLRC0 11111111 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 113...
  • Page 114 — — RE5PPS<5:0> --000000 E76h RE4PPS — — RE4PPS<5:0> --000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 114...
  • Page 115 PMD1 TMR7MD TMR6MD TMR5MD TMR4MD TMR3MD TMR2MD TMR1MD TMR0MD 00000000 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 115...
  • Page 116 IPR5 TMR8IP TMR7IP TMR6IP TMR5IP TMR4IP TMR3IP TMR2IP TMR1IP 11111111 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 116...
  • Page 117 — — T7GPPS<5:0> --011001 DFBh T7CKIPPS — — T7CKIPPS<5:0> --110100 Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 117...
  • Page 118 — — — PPSLOCKED -------0 DD0h — Unimplemented — E7Eh Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition Note Not available on LF devices. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 118...
  • Page 119 For other instructions that do not affect Status bits, see instruction summaries Section 36.0 “Instruction Set Summary” Table 36-3. Note: The C and DC bits operate as the borrow and digit borrow bits, respectively, in subtraction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 119...
  • Page 120 Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the second operand. 2: For Rotate (RRF, RLF) instructions, this bit is loaded with either the high or low-order bit of the Source register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 120...
  • Page 121 Byte. This address specifies either a register address in banks data (Section 10.4.3 “General Purpose Register File”) or a location in the Access Bank (Section 10.4.2 “Access Bank”) as the data source for the instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 121...
  • Page 122 In this case, the FSR1 pair contains ECCh. This means the contents of Bank 14 location ECCh will be added to that F00h of the W register and stored back in Bank 15 ECCh. FFFh Data Memory Preliminary  2016 Microchip Technology Inc. DS40001841B-page 122...
  • Page 123 The SFR map remains the same. Core PIC18 instructions can still operate in both Direct and Indirect Addressing mode; inherent and literal instructions do not change at all. Indirect addressing with FSR0 and FSR1 also remain unchanged. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 123...
  • Page 124 The bank is Bank 14 designated by the Bank Select Register (BSR). The address can be in any implemented F00h bank in the data memory Bank 15 space. F60h SFRs FFFh Data Memory Preliminary  2016 Microchip Technology Inc. DS40001841B-page 124...
  • Page 125 Bank 2 SFRs FFh, as usual. through Bank 14 Bank 0 addresses below 5Fh can still be addressed by using the BSR. Access Bank F00h Bank 15 F60h SFRs FFFh Data Memory Preliminary  2016 Microchip Technology Inc. DS40001841B-page 125...
  • Page 126: Nonvolatile Memory (Nvm) Control

    2: User IDs are eight words ONLY. There is no code protection, table read protection or write protection implemented for this region. 3: Reads as ‘0’, writes clear the WR bit and WRERR bit is set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 126...
  • Page 127 16 bits wide. PFM is arranged in TABLE 11-2: FLASH MEMORY ORGANIZATION BY DEVICE Row Erase Size Write Latches Program Flash Device Data Memory (Bytes) (Words) (Bytes) Memory (Words) PIC18(L)F65K40 16384 PIC18(L)F66K40 32768 1024 PIC18(L)F67K40 65536 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 127...
  • Page 128 The MSBs of the Table Pointer deter- mine where the write block will eventually be written. The process for writing the holding registers to the program memory array is discussed in Section 11.1.6 “Writing to Program Flash Memory”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 128...
  • Page 129 The Table Latch (TABLAT) is an 8-bit register mapped into the SFR space. The Table Latch register is used to hold 8-bit data during data transfers between program memory and data RAM. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 129...
  • Page 130 FIGURE 11-3: TABLE POINTER BOUNDARIES BASED ON OPERATION TBLPTRH TBLPTRL TBLPTRU TABLE ERASE/WRITE TABLE WRITE TBLPTR<21:n+1> TBLPTR<n:0> TABLE READ – TBLPTR<21:0> Note 1: Refer to Table 11-3 for the row size values. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 130...
  • Page 131 TBLPTRL READ_WORD TBLRD*+ ; read into TABLAT and increment MOVF TABLAT, W ; get data MOVWF WORD_EVEN TBLRD*+ ; read into TABLAT and increment MOVFW TABLAT, W ; get data MOVF WORD_ODD Preliminary  2016 Microchip Technology Inc. DS40001841B-page 131...
  • Page 132 PROGRAM FLASH MEMORY READ FLOWCHART Rev. 10-000046B 8/7/2015 Start Read Operation Select PFM (NVMREG<1:0> = 0x10) Select Word Address (TBLPTR registers) Initiate Read operation (TBLRD) Data read now in TABLAT Read Operation Preliminary  2016 Microchip Technology Inc. DS40001841B-page 132...
  • Page 133 If the timing of the steps 1 to 4 is corrupted by an interrupt or a debugger Halt, the action will not take place. 2: Opcodes shown are illustrative; any instruction that has the indicated effect may be used. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 133...
  • Page 134 2: WRERR is set if WR is written to ‘1’ while TBLPTR points to a write-protected address. 3: WRERR is set if WR is written to ‘1’ while TBLPTR points to an invalid address location (Table 10-1 Table 11-1). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 134...
  • Page 135 ; enable block Erase operation INTCON, GIE ; disable interrupts Required MOVLW Sequence MOVWF NVMCON2 ; write 55h MOVLW MOVWF NVMCON2 ; write AAh NVMCON1, WR ; start erase (CPU stalls) INTCON, GIE ; re-enable interrupts Preliminary  2016 Microchip Technology Inc. DS40001841B-page 135...
  • Page 136 ‘0’ to a ‘1’. When modifying individual bytes, it is not necessary to load all holding registers before executing a long write operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 136...
  • Page 137 An example of the required code is given in Example 11-4. Note: Before setting the WR bit, the Table Pointer address needs to be within the intended address range of the bytes in the holding registers. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 137...
  • Page 138 ; point to buffer MOVWF FSR0H MOVLW BUFFER_ADDR_LOW MOVWF FSR0L WRITE_BUFFER_BACK MOVLW BlockSize ; number of bytes in holding register MOVWF COUNTER MOVLW D’64’/BlockSize ; number of write blocks in 64 bytes MOVWF COUNTER2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 138...
  • Page 139 NVMCON2 ; write 0AAh NVMCON1, WR ; start program (CPU stall) DCFSZ COUNTER2 ; repeat for remaining write blocks WRITE_BYTE_TO_HREGS INTCON, GIE ; re-enable interrupts NVMCON1, WREN ; disable write to memory Preliminary  2016 Microchip Technology Inc. DS40001841B-page 139...
  • Page 140 Re-enable Interrupts No delay when writing to Operation (WREN = 1) (GIE = 1) PFM Latches Disable Write/Erase Operation (WREN = 0) Re-enable Interrupts (GIE = 1) Write Operation Increment Address TBLPTR++ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 140...
  • Page 141 WREN bit should be kept clear at all times, except when updating the CONFIG words. The WREN bit is not cleared by hardware. The WR bit will be inhibited from being set unless the WREN bit is set. Verify Operation Preliminary  2016 Microchip Technology Inc. DS40001841B-page 141...
  • Page 142 USER ID, DEV/REV ID AND CONFIGURATION WORD ACCESS (NVMREG<1:0> = X1) Address Function Read Access Write Access 20 0000h-20 000Fh User IDs 3F FFFCh-3F FFFFh Revision ID/Device ID 30 0000h-30 000Bh Configuration Words 1-6 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 142...
  • Page 143 See Section REGISTERS 11.1.1 “Table Reads and Table Writes” regarding table reads. The NVMADRH:NVMADRL registers are used to address the data EEPROM for read and write operations. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 143...
  • Page 144 NVM Interrupt Flag bit (NVMIF) is set. The user can either enable this interrupt or poll this bit. NVMIF must be cleared by software. Data read now in NVMDAT End Read Operation Preliminary  2016 Microchip Technology Inc. DS40001841B-page 144...
  • Page 145 NVMCON2 MOVLW MOVWF NVMCON2 ; Set WR bit to begin write NVMCON1, WR ; Wait for write to complete BTFSC NVMCON1, WR ; Enable INT INTCON, GIE ; Disable writes NVMCON1, WREN Preliminary  2016 Microchip Technology Inc. DS40001841B-page 145...
  • Page 146 ; Compare address high byte with working register Loop ; Skip if greater than working register ; Else go back to erase loop NVMCON1, WREN ; Disable writes INTCON, GIE ; Enable interrupts Preliminary  2016 Microchip Technology Inc. DS40001841B-page 146...
  • Page 147 Once a write operation is initiated, setting this bit to zero will have no effect. The bit can only be set in software. The bit is cleared by hardware when the operation is complete. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 147...
  • Page 148 = Bit is unknown ‘0’ = Bit is cleared ‘1’ = Bit is set -n = Value at POR bit 7-2 Unimplemented: Read as ‘0’ bit 1-0 NVMADR<9:8>: EEPROM Read Address bits Preliminary  2016 Microchip Technology Inc. DS40001841B-page 148...
  • Page 149 — — — CWG1IF IPR8 SCANIP CRCIP NVMIP — — — — CWG1IP Legend: — = unimplemented, read as ‘0’. Shaded bits are not used during EEPROM access. *Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 149...
  • Page 150: 8X8 Hardware Multiplier

    1.8 s 2.8 s 11.2 s 28 s Hardware multiply 15.9 s 25.4 s 102.6 s 254 s Without hardware multiply 16x16 signed 2.5 s 4.0 s 16.0 s 40 s Hardware multiply Preliminary  2016 Microchip Technology Inc. DS40001841B-page 150...
  • Page 151 = (ARG1H  ARG2H  2 (ARG1H  ARG2L  2 (ARG1L  ARG2H  2 (ARG1L  ARG2L) + (-1  ARG2H<7>  ARG1H:ARG1L  2 (-1  ARG1H<7>  ARG2H:ARG2L  2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 151...
  • Page 152: Cyclic Redundancy Check (Crc) Module With Memory Scanner

    CRC calculations. The memory scanner can automatically provide data to the CRC module. The CRC module can also be operated by directly writing data to SFRs, without using a scanner. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 152...
  • Page 153 7-4 DLEN<3:0>: Data Length bits Denotes the length of the data word -1 (See Example 13-1 bit 3-0 PLEN<3:0>: Polynomial Length bits Denotes the length of the polynomial -1 (See Example 13-1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 153...
  • Page 154 ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 ACC<15:8>: CRC Accumulator Register bits Writing to this register writes to the CRC accumulator register. Reading from this register reads the CRC accumulator. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 154...
  • Page 155 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 SHIFT<7:0>: CRC Shifter Register bits Reading from this register reads the CRC Shifter. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 155...
  • Page 156 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-1 X<7:1>: XOR of Polynomial Term XN Enable bits bit 0 Unimplemented: Read as ‘1’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 156...
  • Page 157 Scan Low address registers points to a location that is not mapped in the memory map of the device. CRCEN and CRCGO bits must be set before setting SCANGO bit. Refer to Section 13.9 “Program Memory Scan Configuration” Preliminary  2016 Microchip Technology Inc. DS40001841B-page 157...
  • Page 158 Registers SCANLADRU/H/L form a 22-bit value, but are not guarded for atomic or asynchronous access; registers should only be read or written while SCANGO = 0 (SCANCON0 register). While SCANGO = 1 (SCANCON0 register), writing to this register is ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 158...
  • Page 159 Registers SCANHADRU/H/L form a 22-bit value but are not guarded for atomic or asynchronous access; registers should only be read or written while SCANGO = 0 (SCANCON0 register). While SCANGO = 1 (SCANCON0 register), writing to this register is ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 159...
  • Page 160 Registers SCANHADRU/H/L form a 22-bit value, but are not guarded for atomic or asynchronous access; registers should only be read or written while SCANGO = 0 (SCANCON0 register). While SCANGO = 1 (SCANCON0 register), writing to this register is ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 160...
  • Page 161 1010 = TMR8_postscaled 1001 = TMR7_output 1000 = TMR6_postscaled 0111 = TMR5_output 0110 = TMR4_postscaled 0101 = TMR3_output 0100 = TMR2_postscaled 0011 = TMR1_output 0010 = TMR0_output 0001 = CLKREF_output 0000 = LFINTOSC Preliminary  2016 Microchip Technology Inc. DS40001841B-page 161...
  • Page 162 CRC polynomial is always ‘1’ and will always be treated as a ‘1’ by the CRC for calculating the CRC check value. This bit will be read in software as a ‘0’. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 162...
  • Page 163 MSb first (Big Endian). The value of DLEN will determine the MSb. If SHIFTM bit is set, the data will be shifted into the accumulator in reversed order, LSb first (Little Endian). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 163...
  • Page 164 CRC calculation can be read from the CRCACCH/L registers. 10b.If manual entry is used, monitor the CRCIF (or BUSY bit) to determine when the CRCACC registers will hold the check value. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 164...
  • Page 165 CRCDATA registers. The SCANIF bit can only be cleared in software. The SCAN interrupt enable is the SCANIE bit of the PIE7 register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 165...
  • Page 166 Burst mode, may exceed the WWDT time-out period and result in an undesired device Reset. This should be considered when performing memory scans with an application that also utilizes WWDT. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 166...
  • Page 167 SCANE bit of Configuration Word 4 is set. If the SCANE bit is cleared, then the scanner module is not available for use and the SCANMD bit is ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 167...
  • Page 168 NVMIE — — — — CWG1IE IPR8 SCANIP CRCIP NVMIP — — — — CWG1IP Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used for the CRC module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 168...
  • Page 169: Interrupts

    Global Interrupt Enable bit. Note: Do not use the MOVFF instruction to modify any of the interrupt control regis- ters while any interrupt is enabled. Doing so may cause erratic microcontroller behavior. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 169...
  • Page 170 PIRx PIEx IPRx High Priority Interrupt Generation Low Priority Interrupt Generation PIR1 PIE1 IPR1 PIR2 PIE2 IPR2 PIR0 Interrupt to PIE0 CPU Vector at IPR0 Location 0018h PIRx GIEH/GIE PIEx IPRx GIEL/PEIE Preliminary  2016 Microchip Technology Inc. DS40001841B-page 170...
  • Page 171 10 Peripheral Interrupt Priority registers (IPR0, IPR1, IPR2, IPR3, IPR4 and IPR5, IPR6, IPR7, IPR8 and IPR9). Using the priority bits requires that the Interrupt Priority Enable (IPEN) bit be set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 171...
  • Page 172 User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. This feature allows for software polling. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 172...
  • Page 173 2: IOCIF is a read-only bit, to clear the interrupt condition, all bits in the IOCF register must be cleared. 3: The external interrupt GPIO pin is selected by the INTPPS register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 173...
  • Page 174 0 = The A/D conversion is not complete or has not been started Note 1: The CSWIF interrupt will not wake the system from Sleep. The system will sleep until another interrupt causes the wake-up. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 174...
  • Page 175 0 = Comparator C2 output has not changed bit 0 C1IF: Comparator 1 Interrupt Flag bit 1 = Comparator C1 output has changed (must be cleared by software) 0 = Comparator C1 output has not changed Preliminary  2016 Microchip Technology Inc. DS40001841B-page 175...
  • Page 176 0 = No bus collision occurred bit 0 SSP1IF: Synchronous Serial Port 1 Interrupt Flag bit 1 = The transmission/reception is complete (must be cleared in software) 0 = Waiting to transmit/receive Preliminary  2016 Microchip Technology Inc. DS40001841B-page 176...
  • Page 177 0 = The EUSART3 receive buffer is empty bit 0 TX3IF: EUSART3 Transmit Interrupt Flag bit 1 = The EUSART3 transmit buffer, TX3REG, is empty (cleared by writing TX3REG) 0 = The EUSART3 transmit buffer is full Preliminary  2016 Microchip Technology Inc. DS40001841B-page 177...
  • Page 178 0 = No TMR2 to PR2 match occurred bit 0 TMR1IF: TMR1 to PR1 Match Interrupt Flag bit 1 = TMR1 to PR1 match occurred (must be cleared in software) 0 = No TMR1 to PR1 match occurred Preliminary  2016 Microchip Technology Inc. DS40001841B-page 178...
  • Page 179 1 = TMR3 gate interrupt occurred (must be cleared in software) 0 = No TMR3 gate occurred bit 0 TMR1GIF: TMR1 Gate Interrupt Flag bit 1 = TMR1 gate interrupt occurred (must be cleared in software) 0 = No TMR1 gate occurred Preliminary  2016 Microchip Technology Inc. DS40001841B-page 179...
  • Page 180 0 = No TMR register capture occurred Compare mode: 1 = A TMR register compare match occurred (must be cleared in software) 0 = No TMR register compare match occurred PWM mode: Unused in PWM mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 180...
  • Page 181 0 = No TMR register capture occurred Compare mode: 1 = A TMR register compare match occurred (must be cleared in software) 0 = No TMR register compare match occurred PWM mode: Unused in PWM mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 181...
  • Page 182 0 = Interrupt event has not occurred bit 4-1 Unimplemented: Read as ‘0’ bit 0 CWG1IF: CWG1 Interrupt Flag bit 1 = Interrupt has occurred (must be cleared by software) 0 = Interrupt event has not occurred Preliminary  2016 Microchip Technology Inc. DS40001841B-page 182...
  • Page 183 1 = Interrupt has occurred (must be cleared by software) 0 = Interrupt event has not occurred bit 0 SMT1IF: SMT1 Interrupt Flag bit 1 = Interrupt has occurred (must be cleared by software) 0 = Interrupt event has not occurred Preliminary  2016 Microchip Technology Inc. DS40001841B-page 183...
  • Page 184 1 = Enabled 0 = Disabled Note 1: PIR0 interrupts are not disabled by the PEIE bit in the INTCON register. are not disabled by the PEIE bit in the INTCON register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 184...
  • Page 185 5-2 Unimplemented: Read as ‘0’ bit 1 ADTIE: ADC Threshold Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 ADIE: ADC Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 185...
  • Page 186 1 = Enabled 0 = Disabled bit 1 C2IE: Comparator 2 Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 C1IE: Comparator 1 Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 186...
  • Page 187 0 = Disabled bit 1 BCL1IE: MSSP1 Bus Collision Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 SSP1IE: Synchronous Serial Port 1 Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 187...
  • Page 188 1 = Enabled 0 = Disabled bit 1 RC3IE: EUSART3 Receive Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 TX3IE: EUSART3 Transmit Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 188...
  • Page 189 1 TMR2IE: TMR2 to PR2 Match Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 TMR1IE: TMR1 to PR1 Match Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 189...
  • Page 190 1 = Enabled 0 = Disabled bit 1 TMR3GIE: TMR3 Gate Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 TMR1GIE: TMR1 Gate Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 190...
  • Page 191 1 = Enabled 0 = Disabled bit 1 CCP2IE: ECCP2 Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 CCP1IE: ECCP1 Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 191...
  • Page 192 5 NVMIE: NVM Interrupt Enable bit 1 = Enabled 0 = Disabled bit 4-1 Unimplemented: Read as ‘0’ bit 0 CWG1IE: CWG1 Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 192...
  • Page 193 1 = Enabled 0 = Disabled bit 1 SMT1PRAIE: SMT1 Period Acquisition Interrupt Enable bit 1 = Enabled 0 = Disabled bit 0 SMT1IE: SMT1 Interrupt Enable bit 1 = Enabled 0 = Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 193...
  • Page 194 1 INT1IP: External Interrupt 1 Priority bit 1 = High priority 0 = Low priority bit 0 INT0IP: External Interrupt 0 Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 194...
  • Page 195 Unimplemented: Read as ‘0’ bit 1 ADTIP: ADC Threshold Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 ADIP: ADC Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 195...
  • Page 196 1 C2IP: Comparator 2 Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 C1IP: Comparator 1 Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 196...
  • Page 197 BCL1IP: MSSP1 Bus Collision Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 SSP1IP: Synchronous Serial Port 1 Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 197...
  • Page 198 1 RC3IP: EUSART3 Receive Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 TX3IP: EUSART3 Transmit Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 198...
  • Page 199 TMR2IP: TMR2 to PR2 Match Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 TMR1IP: TMR1 to PR1 Match Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 199...
  • Page 200 1 TMR3GIP: TMR3 Gate Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 TMR1GIP: TMR1 Gate Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 200...
  • Page 201 0 = Low priority bit 1 CCP2IP: ECCP2 Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 CCP1IP: ECCP1 Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 201...
  • Page 202 NVMIP: NVM Interrupt Priority bit 1 = High priority 0 = Low priority bit 4-1 Unimplemented: Read as ‘0’ bit 0 CWG1IP: CWG1 Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 202...
  • Page 203 1 SMT1PRAIP: SMT1 Period Acquisition Interrupt Priority bit 1 = High priority 0 = Low priority bit 0 SMT1IP: SMT1 Interrupt Priority bit 1 = High priority 0 = Low priority Preliminary  2016 Microchip Technology Inc. DS40001841B-page 203...
  • Page 204 ; STATUS_TEMP located anywhere MOVFF BSR, BSR_TEMP ; BSR_TEMP located anywhere ; USER ISR CODE MOVFF BSR_TEMP, BSR ; Restore BSR MOVF W_TEMP, W ; Restore WREG MOVFF STATUS_TEMP, STATUS ; Restore STATUS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 204...
  • Page 205 SCANIP CRCIP NVMIP ― ― ― ― CWG1IP IPR9 ― ― SMT2PWAIP SMT2PRAIP SMT2IP SMT1PWAIP SMT1PRAIP SMT1IP Legend: — = unimplemented locations, read as ‘0’. Shaded bits are not used for Interrupts. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 205...
  • Page 206: I/O Ports

    A simplified model of a generic I/O port, without the interfaces to other peripherals, is shown in Figure 15-1. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 206...
  • Page 207 Note: It is not necessary to set open-drain control when using the pin for I C; the I module controls the pin and makes the pin open-drain. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 207...
  • Page 208 ANSELE ; Configure analog pins ; for digital only MOVLW ; Value used to ; initialize data ; direction MOVWF TRISE ; Set RE<0> as input ; RE<1> as output ; RE<2> as input Preliminary  2016 Microchip Technology Inc. DS40001841B-page 208...
  • Page 209 — — — — Note 1: Bits RB6 and RB7 read ‘1’ while in Debug mode. 2: Bit PORTG5 is read-only, and will read ‘1’ when MCLRE = 1 (Master Clear enabled). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 209...
  • Page 210 TRISG0 TRISH — — — — TRISH3 TRISH2 TRISH1 TRISH0 Note 1: Bits RB6 and RB7 read ‘1’ while in Debug mode. 2: Bit TRISG5 is read-only, and will read ‘1’ always. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 210...
  • Page 211 LATE4 LATE3 LATE2 LATE1 LATE0 LATF LATF7 LATF6 LATF5 LATF4 LATF3 LATF2 LATF1 LATF0 LATG LATG7 LATG6 — LATG4 LATG3 LATG2 LATG1 LATG0 LATH — — — — LATH3 LATH2 LATH1 LATH0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 211...
  • Page 212 ANSELD4 ANSELD3 ANSELD2 ANSELD1 ANSELD0 ANSELE ANSELE7 ANSELE6 ANSELE5 ANSELE4 ANSELE3 ANSELE2 ANSELE1 ANSELE0 ANSELF ANSELF7 ANSELF6 ANSELF5 ANSELF4 ANSELF3 ANSELF2 ANSELF1 ANSELF0 ANSELG ANSELG7 ANSELG6 — ANSELG4 ANSELG3 ANSELG2 ANSELG1 ANSELG0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 212...
  • Page 213 WPUG1 WPUG0 WPUH — — — — WPUH3 WPUH2 WPUH1 WPUH0 Note 1: If MCLRE = 1, the weak pull-up in RG5 is always enabled; bit WPUG5 is not affected and ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 213...
  • Page 214 ODCONE4 ODCONE3 ODCONE2 ODCONE1 ODCONE0 ODCONF ODCONF7 ODCONF6 ODCONF5 ODCONF4 ODCONF3 ODCONF2 ODCONF1 ODCONF0 ODCONG ODCONG7 ODCONG6 — ODCONG4 ODCONG3 ODCONG2 ODCONG1 ODCONG0 ODCONH — — — — ODCONH3 ODCONH2 ODCONH1 ODCONH0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 214...
  • Page 215 SLRCONE4 SLRCONE3 SLRCONE2 SLRCONE1 SLRCONE0 SLRCONF SLRCONF7 SLRCONF6 SLRCONF5 SLRCONF4 SLRCONF3 SLRCONF2 SLRCONF1 SLRCONF0 SLRCONG SLRCONG7 SLRCONG6 — SLRCONG4 SLRCONG3 SLRCONG2 SLRCONG1 SLRCONG0 SLRCONH — — — — SLRCONH3 SLRCONH2 SLRCONH1 SLRCONH0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 215...
  • Page 216 Note 1: Pins read the I C ST inputs when MSSP inputs select these pins, and I C mode is enabled. 2: The state of this bit is ignored when MCLRE = 1. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 216...
  • Page 217: Interrupt-On-Change

    Sleep mode, if the IOCIE bit is set. If an edge is detected while in Sleep mode, the IOCxF register will be updated prior to the first instruction executed out of Sleep. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 217...
  • Page 218 = IOCBFx IOCBPx 0 or 1 write IOCBFx IOCIE IOC interrupt to CPU core from all other IOCnFx individual pin detectors Q4Q1 Q4Q1 Q4Q1 Q4Q1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 218...
  • Page 219 IOCn pin, or when IOCN[n] = 1 and a negative edge was detected on the IOCn pin 0 = No change was detected, or the user cleared the detected change Preliminary  2016 Microchip Technology Inc. DS40001841B-page 219...
  • Page 220 IOCxN7 IOCxN6 IOCxN5 IOCxN4 IOCxN3 IOCxN2 IOCxN1 IOCxN0 IOCxP IOCxP7 IOCxP6 IOCxP5 IOCxP4 IOCxP3 IOCxP2 IOCxP1 IOCxP0 Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used by interrupt-on-change. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 220...
  • Page 221: Peripheral Pin Select (Pps) Module

    Although every pin has its own PPS peripheral selection register, the selections are identical for every pin as shown in Register 17-2. Note: The notation “Rxy” is a place holder for the pin identifier. For example, RA0PPS. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 221...
  • Page 222 PIC18(L)F67K40 FIGURE 17-1: SIMPLIFIED PPS BLOCK DIAGRAM Rev. 10-000262C 1/27/2016 RA0PPS abcPPS Peripheral abc RxyPPS Peripheral xyz RH3PPS xyzPPS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 222...
  • Page 223 Section “Pin Allocation MOVWF PPSLOCK Tables”. The PPS one-way is also removed. MOVLW MOVWF PPSLOCK ; Set PPSLOCKED bit to disable writes ; Only a BSF instruction will work PPSLOCK,0 ; Enable Interrupts INTCON,GIE Preliminary  2016 Microchip Technology Inc. DS40001841B-page 223...
  • Page 224 001 = Peripheral input is from PORTx Pin 1 (Rx1) 000 = Peripheral input is from PORTx Pin 0 (Rx0) Note 1: The Reset value ‘m’ of this register is determined by device default locations for that input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 224...
  • Page 225 — — EUSART2 Receive RX2PPS 0x32 — — — — — — EUSART2 Transmit TX2PPS 0x31 — — — — — — EUSART3 Receive RX3PPS 0x21 — — — — — — Preliminary  2016 Microchip Technology Inc. DS40001841B-page 225...
  • Page 226 — MSSP2 Clock SSP2CLKPPS 0x1E — — — — — — MSSP2 Data SSP2DATPPS 0x1D — — — — — — MSSP2 Slave Select SSP2SSPPS 0x1F — — — — — — Preliminary  2016 Microchip Technology Inc. DS40001841B-page 226...
  • Page 227 = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-6 Unimplemented: Read as ‘0’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 227...
  • Page 228 — — — CWG1D — — — — — — CWG1C — — — — — — CWG1B — — — — — — CWG1A — — — — — — LATxy Preliminary  2016 Microchip Technology Inc. DS40001841B-page 228...
  • Page 229 CCP3PPS — — CCP3PPS<5:0> CCP4PPS — — CCP4PPS<5:0> CCP5PPS — — CCP5PPS<5:0> SMT1WINPPS — — SMT1WINPPS<5:0> SMT1SIGPPS — — SMT1SIGPPS<5:0> SMT2WINPPS — — SMT2WINPPS<5:0> SMT2SIGPPS — — SMT2SIGPPS<5:0> CWG1PPS — — CWG1PPS<5:0> Preliminary  2016 Microchip Technology Inc. DS40001841B-page 229...
  • Page 230 RX4PPS<5:0> TX4PPS — — TX4PPS<5:0> RX5PPS — — RX5PPS<5:0> TX5PPS — — TX5PPS<5:0> RxyPPS — — RxyPPS<5:0> Legend: — = unimplemented, read as ‘0’. Shaded cells are unused by the PPS module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 230...
  • Page 231: Timer0 Module

    16-bit TMR0 Body Diagram (T016BIT = 1) 8-bit TMR0 Body Diagram (T016BIT = 0) Clear TMR0 High TMR0L TMR0L Byte Read TMR0L COMPARATOR Write TMR0L T0_match TMR0H TMR0 High Byte Latch Enable TMR0H Internal Data Bus Preliminary  2016 Microchip Technology Inc. DS40001841B-page 231...
  • Page 232 When an external clock source is selected, Timer0 can operate as either a timer or a counter. Timer0 will increment on multiples of the rising edge of the external clock source, as determined by the Timer0 prescaler. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 232...
  • Page 233 If Timer0 interrupts are enabled (TMR0IE bit of the PIE0 register = ‘1’), the CPU will be interrupted and the device wake from Sleep (see Section 18.2 “Clock Source Selection” for more details). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 233...
  • Page 234 0111 = 1:8 Postscaler 0110 = 1:7 Postscaler 0101 = 1:6 Postscaler 0100 = 1:5 Postscaler 0011 = 1:4 Postscaler 0010 = 1:3 Postscaler 0001 = 1:2 Postscaler 0000 = 1:1 Postscaler Preliminary  2016 Microchip Technology Inc. DS40001841B-page 234...
  • Page 235 1010 = 1:1024 1001 = 1:512 1000 = 1:256 0111 = 1:128 0110 = 1:64 0101 = 1:32 0100 = 1:16 0011 = 1:8 0010 = 1:4 0001 = 1:2 0000 = 1:1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 235...
  • Page 236 TMR0IP IOCIP INT3IP INT2IP INT1IP INT0IP PMD1 — TMR6MD TMR5MD TMR4MD TMR3MD TMR2MD TMR1MD TMR0MD Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used by the Timer0 module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 236...
  • Page 237: Timer1/3/5/7 Module With Gate Control

    • Special Event Trigger (with CCP) • Selectable Gate Source Polarity • Gate Toggle mode • Gate Single-pulse mode • Gate Value Status • Gate Event Interrupt Figure 19-1 is a block diagram of the Timer1/3/5/7 module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 237...
  • Page 238 3: Synchronize does not operate while in Sleep. 4: See Register 19-3 for clock source selections. 5: See Register 19-4 for gate source selection. 6: Synchronized comparator output should not be used in conjunction with synchronized input clock. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 238...
  • Page 239 RD16: 16-Bit Read/Write Mode Enable bit All 16 bits of Timer1 can be read simultaneously (TMR1H is buffered) 16-bit reads of Timer1 are disabled (TMR1H not buffered) bit 0 ON: Timerx On bit Enables Timerx Disables Timerx Preliminary  2016 Microchip Technology Inc. DS40001841B-page 239...
  • Page 240 GVAL: Timerx Gate Current State bit Indicates the current state of the Timerx gate that could be provided to TMRxH:TMRxL Unaffected by Timerx Gate Enable (TMRxGE) bit 1-0 Unimplemented: Read as ‘0’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 240...
  • Page 241 SOSC 0110 MFINTOSC (500 kHz) MFINTOSC (500 kHz) MFINTOSC (500 kHz) MFINTOSC (500 kHz) 0101 LFINTOSC LFINTOSC LFINTOSC LFINTOSC 0100 HFINTOSC HFINTOSC HFINTOSC HFINTOSC 0011 0010 0001 T1CKIPPS T3CKIPPS T5CKIPPS T7CKIPPS 0000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 241...
  • Page 242 TMR1 overflow TMR1 overflow TMR1 overflow 00010 TMR0 overflow TMR0 overflow TMR0 overflow TMR0 overflow 00001 Pin selected by T1GPPS Pin selected by T3GPPS Pin selected by T5GPPS Pin selected by T7GPPS 00000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 242...
  • Page 243 = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 TMRxH<7:0>:Timerx High Byte bits Preliminary  2016 Microchip Technology Inc. DS40001841B-page 243...
  • Page 244 2 LSB error in resolution will occur when reading the Timer1/3/5/7 value. To utilize the full resolution of Timer1/3/5/7, an asynchronous input signal must be used to gate the Timer1/3/5/7 clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 244...
  • Page 245 A write contention may occur (Register 4-4). by writing to the timer registers, while the register is incrementing. This may produce an unpredictable value in the TMRxH:TMRxL register pair. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 245...
  • Page 246 Timer1/3/5/7 will hold the current count. See Figure 19-4 for timing details. TABLE 19-3: TIMER1/3/5/7 GATE ENABLE SELECTIONS Timer1/3/5/7 TMRxCLK TxGPOL Operation  Counts  Holds Count  Holds Count  Counts Preliminary  2016 Microchip Technology Inc. DS40001841B-page 246...
  • Page 247 The TMRxGIF flag bit operates even when the Timer1/3/5/7 gate is not enabled (GE bit is cleared). For more information on selecting high or low priority status for the Timer1/3/5/7 Gate Event Interrupt see Section 14.0 “Interrupts”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 247...
  • Page 248 If the GIE/GIEH bit of the INTCON register is set, the device will call the Interrupt Service Routine. The secondary oscillator will continue to operate in Sleep regardless of the TxSYNC bit setting. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 248...
  • Page 249 2: In Counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge of the clock. FIGURE 19-4: TIMER1/3/5/7 GATE ENABLE MODE TMRxGE TxGPOL TxG_IN TxCKI TxGVAL Timer1/3/5/7 N + 1 N + 2 N + 3 N + 4 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 249...
  • Page 250 Counting enabled on rising edge of TxG TxG_IN TxCKI TxGVAL TIMER1/3/5/7 N + 1 N + 2 Cleared by Set by hardware on Cleared by software software TMRxGIF falling edge of TxGVAL Preliminary  2016 Microchip Technology Inc. DS40001841B-page 250...
  • Page 251 The Module Disable bits for Timer1 (TMR1MD), Timer3 (TMR3MD), Timer5 (TMR5MD) and Timer7 (TMR7MD) are in the PMD1 register. See Section 7.0 “Peripheral Module Disable (PMD)” for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 251...
  • Page 252 T3GPPS<5:0> T5CKIPPS — — T5CKIPPS<5:0> T5GPPS — — T5GPPS<5:0> T7CKIPPS — — T7CKIPPS<5:0> T7GPPS — — T7GPPS<5:0> Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used by TIMER1/3/5/7. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 252...
  • Page 253: Timer2/4/6/8 Module

    Timer4, Timer6 and Timer8. All references to PR2 apply as well to PR4, PR6 and PR8. FIGURE 20-1: TIMER2 CLOCK SOURCE BLOCK DIAGRAM Rev. 10-000169D 8/7/2015 TxCLK <3:0> INPPS 0000 TMRx_clk TxCLKCON Register 1111 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 253...
  • Page 254 TxCKPS<2:0> Fosc/4 TxPSYNC TMRx_postscaled Comparator Postscaler Sync TxON (2 Clocks) TxOUTPS<3:0> TxCSYNC Note 1: Signal to the CCP to trigger the PWM pulse. 2: See TxRST Register 20-6 for external Reset sources. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 254...
  • Page 255 = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 TxPR<7:0>: Timerx Period Register bits Preliminary  2016 Microchip Technology Inc. DS40001841B-page 255...
  • Page 256 0011 = 1:4 Postscaler 0010 = 1:3 Postscaler 0001 = 1:2 Postscaler 0000 = 1:1 Postscaler Note 1: In certain modes, the TxON bit will be auto-cleared by hardware. See Section 20.5.1 “One-Shot Mode”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 256...
  • Page 257 6: Unless otherwise indicated, all modes start upon ON = 1 and stop upon ON = 0 (stops occur without affecting the value of TMRx). 7: When TMRx = PRx, the next clock clears TMRx, regardless of the operating mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 257...
  • Page 258 (prepared for next start) if TxON becomes ‘0’ (zero); the counter will not restart until an input edge occurs. When TMRx = PRx, the next clock clears TxON. When TMRx = PRx, TxON is not cleared. Both TxON and TMRx_ers are subject to clock sync delays. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 258...
  • Page 259 HFINTOSC HFINTOSC HFINTOSC HFINTOSC 0011 Fosc Fosc Fosc Fosc 0010 Fosc/4 Fosc/4 Fosc/4 Fosc/4 0001 Pin selected by Pin selected by Pin selected by Pin selected by 0000 T2INPPS T4INPPS T6INPPS T8INPPS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 259...
  • Page 260 TMR4 post-scaled Reserved TMR4 post-scaled TMR4 post-scaled 0010 Reserved TMR2 post-scaled TMR2 post-scaled TMR2 post-scaled 0001 Pin selected by Pin selected by Pin selected by Pin selected by 0000 T2INPPS T4INPPS T6INPPS T8INPPS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 260...
  • Page 261 CKPS 0b010 OUTPS 0b0001 TMRx_clk TMRx TMRx_postscaled TMRxIF Note 1: Setting the interrupt flag is synchronized with the instruction clock. Synchronization may take as many as 2 instruction cycles Cleared by software. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 261...
  • Page 262 Normal Period mode. When this bit is set, the timer acts in the One-Shot mode, meaning that upon the timer register matching the PRx period register, the timer will stop incrementing until the timer is manually started again. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 262...
  • Page 263 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON. CPU execution is asynchronous to the timer clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 263...
  • Page 264 MODE<4:0> = 00001 in which a high input level stops the counter. FIGURE 20-5: HARDWARE GATE MODE TIMING DIAGRAM Rev. 10-000 196B 5/30/201 4 MODE 0b00001 TMRx_clk TMRx_ers TMRx TMRx_postscaled PWM Duty Cycle PWM Output Preliminary  2016 Microchip Technology Inc. DS40001841B-page 264...
  • Page 265 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON. CPU execution is asynchronous to the timer clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 265...
  • Page 266 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON. CPU execution is asynchronous to the timer clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 266...
  • Page 267 Note 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON. CPU execution is asynchronous to the timer clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 267...
  • Page 268 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON. CPU execution is asynchronous to the timer clock input. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 268...
  • Page 269 CCPRx pulse-width value and stay deactivated until the timer halts at the PRx period match unless an exter- nal signal edge resets the timer before the match occurs. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 269...
  • Page 270 FIGURE 20-10: EDGE-TRIGGERED HARDWARE LIMIT ONE-SHOT TIMING DIAGRAM Rev. 10-000 201B 5/30/201 4 MODE 0b01100 TMRx_clk Instruction TMRx_ers TMRx TMRx_postscaled PWM Duty Cycle PWM Output Note 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON.
  • Page 271 When TxPSYNC = 0, Timer2 will operate in Sleep as long as the clock source selected is also still running. Selecting the LFINTOSC, MFINTOSC, or HFINTOSC oscillator as the timer clock source will keep the selected oscillator running during Sleep. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 271...
  • Page 272 FIGURE 20-11: LEVEL-TRIGGERED HARDWARE LIMIT ONE-SHOT MODE TIMING DIAGRAM Rev. 10-000 202A 12/20/201 3 MODE 0b1110 TMRx_clk Instruction TMRx_ers TMRx TMRx_postscaled PWM Duty Cycle PWM Output Note 1: BSF and BCF represent Bit-Set File and Bit-Clear File instructions executed by the CPU to set or clear the ON bit of TxCON.
  • Page 273 T4INPPS — — T4INPPS<5:0> T6INPPS — — T6INPPS<5:0> T8INPPS — — T8INPPS<5:0> Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used for Timer2 module. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 273...
  • Page 274: Capture/Compare/Pwm Module

    CCPx module. Register names, module signals, I/O pins, and bit names may use the generic designator ‘x’ to indicate the use of a numeral to distinguish a particular module, when required. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 274...
  • Page 275 When MODE = 0001 or 1011, then the timer associated with the CCP module is cleared. TMR1 is the default selection for the CCP module, so it is used for indication purpose only. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 275...
  • Page 276 When MODE = 0001 or 1011, then the timer associated with the CCP module is cleared. TMR1 is the default selection for the CCP module, so it is used for indication purpose only. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 276...
  • Page 277 10 = CCP1 is based off Timer5 in Capture/Compare mode and Timer6 in PWM mode 01 = CCP1 is based off Timer3 in Capture/Compare mode and Timer4 in PWM mode 00 = CCP1 is based off Timer1 in Capture/Compare mode and Timer2 in PWM mode Preliminary  2016 Microchip Technology Inc. DS40001841B-page 277...
  • Page 278 10 = CCP5 is based off Timer5 in Capture/Compare mode and Timer6 in PWM mode 01 = CCP5 is based off Timer3 in Capture/Compare mode and Timer4 in PWM mode 00 = CCP5 is based off Timer1 in Capture/Compare mode and Timer2 in PWM mode Preliminary  2016 Microchip Technology Inc. DS40001841B-page 278...
  • Page 279 MODE = PWM Mode && FMT = 0: CCPRxL<7:0>: CCPW<7:0> – Pulse-Width LS 8 bits MODE = PWM Mode && FMT = 1: CCPRxL<7:6>: CCPW<1:0> – Pulse-Width LS 2 bits CCPRxL<5:0>: Not used Preliminary  2016 Microchip Technology Inc. DS40001841B-page 279...
  • Page 280 MODE = PWM Mode && FMT = 0: CCPRxH<7:2>: Not used CCPRxH<1:0>: CCPW<9:8> – Pulse-Width MS 2 bits MODE = PWM Mode && FMT = 1: CCPRxH<7:0>: CCPW<9:2> – Pulse-Width MS 8 bits Preliminary  2016 Microchip Technology Inc. DS40001841B-page 280...
  • Page 281 CAPTURE MODE OPERATION BLOCK DIAGRAM Rev. 10-000158G 1/20/2016 RxyPPS CCPx CTS<2:0> TRIS Control Reserved Reserved CCPRxH CCPRxL Reserved set CCPxIF IOC_interrupt Prescaler 1,4,16 C3OUT_sync Edge Detect C2OUT_sync MODE <3:0> C1OUT_sync TMR1H TMR1L CCPx CCPxPPS Preliminary  2016 Microchip Technology Inc. DS40001841B-page 281...
  • Page 282 /4, Timer1 will not increment during Sleep. When the device wakes from Sleep, Timer1 will continue from its previous state. Capture mode will operate during Sleep when Timer1 is clocked by an external clock source. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 282...
  • Page 283 Compare mode will not function properly during Sleep, FIGURE 21-3: CCP PWM OUTPUT SIGNAL unless the timer is running. The device will wake on interrupt (if enabled). Period Pulse Width TMR2 = PR2 TMR2 = CCPRxH:CCPRxL TMR2 = 0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 283...
  • Page 284 1. 8-bit timer is concatenated with two bits generated by Fosc or two bits of the internal prescaler to create 10-bit time-base. 2. The alignment of the 10 bits from the CCPR register is determined by the CCPxFMT bit. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 284...
  • Page 285 PWM signal on the first output, then step 6 may be ignored. 21.5.3 TIMER2 TIMER RESOURCE The PWM standard mode makes use of the 8-bit Timer2 timer resources to specify the PWM period. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 285...
  • Page 286 10-bit time base. The system clock is used if the Timer2 prescaler is set to 1:1. When 10-bit time base matches CCPRxH:CCPRxL register pair, then the CCPx pin is cleared (see Figure 21-4). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 286...
  • Page 287 4.0 “Oscillator Module (with Fail-Safe Clock Monitor)” for additional details. 21.5.9 EFFECTS OF RESET Any Reset will force all ports to Input mode and the CCP registers to their Reset states. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 287...
  • Page 288 CPOL CSYNC MODE<4:0> T2CLKCON — — — — CS<3:0> T2RST — — — — RSEL<3:0> Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used by the CCP module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 288...
  • Page 289: Pulse-Width Modulation (Pwm 6/7)

    For a step-by-step procedure on how to set up this module for PWM operation, refer to Section Period 22.1.9 “Setup for PWM Operation using PWMx Pins”. Pulse Width TMR2 = PR2 TMR2 = PWMxDCH<7:0>:PWMxDCL<7:6> TMR2 = 0 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 289...
  • Page 290 The 8-bit timer TMR2 register is concatenated with the two Least Significant bits of 1/F , adjusted by the Timer2 prescaler to create the 10-bit time base. The system clock is used if the Timer2 prescaler is set to 1:1. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 290...
  • Page 291 Section 4.0 “Oscillator Module (with Fail-Safe Clock Monitor)” for additional details. 22.1.8 EFFECTS OF RESET Any Reset will force all ports to Input mode and the PWM registers to their Reset states. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 291...
  • Page 292 If it is not critical to start with a output, then step 6 may be ignored. complete PWM signal, then move Step 8 to replace Step 4. 2: For operation with other peripherals only, disable PWMx pin outputs. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 292...
  • Page 293 OUT: PWM Module Output Level When Bit is Read bit 4 POL: PWM Output Polarity Select bit 1 = PWM output is inverted 0 = PWM output is normal bit 3-0 Unimplemented: Read as ‘0’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 293...
  • Page 294 10 = CCP5 is based off Timer5 in Capture/Compare mode and Timer6 in PWM mode 01 = CCP5 is based off Timer3 in Capture/Compare mode and Timer4 in PWM mode 00 = CCP5 is based off Timer1 in Capture/Compare mode and Timer2 in PWM mode Preliminary  2016 Microchip Technology Inc. DS40001841B-page 294...
  • Page 295 7-6 DC<8:9>: PWM Duty Cycle Least Significant bits These bits are the LSbs of the PWM duty cycle. The MSbs are found in PWMxDCH Register. bit 5-0 Unimplemented: Read as ‘0’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 295...
  • Page 296 T2RSEL<3:0> PMD4 — PWM7MD PWM6MD CCP5MD CCP4MD CCP3MD CCP2MD CCP1MD Legend: - = Unimplemented locations, read as ‘0’, u = unchanged, x = unknown. Shaded cells are not used by the PWM. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 296...
  • Page 297: Zero-Cross Detection (Zcd) Module

    • A/C period measurement MAXPEAK • Accurate long term time measurement MINPEAK PEAK • Dimmer phase delayed drive • Low EMI cycle switching CPINV Preliminary  2016 Microchip Technology Inc. DS40001841B-page 297...
  • Page 298 PIC18(L)F67K40 FIGURE 23-2: SIMPLIFIED ZCD BLOCK DIAGRAM PULLUP Rev. 10-000194B 5/14/2014 optional PULLUP ZCDxIN SERIES External Zcpinv PULLDOWN voltage source optional ZCDx_output ZCDxOUT bit ZCDxPOL Interrupt ZCDxINTP ZCDIF ZCDxINTN flag Interrupt Preliminary  2016 Microchip Technology Inc. DS40001841B-page 298...
  • Page 299 If another edge CPINV SERIES -------------------------------------------- - PULLDOWN is detected while this flag is being cleared, the flag will   – CPINV still be set at the end of the sequence. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 299...
  • Page 300 Equation 23-3 because the pull-up value is independent from the peak voltage. EQUATION 23-5: SERIES R FOR V RANGE MAXPEAK MINPEAK --------------------------------------------------------- SERIES 4 – 10 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 300...
  • Page 301 0 = ZCDIF bit is unaffected by low-to-high ZCD_output transition bit 0 ZCDINTN: Zero-Cross Detect Negative-Going Edge Interrupt Enable bit 1 = ZCDIF bit is set on high-to-low ZCD_output transition 0 = ZCDIF bit is unaffected by high-to-low ZCD_output transition Preliminary  2016 Microchip Technology Inc. DS40001841B-page 301...
  • Page 302 XINST — DEBUG STVREN PPS1WAY BORV1 BORV0 BOREN1 BOREN0 LPBOREN — — — PWRTE MCLRE Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used by the ZCD module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 302...
  • Page 303: Complementary Waveform Generator (Cwg) Module

    In this case, the active drive must be terminated before the Fault condition causes damage. This is referred to as auto-shutdown and is covered in Section 24.10 “Auto-Shutdown”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 303...
  • Page 304 High-Z data in CWG Data Input Data CWG1B POLB LSAC<1:0> ‘1’ ‘0’ High-Z CWG1C POLC Auto-shutdown source (CWGxAS1 register) LSBD<1:0> ‘1’ SHUTDOWN = 0 ‘0’ High-Z CWG1D POLD SHUTDOWN FREEZE CWG Data Preliminary  2016 Microchip Technology Inc. DS40001841B-page 304...
  • Page 305 CWG1A. The unused outputs CWG1C and CWG1D drive copies of CWG1A and CWG1B, respectively, but with polarity controlled by the POLC and POLD bits of the CWG1CON1 register, respectively. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 305...
  • Page 306 CWG Data B CWG Data Input CWG1B POLB Data LSAC<1:0> ‘1’ ‘0’ High-Z CWG1C POLC Auto-shutdown source (CWGxAS1 register) LSBD<1:0> ‘1’ SHUTDOWN = 0 ‘0’ High-Z CWG1D POLD SHUTDOWN FREEZE CWG Data Preliminary  2016 Microchip Technology Inc. DS40001841B-page 306...
  • Page 307 A simplified block diagram for the Full-Bridge modes is shown in Figure 24-6. FIGURE 24-5: EXAMPLE OF FULL-BRIDGE APPLICATION Rev. 10-000263A 12/8/2015 Driver Driver CWG1A CWG1B LOAD CWG1C Driver Driver CWG1D Preliminary  2016 Microchip Technology Inc. DS40001841B-page 307...
  • Page 308 CWG Data CWG1B POLB LSAC<1:0> ‘1’ ‘0’ High-Z CWG Data C CWG1C POLC Auto-shutdown source (CWGxAS1 register) LSBD<1:0> ‘1’ SHUTDOWN = 0 ‘0’ High-Z CWG Data D CWG1D POLD SHUTDOWN FREEZE CWG Data Preliminary  2016 Microchip Technology Inc. DS40001841B-page 308...
  • Page 309 Period CWG1A Pulse Width CWG1B CWG1C CWG1D Note 1: A rising CWG data input creates a rising event on the modulated output. Output signals shown as active-high; all POLy bits are clear. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 309...
  • Page 310 EXAMPLE OF PWM DIRECTION CHANGE AT NEAR 100% DUTY CYCLE Forward Period Reverse Period CWG1A CWG1B Pulse Width CWG1C CWG1D Pulse Width External Switch C External Switch D Potential Shoot- T = T Through Current Preliminary  2016 Microchip Technology Inc. DS40001841B-page 310...
  • Page 311 Steering modes as described in Section 24.10 “Auto- Shutdown””. An auto-shutdown event will only affect pins that have STRx = 1. FIGURE 24-9: EXAMPLE OF SYNCHRONOUS STEERING (MODE<2:0> = 001) CWG1 clock Input source CWG1A CWG1B Preliminary  2016 Microchip Technology Inc. DS40001841B-page 311...
  • Page 312 This is required because all I/O pins are forced to high-impedance at Reset. The POLy bits (Register 24-2) allow the user to choose whether the output signals are active-high or active- low. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 312...
  • Page 313 ‘1’ ‘0’ High-Z CWG Data C Auto-shutdown source POLC (CWGxAS1 register) CWG1C DATC STRC LSBD<1:0> SHUTDOWN = 0 ‘1’ ‘0’ High-Z CWG Data D POLD CWG1D DATD SHUTDOWN STRD FREEZE CWG Data Preliminary  2016 Microchip Technology Inc. DS40001841B-page 313...
  • Page 314 (CWG1B or CWG1D, depending on the direction of the change) will experience a delay dictated by the dead-band counters. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 314...
  • Page 315 CWG1DBF is written. If EN = 1, then the buffer will be loaded at the rising edge following the first falling edge of the data input after the LD (Register 24- 1) is set. Refer to Figure 24-13 for an example. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 315...
  • Page 316 FIGURE 24-12: DEAD-BAND OPERATION, CWG1DBR = 0x01, CWG1DBF = 0x02 cwg_clock Input Source CWGxA CWGxB FIGURE 24-13: DEAD-BAND OPERATION, CWG1DBR = 0x03, CWG1DBF = 0x06, SOURCE SHORTER THAN DEAD BAND cwg_clock Input Source CWGxA CWGxB source shorter than dead band...
  • Page 317 DEAD BAND – DEAD BAND – EXAMPLE DBR<4:0> 0x0A 8 MHz CWG_CLOCK --------------- - 125 ns JITTER 8MHz 125 s 125 ns*10 DEAD BAND_MIN – 1.25 s 0.125s 1.37s DEAD BAND_MAX – Preliminary  2016 Microchip Technology Inc. DS40001841B-page 317...
  • Page 318 Note: The SHUTDOWN bit cannot be cleared in software if the auto-shutdown condition is still present. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 318...
  • Page 319 If auto-restart is to be used, set the REN bit and the SHUTDOWN bit will be cleared automatically. Other- wise, clear the SHUTDOWN bit in software to start the CWG. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 319...
  • Page 320 FIGURE 24-14: CWG SHUTDOWN BLOCK DIAGRAM Write ‘1’ to Rev. 10-000172D 1/19/2016 SHUTDOWN bit AS0E CWGxINPPS C1OUT_sync AS5E C2OUT_sync AS6E SHUTDOWN C3OUT_sync AS7E CWG_shutdown TMR2_postscaled FREEZE AS1E TMR4_postscaled CWG_data AS2E Write ‘0’ to TMR6_postscaled SHUTDOWN bit AS3E TMR8_postscaled AS4E FIGURE 24-15: SHUTDOWN FUNCTIONALITY, AUTO-RESTART DISABLED (REN = 0, LSAC = 01, LSBD = 01) Shutdown Event Ceases REN Cleared by Software CWG Input...
  • Page 321 FIGURE 24-16: SHUTDOWN FUNCTIONALITY, AUTO-RESTART ENABLED (REN = 1, LSAC = 01, LSBD = 01) Shutdown Event Ceases REN auto-cleared by hardware CWG Input Source Shutdown Source SHUTDOWN CWG1A Tri-State (No Pulse) CWG1C CWG1B Tri-State (No Pulse) CWG1D No Shutdown Output Resumes Shutdown...
  • Page 322 000 = CWG outputs operate in Asynchronous Steering mode Note 1: This bit can only be set after EN = 1; it cannot be set in the same cycle when EN is set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 322...
  • Page 323 1 = Signal output is inverted polarity 0 = Signal output is normal polarity bit 0 POLA: CWG1A Output Polarity bit 1 = Signal output is inverted polarity 0 = Signal output is normal polarity Preliminary  2016 Microchip Technology Inc. DS40001841B-page 323...
  • Page 324 CMP2 OUT 1001 CMP1 OUT 1000 PWM7 OUT 0111 PWM6 OUT 0110 CCP5 OUT 0101 CCP4 OUT 0100 CCP3 OUT 0011 CCP2 OUT 0010 CCP1 OUT 0001 Pin selected by CWG1PPS 0000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 324...
  • Page 325 0 = CWG1A output is assigned to value of OVRA bit Note 1: The bits in this register apply only when MODE<2:0> = 00x (Register 24-1, Steering modes). This bit is double-buffered when MODE<2:0> = 001. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 325...
  • Page 326 (Register 24-1), to place the outputs into the shutdown configuration. The outputs will remain in auto-shutdown state until the next rising edge of the CWG data input after this bit is cleared. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 326...
  • Page 327 0 = Auto-shutdown for TMR2_Postscaled is disabled bit 0 AS0E: CWG Auto-shutdown Source 0 (Pin selected by CWG1PPS) Enable bit 1 = Auto-shutdown for CWG1PPS Pin is enabled 0 = Auto-shutdown for CWG1PPS Pin is disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 327...
  • Page 328 11 1110 = 62-63 CWG clock periods 00 0010 = 2-3 CWG clock periods 00 0001 = 1-2 CWG clock periods 00 0000 = 0 CWG clock periods. Dead-band generation is bypassed. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 328...
  • Page 329 NVMIP — — — — CWG1IP PMD2 — — CWGMD — DSMMD SMT2MD SMT1MD TMR8MD Legend: – = unimplemented locations read as ‘ 0 ’. Shaded cells are not used by CWG. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 329...
  • Page 330: Signal Measurement Timer (Smt)

    • One 24-bit period match register • Multi-mode operation, including relative timing measurement • Interrupt on period match • Multiple clock, gate and signal sources • Interrupt on acquisition complete Ability to read current input values Preliminary  2016 Microchip Technology Inc. DS40001841B-page 330...
  • Page 331 These devices implement two SMT mod- ules. All references to SMTx apply to SMT1 and SMT2. FIGURE 25-2: SMTx SIGNAL AND WINDOW BLOCK DIAGRAM Rev. 10-000173C 1/20/2016 SMTxSIG SMT_signal SMT_window SMTxWIN Register Register SMTxSIG<4:0> SMTxWIN<4:0> Preliminary  2016 Microchip Technology Inc. DS40001841B-page 331...
  • Page 332 11 = Prescaler = 1:8 10 = Prescaler = 1:4 01 = Prescaler = 1:2 00 = Prescaler = 1:1 Note 1: Setting EN to ‘0‘ does not affect the register contents. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 332...
  • Page 333 0110 = Time of flight 0101 = Gated windowed measure 0100 = Windowed measure 0011 = High and low time measurement 0010 = Period and Duty-Cycle Acquisition 0001 = Gated Timer 0000 = Timer Preliminary  2016 Microchip Technology Inc. DS40001841B-page 333...
  • Page 334 1 = SMT window is open 0 = SMT window is closed bit 0 AS: SMT_signal Value Status bit 1 = SMT acquisition is in progress 0 = SMT acquisition is not in progress Preliminary  2016 Microchip Technology Inc. DS40001841B-page 334...
  • Page 335 CSEL<2:0>: SMT Clock Selection bits 111 = Clock reference out 110 = SOSC 101 = MFINTOSC/16 (31.25kHz) 100 = MFINTOSC (500 kHz) 011 = LFINTOSC 010 = HFINTOSC 001 = F 000 = F Preliminary  2016 Microchip Technology Inc. DS40001841B-page 335...
  • Page 336 TMR2_postscaler TMR2_postscaler 00101 TMR0_overflow TMR0_overflow 00100 SOSC SOSC 00011 MFINTOSC (31 kHz) MFINTOSC (31 kHz) 00010 LFINTOSC (31 kHz) LFINTOSC (31 kHz) 00001 Pin selected by SMT1WINPPS Pin selected by SMT2WINPPS 00000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 336...
  • Page 337 TMR7_postscaler 01000 TMR6_postscaler TMR6_postscaler 00111 TMR5_postscaler TMR5_postscaler 00110 TMR4_postscaler TMR4_postscaler 00101 TMR3_postscaler TMR3_postscaler 00100 TMR2_postscaler TMR2_postscaler 00011 TMR1_postscaler TMR1_postscaler 00010 TMR0_postscaler TMR0_postscaler 00001 Pin selected by SMT1SIGPPS Pin selected by SMT2SIGPPS 00000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 337...
  • Page 338 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 SMTxTMR<23:16>: Significant bits of the SMT Counter – Upper Byte Preliminary  2016 Microchip Technology Inc. DS40001841B-page 338...
  • Page 339 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 SMTxCPR<23:16>: Significant bits of the SMT Period Latch – Upper Byte Preliminary  2016 Microchip Technology Inc. DS40001841B-page 339...
  • Page 340 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 SMTxCPW<23:16>: Significant bits of the SMT PW Latch – Upper Byte Preliminary  2016 Microchip Technology Inc. DS40001841B-page 340...
  • Page 341 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 SMTxPR<23:16>: Significant bits of the SMT Timer Value for Period Match – Upper Byte Preliminary  2016 Microchip Technology Inc. DS40001841B-page 341...
  • Page 342 SMT2WIN — — — WSEL<4:0> Legend: x = unknown, u = unchanged, — = unimplemented read as ‘0’, q = value depends on condition. Shaded cells are not used for SMTx module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 342...
  • Page 343 They are used to latch in the value of the SMTxTMR when triggered by various signals, which are determined by the mode the SMT is currently in. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 343...
  • Page 344 Section 25.7.8 “Capture Mode” 0111 Counter Section 25.7.9 “Counter Mode” 1000 Gated Counter Section 25.7.10 “Gated Counter Mode” 1001 Windowed Counter Section 25.7.11 “Windowed Counter Mode” 1010 Reserved — — 1011 - 1111 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 344...
  • Page 345 FIGURE 25-3: TIMER MODE TIMING DIAGRAM Rev. 10-000 174A 12/19/201 3 SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxPR SMTxTMR 9 10 11 0 SMTxIF...
  • Page 346 SMTxCPW register will update to the current value of the SMTxTMR. Example waveforms for both repeated and single acquisitions are provided in Figure 25-4 Figure 25-5. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 346...
  • Page 347 FIGURE 25-4: GATED TIMER MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000 176A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxPR 0xFFFFFF SMTxTMR SMTxCPW SMTxPWAIF...
  • Page 348 FIGURE 25-5: GATED TIMER MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000 175A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxPR 0xFFFFFF SMTxTMR SMTxCPW SMTxPWAIF...
  • Page 349 SMTxTMR resetting to 0x0001. In addition, the SMTxGO bit is reset on a rising edge when the SMT is in Single Acquisition mode. See Figure 25-6 Figure 25-7. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 349...
  • Page 350 FIGURE 25-6: PERIOD AND DUTY-CYCLE REPEAT ACQUISITION MODE TIMING DIAGRAM Rev. 10-000 177A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 11 1 SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 351 FIGURE 25-7: PERIOD AND DUTY-CYCLE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000 178A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 11 SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 352 Upon observing another rising edge, it updates the SMTxCPR register with its current value and once again resets the SMTxTMR value and begins incrementing again. See Figure 25-8 Figure 25-9. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 352...
  • Page 353 FIGURE 25-8: HIGH AND LOW MEASURE MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000 180A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 354 FIGURE 25-9: HIGH AND LOW MEASURE MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000 179A 12/19/201 3 SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 355 SMTWINx input and updates the SMTxCPR register with the value of the timer and resets the timer on a second rising edge. See Figure 25-10 Figure 25-11. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 355...
  • Page 356 FIGURE 25-10: WINDOWED MEASURE MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000 182A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 SMTxCPR SMTxPRAIF...
  • Page 357 FIGURE 25-11: WINDOWED MEASURE MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000 181A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 SMTxCPR SMTxPRAIF...
  • Page 358 SMTx_signal input is high, updating the SMTxCPR register and resetting the timer on every rising edge of the SMTWINx input after the first. See Figure 25-12 Figure 25-13. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 358...
  • Page 359 FIGURE 25-12: GATED WINDOWED MEASURE MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000 184A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPR SMTxPRAIF...
  • Page 360 FIGURE 25-13: GATED WINDOWED MEASURE MODE SINGLE ACQUISITION TIMING DIAGRAMS Rev. 10-000 183A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPR SMTxPRAIF...
  • Page 361 In the event of two SMTWINx rising edges without an SMTx_signal rising edge, it will update the SMTxCPW register with the current value of the timer and reset the timer value. See Figure 25-14 Figure 25-15. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 361...
  • Page 362 FIGURE 25-14: TIME OF FLIGHT MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000186A 4/22/2016 SMTxWIN SMTxWIN_sync SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 11 12 13 SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 363 FIGURE 25-15: TIME OF FLIGHT MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000185A 4/26/2016 SMTxWIN SMTxWIN_sync SMTx_signal SMTx_signalsync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 364 CPW register on each falling edge of the SMTWINx. The timer is not reset by any hardware conditions in this mode and must be reset by software, if desired. See Figure 25-16 Figure 25-17. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 364...
  • Page 365 FIGURE 25-16: CAPTURE MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000 188A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR 9 10 11 12 13 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 SMTxCPW SMTxCPR SMTxPWAIF...
  • Page 366 FIGURE 25-17: CAPTURE MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000 187A 12/19/201 3 SMTxWIN SMTxWIN_sync SMTx Clock SMTxEN SMTxGO SMTxGO_sync SMTxTMR SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF...
  • Page 367 SMT clock and uses the SMTx_signal as a time source. The SMTxCPW register will be updated with the current SMTxTMR value on the falling edge of the SMTxWIN input. See Figure 25-18. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 367...
  • Page 368 FIGURE 25-18: COUNTER MODE TIMING DIAGRAM Rev. 10-000189A 4/12/2016 SMTxWIN SMTx_signal SMTxEN SMTxGO SMTxTMR 12 13 14 15 16 17 18 19 20 21 22 23 25 26 SMTxCPW...
  • Page 369 SMTxWIN input. It begins incrementing the timer upon seeing a rising edge of the SMTxWIN input and updates the SMTxCPW register upon a fall- ing edge on the SMTxWIN input. See Figure 25-19 Figure 25-20. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 369...
  • Page 370 FIGURE 25-19: GATED COUNTER MODE REPEAT ACQUISITION TIMING DIAGRAM Rev. 10-000190A 12/18/2013 SMTxWIN SMTx_signal SMTxEN SMTxGO SMTxTMR 9 10 SMTxCPW SMTxPWAIF FIGURE 25-20: GATED COUNTER MODE SINGLE ACQUISITION TIMING DIAGRAM Rev. 10-000191A 12/18/2013 SMTxWIN SMTx_signal SMTxEN SMTxGO SMTxTMR SMTxCPW SMTxPWAIF...
  • Page 371 SMTxWIN input, updates the SMTxCPW register on a falling edge of the SMTxWIN input, and updates the SMTxCPR register on each rising edge of the SMTxWIN input beyond the first. See Figure 25-21 Figure 25-22. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 371...
  • Page 372 FIGURE 25-21: WINDOWED COUNTER MODE REPEAT ACQUISITION TIMING DIAGRAM SMTxWIN SMTx_signal SMTxEN SMTxGO SMTxTMR 9 10 11 12 13 14 15 16 SMTxCPW SMTxCPR SMTxPWAIF SMTxPRAIF FIGURE 25-22: WINDOWED COUNTER MODE SINGLE ACQUISITION TIMING DIAGRAM SMTxWIN SMTx_signal SMTxEN SMTxGO SMTxTMR 9 10 11 12 13 14 15 16 SMTxCPW SMTxCPR...
  • Page 373 Section 25.2.2 “Period Match interrupt”, the SMT will also interrupt upon SMTxTMR, matching SMTxPR with its period match limit functionality described Section 25.4 “Halt Operation”. The period match interrupt is controlled by SMTxIF and SMTxIE. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 373...
  • Page 374: Data Signal Modulator (Dsm) Module

    • Peripheral Module Disable, which provides the ability to place the DSM module in the lowest power consumption mode Figure 26-1 shows a Simplified Block Diagram of the Data Signal Modulator peripheral. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 374...
  • Page 375 SIMPLIFIED BLOCK DIAGRAM OF THE DATA SIGNAL MODULATOR MDCHS<3:0> Rev. 10-000248F 1/19/2016 Data Signal Modulator 0000 CARH MDCARH Register MDCHPOL 1111 SYNC MDSRCS<4:0> 00000 MDCHSYNC RxyPPS MDSRC Register MDOPOL 11111 MDCLS<3:0> SYNC 0000 CARL MDCARL MDCLSYNC Register MDCLPOL 1111 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 375...
  • Page 376 The modulated output frequency can be greater and asynchronous from the clock that updates this register bit, the bit value may not be valid for higher speed modulator or carrier signals. MDBIT must be selected as the modulation source in the MDSRC register for this operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 376...
  • Page 377 0 = Modulator output is not synchronized to the low time carrier signal Note 1:Narrowed carrier pulse widths or spurs may occur in the signal stream if the carrier is not synchronized. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 377...
  • Page 378 CCP1 OUT 0100 0100 CLKREF output CLKREF output 0011 0011 HFINTOSC HFINTOSC 0010 0010 FOSC (system clock) FOSC (system clock) 0001 0001 Pin selected by MDCARHPPS Pin selected by MDCARHPPS 0000 0000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 378...
  • Page 379 01010 CMP1 OUT 01001 PWM7 OUT 01000 PWM6 OUT 00111 CCP5 OUT 00110 CCP4 OUT 00101 CCP3 OUT 00100 CCP2 OUT 00011 CCP1 OUT 00010 MDBIT 00001 Pin selected by MDSRCPPS 00000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 379...
  • Page 380 — — RxyPPS<5:0> PMD2 — — CWGMD — DSMMD SMT2MD SMT1MD TMR8MD Legend: — = unimplemented, read as ‘ 0 ’. Shaded cells are not used in the Data Signal Modulator mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 380...
  • Page 381 • Comparator C1/C2/C3 Output • EUSART1/2/3/4/5 RX Signal • EUSART1/2/3/4/5 TX Signal • MSSP1/2 SDO Signal (SPI Mode Only) The modulator signal is selected by configuring the MDSRCS<4:0> bits in the MDSRC register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 381...
  • Page 382 Active Carrier State FIGURE 26-4: Carrier High Synchronization (MDSHSYNC = 1, MDCLSYNC = 0) carrier_high carrier_low modulator MDCHSYNC = 1 MDCLSYNC = 0 Active Carrier carrier_high carrier_low carrier_high carrier_low both both State Preliminary  2016 Microchip Technology Inc. DS40001841B-page 382...
  • Page 383 State FIGURE 26-6: Full Synchronization (MDSHSYNC = 1, MDCLSYNC = 1) carrier_high carrier_low modulator Falling edges used to sync MDCHSYNC = 1 MDCLSYNC = 1 Active Carrier carrier_high carrier_high carrier_low State Preliminary  2016 Microchip Technology Inc. DS40001841B-page 383...
  • Page 384 Inverting the modulated output the DSM module completely. When enabled again all signal is enabled by setting the MDOPOL bit of the the registers of the DSM module default to POR status. MDCON0 register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 384...
  • Page 385: Master Synchronous Serial Port (Mssp1)Module

    • Start and Stop interrupts • Interrupt masking • Clock stretching • Bus collision detection • General call address matching • Address masking • Address Hold and Data Hold modes • Selectable SDA hold times Preliminary  2016 Microchip Technology Inc. DS40001841B-page 385...
  • Page 386 The master selects only one slave at a time. Most slave devices have tri-state outputs so their output signal appears disconnected from the bus when they are not selected. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 386...
  • Page 387 When SSPSR receives a complete byte, it is transferred to SSPxBUF and the SSPxIF interrupt is set. During transmission, the SSPxBUF is not buffered. A write to SSPxBUF will write to both SSPxBUF and SSPSR. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 387...
  • Page 388 BF: Buffer Full Status bit (Receive mode only) 1 = Receive is complete, SSPxBUF is full 0 = Receive is not complete, SSPxBUF is empty Note 1: Polarity of clock state is set by the CKP bit (SSPxCON1<4>). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 388...
  • Page 389 When enabled, these pins must be properly configured as inputs or outputs. SSPxADD = 0 is not supported. Bit combinations not specifically listed here are either reserved or implemented in I C mode only. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 389...
  • Page 390 For daisy-chained SPI operation; allows the user to ignore all but the last received byte. SSPOV is still set when a new byte is received and BF = 1, but hardware continues to write the most recent byte to SSPxBUF. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 390...
  • Page 391 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared Master mode: SPI mode bit 7-0 Baud Rate Clock Divider bits SCK/SCL pin clock period = ((SSPxADD<7:0> + 1) *4)/F Preliminary  2016 Microchip Technology Inc. DS40001841B-page 391...
  • Page 392 Every slave device connected to the bus that has not been selected through its slave select line must disre- gard the clock and transmission signals and must not transmit out any data of its own. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 392...
  • Page 393 SPI Slave SSPM<3:0> = 010x = 1010 Serial Input Buffer Serial Input Buffer (BUF) (SSPxBUF) Shift Register Shift Register (SSPSR) (SSPSR) Serial Clock Slave Select General I/O (optional) Processor 2 Processor 1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 393...
  • Page 394 SCK pin is also the clock signal input to the peripheral. The pin selected for out- put with the RxyPPS register must also be selected as the peripheral input with the SSPxCLKPPS register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 394...
  • Page 395 BOEN bit of the SSPxCON3 register will enable writes wake-up from Sleep. to the SSPxBUF register, even if the previous byte has not been read. This allows the software to ignore data that may not apply to it. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 395...
  • Page 396 ‘0’. This can be done by either forcing the SS pin to (SSPxCON1<3:0> = 0100). a high level or clearing the SSPEN bit. FIGURE 27-5: SPI DAISY-CHAIN CONNECTION SPI Master SPI Slave General I/O SPI Slave SPI Slave Preliminary  2016 Microchip Technology Inc. DS40001841B-page 396...
  • Page 397 SSPxBUF to SSPSR bit 6 bit 6 bit 7 bit 0 bit 7 bit 0 bit 7 bit 7 Input Sample SSPxIF Interrupt Flag SSPSR to SSPxBUF Preliminary  2016 Microchip Technology Inc. DS40001841B-page 397...
  • Page 398 6 bit 3 bit 2 bit 7 bit 5 bit 4 bit 1 bit 0 bit 0 bit 7 Input Sample SSPxIF Interrupt Flag SSPSR to SSPxBUF Write Collision detection active Preliminary  2016 Microchip Technology Inc. DS40001841B-page 398...
  • Page 399 — SSPDATPPS<5:0> SSPxSSPPS — — SSPSSPPS<5:0> SSPxSTAT Legend: — = Unimplemented location, read as ‘ 0 ’. Shaded cells are not used by the MSSP in SPI mode. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 399...
  • Page 400 XMIT/RCV Bus Collision Address Match detect Note 1: SDA pin selections must be the same for input and output 2: SCL pin selections must be the same for input and output Preliminary  2016 Microchip Technology Inc. DS40001841B-page 400...
  • Page 401 SDA line low to indicate to the transmit- master intends to transmit to or receive data from the ter that the slave device has received the transmitted slave device. data and is ready to receive more. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 401...
  • Page 402 • Single message where a master reads data from a slave. • Combined message where a master initiates a minimum of two writes, or two reads, or a combination of writes and reads, to one or more slaves. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 402...
  • Page 403 SSPxBUF is not double-buffered. A continue into the data stage. write to SSPxBUF will write to both SSPxBUF and Arbitration usually occurs very rarely, but it is a SSPSR. necessary process for proper multi-master support. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 403...
  • Page 404 Start bit, Stop bit or not ACK bit. ORing this bit with SEN, RSEN, PEN, RCEN or ACKEN will indicate if the MSSPx is in Active mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 404...
  • Page 405 When SSPM<3:0> = 1001, any reads or writes to the SSPxADD SFR address actually accesses the SSPxMSK register. This mode is only available when 7-Bit Address Masking mode is selected (MSSPMSK Configuration bit is ‘1’). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 405...
  • Page 406 The value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive. If the I C module is active, these bits may not be set (no spooling) and the SSPxBUF may not be written (or writes to the SSPxBUF are disabled). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 406...
  • Page 407 = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 BUF<7:0>: MSSP Buffer bits Preliminary  2016 Microchip Technology Inc. DS40001841B-page 407...
  • Page 408 1 = The received address bit 0 is compared to SSPxADD0 to detect I C address match 0 = The received address bit 0 is not used to detect I C address match C Slave mode, 7-bit address, the bit is ignored. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 408...
  • Page 409 SSPxCON3 register. Hold time is the time SDA is held valid after the falling edge of SCL. Setting the SDAHT bit selects a longer 300 ns minimum hold time and may help on buses with large capacitance. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 409...
  • Page 410 C START AND STOP CONDITIONS Change of Change of Data Allowed Data Allowed Start Stop Condition Condition FIGURE 27-13: C RESTART CONDITION Change of Change of Data Allowed Data Allowed Restart Condition Preliminary  2016 Microchip Technology Inc. DS40001841B-page 410...
  • Page 411 27.9.6.2 “10-bit Addressing Mode” for more detail. software that anything happened. The SSP Mask register affects the address matching process. See Section 27.9.9 “SSP Mask Register” for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 411...
  • Page 412 ACK = 1, or the master sending a Stop condition. If a Stop is sent and Interrupt on Stop Detect is disabled, the slave will only know by polling the P bit of the SSTSTAT register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 412...
  • Page 413 FIGURE 27-14: C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 0, AHEN = 0, DHEN = 0) Bus Master sends Stop condition From Slave to Master Receiving Address Receiving Data Receiving Data ACK = 1 SSPxIF SSPxIF set on 9th Cleared by software Cleared by software falling edge of First byte...
  • Page 414 FIGURE 27-15: C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 1, AHEN = 0, DHEN = 0) Bus Master sends Stop condition Receive Address Receive Data Receive Data R/W=0 Clock is held low until CKP is set to ‘1’ SSPxIF SSPxIF set on 9th Cleared by software Cleared by software falling edge of SCL...
  • Page 415 FIGURE 27-16: C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 0, AHEN = 1, DHEN = 1) Master sends Master Releases SDA Stop condition to slave for ACK sequence Receiving Address Receiving Data Received Data ACK=1 A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 SSPxIF...
  • Page 416 FIGURE 27-17: C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 1, AHEN = 1, DHEN = 1) Master sends Stop condition Master releases R/W = 0 SDA to slave for ACK sequence Receiving Address Receive Data Receive Data A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 3 4 5...
  • Page 417 15. The master sends a Restart condition or a Stop. addressed again. User software can use the BCLxIF bit 16. The slave is no longer addressed. to handle a slave bus collision. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 417...
  • Page 418 FIGURE 27-18: C SLAVE, 7-BIT ADDRESS, TRANSMISSION (AHEN = 0) Master sends Stop condition Receiving Address Automatic Transmitting Data Automatic Transmitting Data R/W = 1 A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 SSPxIF Cleared by software...
  • Page 419 Stop and end the communication. Note: Master must send a not ACK on the last byte to ensure that the slave releases the SCL line to receive a Stop. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 419...
  • Page 420 FIGURE 27-19: C SLAVE, 7-BIT ADDRESS, TRANSMISSION (AHEN = 1) Master sends Master releases SDA Stop condition to slave for ACK sequence Receiving Address Automatic Transmitting Data Automatic Transmitting Data R/W = 1 A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 SSPxIF...
  • Page 421 16. Slave reads the received byte from SSPxBUF clearing BF. 17. If SEN is set the slave sets CKP to release the SCL. 18. Steps 13-17 repeat for each received byte. 19. Master sends Stop to end the transmission. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 421...
  • Page 422 FIGURE 27-20: C SLAVE, 10-BIT ADDRESS, RECEPTION (SEN = 1, AHEN = 0, DHEN = 0) Master sends Stop condition Receive Data Receive Second Address Byte Receive Data Receive First Address Byte 0 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 SCL is held low...
  • Page 423 FIGURE 27-21: C SLAVE, 10-BIT ADDRESS, RECEPTION (SEN = 0, AHEN = 1, DHEN = 0) Receive First Address Byte Receive Second Address Byte Receive Data Receive Data R/W = 0 D6 D5 SSPxIF Set by hardware Cleared by software Cleared by software on 9th falling edge SSPxBUF can be...
  • Page 424 FIGURE 27-22: C SLAVE, 10-BIT ADDRESS, TRANSMISSION (SEN = 0, AHEN = 0, DHEN = 0) Master sends Master sends Stop condition Master sends Restart event not ACK Receiving Address Receiving Second Address Byte Receive First Address Byte Transmitting Data Byte R/W = 0 ACK = 1 1 1 1 1 0 A9 A8...
  • Page 425 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 – DX ‚ Master device asserts clock Master device releases clock SSPxCON1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 425...
  • Page 426 SLAVE MODE GENERAL CALL ADDRESS SEQUENCE Address is compared to General Call Address after ACK, set interrupt Receiving Data R/W = General Call Address SSPxIF BF (SSPxSTAT<0>) Cleared by software SSPxBUF is read GCEN (SSPxCON2<7>) ’1’ Preliminary  2016 Microchip Technology Inc. DS40001841B-page 426...
  • Page 427 BRG rollover count in the event that the generated when the SEN/PEN bit is clock is held low by an external device (Figure 27-25). cleared and the generation is complete. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 427...
  • Page 428 Write to SEN bit occurs here At completion of Start bit, SDA = 1 , hardware clears SEN bit SCL = 1 and sets SSPxIF bit Write to SSPxBUF occurs here 2nd bit 1st bit Preliminary  2016 Microchip Technology Inc. DS40001841B-page 428...
  • Page 429 At completion of Start bit, SDA = 1, SDA = 1, hardware clears the RSEN bit SCL = 1 SCL (no change) and sets SSPxIF 1st bit Write to SSPxBUF occurs here Repeated Start Preliminary  2016 Microchip Technology Inc. DS40001841B-page 429...
  • Page 430 ACKSTAT bit of the SSPxCON2 register. The MSSP module generates an interrupt at the end of the ninth clock cycle by setting the SSPxIF bit. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 430...
  • Page 431 FIGURE 27-28: C MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS) ACKSTAT in Write SSPxCON2<0> SEN = 1 Start condition begins SSPxCON2 = 1 From slave, clear ACKSTAT bit SSPxCON2<6> SEN = 0 Transmitting Data or Second Half R/W = 0 Transmit Address to Slave of 10-bit Address ACK = 0...
  • Page 432 If the user writes the SSPxBUF when a receive is already in progress (i.e., SSPSR is still shifting in a data byte), the WCOL bit is set and the contents of the buffer are unchanged (the write does not occur). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 432...
  • Page 433 FIGURE 27-29: C MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS) Write to SSPxCON2<4> to start Acknowledge sequence SDA = ACKDT (SSPxCON2<5>) = 0 Write to SSPxCON2<0>(SEN = 1), begin Start condition Set ACKEN, start Acknowledge sequence ACK from Master Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1 by programming SSPxCON2<3>...
  • Page 434 SSPxIF bit is set 9th clock SCL brought high after T SDA asserted low before rising edge of clock to setup Stop condition Note: T = one Baud Rate Generator period. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 434...
  • Page 435 SDA line pulled low data does not match what is driven while SCL = 0 by another source by the master. Bus collision has occurred. SDA released by master Set bus collision interrupt (BCLxIF) BCLxIF Preliminary  2016 Microchip Technology Inc. DS40001841B-page 435...
  • Page 436 Start condition. Set BCLxIF. S bit and SSPxIF set because BCLxIF SDA = 0 , SCL = 1 . SSPxIF and BCLxIF are cleared by software SSPxIF SSPxIF and BCLxIF are cleared by software Preliminary  2016 Microchip Technology Inc. DS40001841B-page 436...
  • Page 437 Set SEN, enable Start sequence if SDA = 1 , SCL = 1 ’0’ BCLxIF SSPxIF SDA = 0 , SCL = 1 , Interrupts cleared by software set SSPxIF Preliminary  2016 Microchip Technology Inc. DS40001841B-page 437...
  • Page 438 ’0’ ’0’ SSPxIF FIGURE 27-37: BUS COLLISION DURING REPEATED START CONDITION (CASE 2) SCL goes low before SDA, BCLxIF set BCLxIF. Release SDA and SCL. Interrupt cleared by software RSEN ’0’ SSPxIF Preliminary  2016 Microchip Technology Inc. DS40001841B-page 438...
  • Page 439 SDA asserted low BCLxIF ’0’ ’0’ SSPxIF FIGURE 27-39: BUS COLLISION DURING A STOP CONDITION (CASE 2) SCL goes low before SDA goes high, Assert SDA set BCLxIF BCLxIF ’0’ ’0’ SSPxIF Preliminary  2016 Microchip Technology Inc. DS40001841B-page 439...
  • Page 440 100 kHz 4 MHz 1 MHz 100 kHz Note: Refer to the I/O port electrical specifications in Table 37-8: Internal Oscillator Parameters, to ensure the sys- tem is designed to support I requirements. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 440...
  • Page 441 — SSPDATPPS<5:0> SSPxMSK MSK<7:0> SSPxSTAT Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used by the MSSP module in I C mode. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 441...
  • Page 442: Enhanced Universal Synchronous Asynchronous Receiver Transmitter (Eusart)

    SPxBRGL BRGH X 1 1 0 BRG16 X 1 0 1 RxyPPS SYNC Note 1: In Synchronous mode, the DT output and RX input PPS CSRC selections should enable the same pin. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 442...
  • Page 443 DT output in Synchronous mode, it is the user’s responsibility to select the same pin for both of these functions when operating in Synchronous mode. The EUSART control logic will control the data direction drivers automatically. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 443...
  • Page 444 0 = TSR full bit 0 TX9D: Ninth bit of Transmit Data Can be address/data bit or a parity bit. Note 1: SREN/CREN bits of RCxSTA (Register 28-2) override TXEN in Sync mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 444...
  • Page 445 1 = Overrun error (can be cleared by clearing bit CREN) 0 = No overrun error bit 0 RX9D: Ninth bit of Received Data This can be address/data bit or a parity bit and must be calculated by user firmware. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 445...
  • Page 446 0 ABDEN: Auto-Baud Detect Enable bit Asynchronous mode: 1 = Auto-Baud Detect mode is enabled (clears when auto-baud is complete) 0 = Auto-Baud Detect mode is disabled Synchronous mode: Don’t care Preliminary  2016 Microchip Technology Inc. DS40001841B-page 446...
  • Page 447 If the TXx/CKx pin is shared with an analog peripheral, the analog I/O function must be disabled by clearing the corresponding ANSEL bit. Note: The TXxIF Transmitter Interrupt flag is set when the TXEN enable bit is set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 447...
  • Page 448 TXx/CKx Start bit bit 0 bit 1 bit 7/8 Stop bit Word 1 TXxIF bit (Transmit Buffer Reg. Empty Flag) Word 1 TRMT bit Transmit Shift Reg. (Transmit Shift Reg. Empty Flag) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 448...
  • Page 449 EUSARTx Transmit Register 447* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for asynchronous transmission. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 449...
  • Page 450 • GIE, Global Interrupt Enable bit of the INTCON register The RCxIF interrupt flag bit will be set when there is an unread character in the FIFO, regardless of the state of interrupt enable bits. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 450...
  • Page 451 Most Significant data bit of the top unread character in the receive FIFO. When reading 9-bit data from the receive FIFO buffer, the RX9D data bit must be read before reading the eight Least Significant bits from the RCxREG. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 451...
  • Page 452 OERR bit CREN Note: This timing diagram shows three words appearing on the RXx input. The RCxREG (receive buffer) is read after the third word, causing the OERR (overrun) bit to be set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 452...
  • Page 453 EUSARTx Baud Rate Generator, Low Byte 455* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for asynchronous reception. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 453...
  • Page 454 Auto-Baud Detect feature (see Section 28.4.1 “Auto-Baud Detect”). There may not be fine enough resolution when adjusting the Baud Rate Generator to compensate for a gradual change in the peripheral clock frequency. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 454...
  • Page 455 To avoid this problem, check the status of the RCIDL bit to make sure that the receive operation is idle before changing the system clock. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 455...
  • Page 456 SPxBRGL 455* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘0’. Shaded cells are not used for the Baud Rate Generator. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 456...
  • Page 457 0.00 10378 -0.37 10473 0.53 19.2k 19.23k 0.16 19.23k 0.16 19.20k 0.00 19.20k 0.00 57.6k 57.14k -0.79 56.82k -1.36 57.60k 0.00 57.60k 0.00 115.2k 117.64k 2.12 113.64k -1.36 115.2k 0.00 115.2k 0.00 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 457...
  • Page 458 19.23k 0.16 19.23k 0.16 19.20k 0.00 — — — 57.6k 55556 -3.55 — — — 57.60k 0.00 — — — 115.2k — — — — — — 115.2k 0.00 — — — Preliminary  2016 Microchip Technology Inc. DS40001841B-page 458...
  • Page 459 0.53 10417 0.00 19.2k 19.23k 0.16 19.23k 0.16 19.20k 0.00 19.23k 0.16 57.6k 57.14k -0.79 58.82k 2.12 57.60k 0.00 — — — 115.2k 117.6k 2.12 111.1k -3.55 115.2k 0.00 — — — Preliminary  2016 Microchip Technology Inc. DS40001841B-page 459...
  • Page 460 BRG Clock Auto Cleared Set by User ABDEN bit RCIDL RCxIF bit (Interrupt) Read RCxREG SPxBRGL SPxBRGH Note 1: The ABD sequence requires the EUSART module to be configured in Asynchronous mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 460...
  • Page 461 RX line at the end of the Break. This signals to the user that the Break event is over. At this point, the EUSART module is in Idle mode waiting to receive the next character. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 461...
  • Page 462 If the wake-up event requires long oscillator warm-up time, the automatic clearing of the WUE bit can occur while the stposc signal is still active. This sequence should not depend on the presence of Q clocks. The EUSART remains in Idle while the WUE bit is set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 462...
  • Page 463 Start bit bit 0 bit 1 bit 11 Stop bit Break TXxIF bit (Transmit Interrupt Flag) TRMT bit (Transmit Shift Empty Flag) SENDB Sampled Here Auto Cleared SENDB (send Break control bit) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 463...
  • Page 464 Only as many clock cycles are should be loaded in the TX9D bit. generated as there are data bits. Start transmission by loading data to the TXxREG register. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 464...
  • Page 465 Sync Master mode, SPxBRGL = 0, continuous transmission of two 8-bit words. FIGURE 28-11: SYNCHRONOUS TRANSMISSION (THROUGH TXEN) RXx/DTx pin bit 0 bit 2 bit 1 bit 6 bit 7 TXx/CKx pin Write to TXxREG reg TXxIF bit TRMT bit TXEN bit Preliminary  2016 Microchip Technology Inc. DS40001841B-page 465...
  • Page 466 447* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for synchronous master transmission. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 466...
  • Page 467 10. Read the 8-bit received data by reading the RCxREG register. 11. If an overrun error occurs, clear the error by either clearing the CREN bit of the RCxSTA register or by clearing the SPEN bit which resets the EUSART. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 467...
  • Page 468 455* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for synchronous master reception. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 468...
  • Page 469 If the PEIE and TXxIE bits are set, the interrupt will wake the device from Sleep and execute the next instruction. If the GIE bit is also set, the program will call the Interrupt Service Routine. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 469...
  • Page 470 447* TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for synchronous slave transmission. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 470...
  • Page 471 RXPPS<5:0> TXxSTA CSRC TXEN SYNC SENDB BRGH TRMT TX9D Legend: — = unimplemented location, read as ‘ 0 ’. Shaded cells are not used for synchronous slave reception. Page provides register information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 471...
  • Page 472 Upon waking from Sleep, the instruction following the SLEEP instruction will be executed. If the Global Interrupt Enable (GIE) bit of the INTCON register is also set, then the Interrupt Service Routine at address 004h will be called. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 472...
  • Page 473: Fixed Voltage Reference (Fvr)

    FIGURE 29-1: VOLTAGE REFERENCE BLOCK DIAGRAM Rev. 10-000 053C 12/9/201 3 ADFVR<1:0> FVR_buffer1 (To ADC Module) CDAFVR<1:0> FVR_buffer2 (To Comparators and DAC) FVREN FVRRDY Note 1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 473...
  • Page 474 — CxNCH<2:0> CMxPCH — — — — — CxPCH<2:0> DAC1CON1 — — — DAC1R<4:0> Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used with the Fixed Voltage Reference. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 474...
  • Page 475: Temperature Indicator Module

    FVRCON register. The low range generates a lower voltage drop and thus, a lower bias voltage is needed to operate the circuit. The low range is provided for low voltage operation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 475...
  • Page 476 Bit 2 Bit 1 Bit 0 on page FVRCON FVREN FVRRDY TSEN TSRNG CDFVR<1:0> ADFVR<1:0> Legend: — = Unimplemented location, read as ‘0’. Shaded cells are unused by the temperature indicator module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 476...
  • Page 477: 5-Bit Digital-To-Analog Converter (Dac) Module

    DIGITAL-TO-ANALOG CONVERTER BLOCK DIAGRAM Rev. 10-000026F 8/7/2015 Reserved SOURCE DACR<4:0> FVR Buffer DACPSS DACx_output To Peripherals Steps DACEN DACxOUT1 DACOE1 DACxOUT2 DACOE2 SOURCE DACNSS Note 1: The unbuffered DACx_output is provided on the DACxOUT pin(s). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 477...
  • Page 478 IF DACEN = 1     DACR 4:0    DACx_output – -----------------------------   Note: See the DAC1CON0 register for the available V + and V - selections. SOURCE SOURCE Preliminary  2016 Microchip Technology Inc. DS40001841B-page 478...
  • Page 479 11 = Reserved 10 = FVR buffer 01 = V 00 = AV bit 1 Unimplemented: Read as ‘0’ bit 0 NSS: DAC Negative Source Select bit 1 = V 0 = AV Preliminary  2016 Microchip Technology Inc. DS40001841B-page 479...
  • Page 480 — PSS<1:0> — DAC1CON1 — — — DAC1R<4:0> FVRCON FVREN FVRRDY TSEN TSRNG CDAFVR<1:0> ADFVR<1:0> Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used with the DAC module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 480...
  • Page 481: Analog-To-Digital Converter With Computation (Adc2) Module

    The ADC can generate an interrupt upon completion of a conversion and upon threshold comparison. These interrupts can be used to wake-up the device from Sleep. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 481...
  • Page 482 FVR_buffer1 Sample Circuit CHS<4:0> ADFM set bit ADIF complete 10-bit Result Write to bit GO/DONE GO/DONE start ADRESH ADRESL Enable Trigger Select TRIGSEL<3:0> ADON . . . Trigger Sources AUTO CONVERSION TRIGGER Preliminary  2016 Microchip Technology Inc. DS40001841B-page 482...
  • Page 483 ADCON0. What this can mean is when the ADCS bit of ADCON0 is set to ‘1’ (ADC runs on FRC), there may be unexpected delays in operation when setting ADC control bits. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 483...
  • Page 484 If ADPRE If ADACQ If ADPRE = 0 If ADACQ = 0 On the following cycle: ADRESH:ADRESL is loaded, (Traditional Operation Start) GO bit is cleared, Set GO bit ADIF bit is set, Preliminary  2016 Microchip Technology Inc. DS40001841B-page 484...
  • Page 485 0 10-bit ADC Result Unimplemented: Read as ‘ 0 ’ (ADFM = 1 ) bit 7 bit 0 bit 7 bit 0 Unimplemented: Read as ‘ 0 ’ 10-bit ADC Result Preliminary  2016 Microchip Technology Inc. DS40001841B-page 485...
  • Page 486 Incomplete bits will match the last bit converted. In this case, filter and/or threshold occur. Note: A device Reset forces all registers to their Reset state. Thus, the ADC module is turned off and any pending conversion is terminated. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 486...
  • Page 487 /6/7 /6/7 output C1/2 Comparator C1/2 output Interrupt-on-change interrupt trigger ADERR Read of ADERRH register ADRESH Read of ADRESH register ADPCH Write of ADPCH register SMT1/2 Signal Measurement Timer 1/2 Out Preliminary  2016 Microchip Technology Inc. DS40001841B-page 487...
  • Page 488 Note 1: The global interrupt can be disabled if the user is attempting to wake-up from Sleep and resume in-line code execution. 2: Refer to Section 32.3 “ADC Acquisi- tion Requirements”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 488...
  • Page 489 2: The charge holding capacitor (C ) is not discharged after each conversion. HOLD 3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin leakage specification. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 489...
  • Page 490 Note 1: Refer to Table 37-4 (parameter D340 and D341). FIGURE 32-5: ADC TRANSFER FUNCTION Full-Scale Range 3FFh 3FEh 3FDh 3FCh 3FBh Analog Input Voltage 0.5 LSB 1.5 LSB Zero-Scale REF- Full-Scale Transition REF+ Transition Preliminary  2016 Microchip Technology Inc. DS40001841B-page 490...
  • Page 491 CVD portion of the ADC module. FIGURE 32-6: HARDWARE CAPACITIVE VOLTAGE DIVIDER BLOCK DIAGRAM ADOUT Pad ADOUT ADOEN ADIPPOL = 1 ADC Conversion Bus ANx Pads ADIPPOL = 0 ADDCAP<2:0> Additional Sample and Hold Cap Preliminary  2016 Microchip Technology Inc. DS40001841B-page 491...
  • Page 492 Figure 32-7 HOLD shows waveform inverted measurements, which is known as differential CVD measurement. FIGURE 32-7: DIFFERENTIAL CVD MEASUREMENT WAVEFORM Precharge Acquisition Conversion Precharge Acquisition Conversion First Sample Second Sample Time Preliminary  2016 Microchip Technology Inc. DS40001841B-page 492...
  • Page 493 ‘0’. In this case, setting ADACQ to ‘0’ will set a maximum acquisition time (256 ADC clock cycles). When precharge is disabled, setting ADACQ to ‘0’ will dis- able hardware acquisition time control. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 493...
  • Page 494 This is used to improve the match between internal and external capacitance for a better sensing performance. The additional capacitance does not affect analog performance of the ADC because it is not connected during conversion. See Figure 32-11. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 494...
  • Page 495 Every trigger after that the ADC conversion result is sent through the filter and another threshold test is performed. The five modes are summarized in Table 32-3 below. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 495...
  • Page 496 TABLE 32-3: COMPUTATION MODES Bit Clear Conditions Value after Trigger completion Threshold Operations Value at ADTIF interrupt Mode ADMD ADACC and ADCNT ADACC ADCNT Retrigger Threshold Interrupt ADAOV ADFLTR ADCNT Test Basic ADACLR = 1 Unchanged Unchanged Every If thresh- count Sample old=true...
  • Page 497 ADCNT is also incremented, incrementing the number of samples accumulated. After each sample and accumulation, the ADACC value has a threshold comparison performed (see Section 32.5.7 “Threshold Comparison”) and the ADTIF interrupt may trigger. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 497...
  • Page 498 - If the threshold condition is met, the threshold interrupt flag ADTIF is set. Note 1: The threshold tests signed operations. 2: If ADAOV is set, a threshold interrupt is signaled. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 498...
  • Page 499 1 = ADC conversion cycle in progress. Setting this bit starts an ADC conversion cycle. The bit is cleared by hardware as determined by the ADCONT bit 0 = ADC conversion completed/not in progress Preliminary  2016 Microchip Technology Inc. DS40001841B-page 499...
  • Page 500 0 ADDSEN: Double-sample enable bit 1 = Two conversions are performed on each trigger. Data from the first conversion appears in ADPREV 0 = One conversion is performed for each trigger Preliminary  2016 Microchip Technology Inc. DS40001841B-page 500...
  • Page 501 ADCRS = 3'b111 is a reserved option. This bit is cleared by hardware when the accumulator operation is complete; depending on oscillator selections, the delay may be many instructions. Table 32-2 for Full mode descriptions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 501...
  • Page 502 001 = Interrupt if ADERR<ADLTH 000 = Never interrupt Note 1: When ADPSIS = 0, the value of ADRES-ADPREV) is the value of (S2-S1) from Table 32-3. When ADPSIS = 0 When ADPSIS = 1. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 502...
  • Page 503 001 = ADC module is in 1 precharge stage 000 = ADC module is not converting Note 1: If ADCS = 1, and F <F , these bits may be invalid. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 503...
  • Page 504 11 = V + is connected to internal Fixed Voltage Reference (FVR) module 10 = V + is connected to external V 01 = Reserved 00 = V + is connected to V Preliminary  2016 Microchip Technology Inc. DS40001841B-page 504...
  • Page 505 100000 = ANE0 Note 1: Section 31.0 “5-Bit Digital-to-Analog Converter (DAC) Module” for more information. Section 29.0 “Fixed Voltage Reference (FVR)” for more information. Section 30.0 “Temperature Indicator Module” for more information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 505...
  • Page 506 00000000 = Acquisition time is not included in the data conversion cycle Note: If ADPRE is not equal to ‘0’, then ADACQ = b’00000000 means Acquisition time is 256 clocks of the selected ADC clock. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 506...
  • Page 507 Counts the number of times that the ADC has been triggered and is used along with ADCNT to deter- mine when the error threshold is checked when the computation is Low-pass Filter, Burst Average, or Average modes. See Table 32-3 for more details. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 507...
  • Page 508 ADFLTR<7:0>: ADC Filter Output Least Significant bits In Accumulate, Average, and Burst Average mode, this is equal to ADACC right shifted by the ADCRS bits of ADCON2. In LPF mode, this is the output of the Low-pass Filter. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 508...
  • Page 509 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-2 Reserved: Do not use. bit 1-0 ADRES<9:8>: ADC Sample Result bits. Upper two bits of 10-bit conversion result. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 509...
  • Page 510 Upper bits of ADRES at the start of current ADC conversion Note 1: If ADPSIS = 0, ADPREVH and ADPREVL are formatted the same way as ADRES is, depending on the ADFM bit. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 510...
  • Page 511 -n/n = Value at POR and BOR/Value at all other Resets ‘1’ = Bit is set ‘0’ = Bit is cleared bit 7-0 ADACC<7:0>: ADC Accumulator LSB. Lower eight bits of accumulator value. See Table 32-2 for more details. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 511...
  • Page 512 ‘0’ = Bit is cleared bit 7-0 ADERR<7:0>: ADC Setpoint Error MSB. Upper byte of ADC Setpoint Error. Setpoint Error calculation is determined by ADCALC bits of ADCON3, see Register 23-1 for more details. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 512...
  • Page 513 ADLTH<7:0>: ADC Lower Threshold LSB. ADLTH and ADUTH are compared with ADERR to set the ADUTHR and ADLTHR bits of ADSTAT. Depending on the setting of ADTMD, an interrupt may be triggered by the results of this comparison. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 513...
  • Page 514 ADUTH<7:0>: ADC Upper Threshold LSB. ADLTH and ADUTH are compared with ADERR to set the ADUTHR and ADLTHR bits of ADSTAT. Depending on the setting of ADTMD, an interrupt may be triggered by the results of this comparison. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 514...
  • Page 515 01000 = TMR6_postscaled 00111 = TMR5_overflow 00110 = TMR4_postscaled 00101 = TMR3_overflow 00100 = TMR2_postscaled 00011 = TMR1_overflow 00010 = TMR0_overflow 00001 = Pin selected by ADACTPPS 00000 = External Trigger Disabled Preliminary  2016 Microchip Technology Inc. DS40001841B-page 515...
  • Page 516 ADFVR<1:0> DAC1CON1 — — — DAC1R<4:0> OSCSTAT EXTOR HFOR MFOR LFOR ADOR — PLLR Legend: — = unimplemented read as ‘ 0 ’. Shaded cells are not used for the ADC module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 516...
  • Page 517: Comparator Module (C1/2/3)

    • DSM Modulator Source Output • Input and Window signal to Signal Measurement Timer Note: The black areas of the output of the comparator represents the uncertainty due to input offsets and response time. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 517...
  • Page 518 Reserved Reserved RxyPPS (From Timer1 Module) T1CLK DAC_output FVR_buffer2 CxPCH<2:0> CxON When CxON = 0, all multiplexer inputs are disconnected and the Comparator will produce a ‘0’ at the output. Note 1: Preliminary  2016 Microchip Technology Inc. DS40001841B-page 518...
  • Page 519 1 = Comparator output to Timer1/3/5/7 and I/O pin is synchronous to changes on Timer1 clock source. 0 = Comparator output to Timer1/3/5/7 and I/O pin is asynchronous Output updated on the falling edge of Timer1/3/5/7 clock source. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 519...
  • Page 520 NCH<2:0>: Comparator Inverting Input Channel Select bits C1 Selection C2 Selection C3 Selection FVR buffer FVR buffer FVR buffer C1IN4- C2IN4- C3IN4- C1IN3- C2IN3- C3IN3- C1IN2- C2IN2- C3IN2- C1IN1- C2IN1- C3IN1- C1IN0- C2IN0- C3IN0- Preliminary  2016 Microchip Technology Inc. DS40001841B-page 520...
  • Page 521 = Bit is unknown bit 7-3 Unimplemented: Read as ‘0’ bit 2 MC3OUT: Mirror copy of C3OUT bit bit 1 MC2OUT: Mirror copy of C2OUT bit bit 0 MC1OUT: Mirror copy of C1OUT bit Preliminary  2016 Microchip Technology Inc. DS40001841B-page 521...
  • Page 522 The corresponding TRIS bit must be clear to enable the pin as an output. Note 1: The internal output of the comparator is latched with each instruction cycle. Unless otherwise specified, external out- puts are not latched. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 522...
  • Page 523 • INTP bit of the CMxCON1 register (for a rising edge detection) • INTN bit of the CMxCON1 register (for a falling edge detection) • PEIE and GIE bits of the INTCON register Preliminary  2016 Microchip Technology Inc. DS40001841B-page 523...
  • Page 524 = Input Capacitance = Leakage Current at the pin due to various junctions LEAKAGE = Interconnect Resistance = Source Impedance = Analog Voltage = Threshold Voltage Note 1: See Section 37.0 “Electrical Specifications”. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 524...
  • Page 525 Sleep, and synchronized comparator outputs will not operate. A comparator interrupt will wake the device from Sleep. The CxIE bits of the PIE2 register must be set to enable comparator interrupts. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 525...
  • Page 526 — C3IP C2IP C1IP PMD3 — DACMD ADCMD — CMP3MD CMP2MD CMP1MD ZCDMD — RxyPPS — RxyPPS<5:0> Legend: — = unimplemented, read as ‘0’. Shaded cells are unused by the comparator module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 526...
  • Page 527: High/Low-Voltage Detect (Hlvd)

    16 values. The trip point is selected by programming the HLVDSEL<3:0> bits (HLVDCON1<3:0>). FIGURE 34-1: HLVD MODULE BLOCK DIAGRAM HLVDSEL<3:0> HLVDEN HLVDOUT Trigger/ Interrupt HLVDIF Generation HLVDRDY HLVDINTH HLVDINTL Bandgap Reference Volatge HLVDEN Preliminary  2016 Microchip Technology Inc. DS40001841B-page 527...
  • Page 528 HLVD events. expired and a stable reference voltage is reached. For this reason, brief excursions beyond the set point may not be detected during this interval (see Figure 34-2 Figure 34-3). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 528...
  • Page 529 Band Gap Reference Voltage is Stable CASE 2: HLVD HLVDIF Enable HLVD FVRST HLVDRDY Band Gap Reference Voltage is Stable HLVDIF Cleared in Software HLVDIF Cleared in Software, HLVDIF Remains Set since HLVD Condition still Exists Preliminary  2016 Microchip Technology Inc. DS40001841B-page 529...
  • Page 530 T . This would give the application a time window, represented by the difference between and T , to safely exit. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 530...
  • Page 531 Register reads and writes through the CPU interface are allowed. 34.9 Effects of a Reset A device Reset forces all registers to their Reset state. This forces the HLVD module to be turned off. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 531...
  • Page 532 Reserved 1111 4.63V 1110 4.32V 1101 4.12V 1100 3.91V 1011 3.71V 1010 3.60V 1001 3.4V 1000 3.09V 0111 2.88V 0110 2.78V 0101 2.57V 0100 2.47V 0011 2.26V 0010 2.06V 0001 1.85V 0000 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 532...
  • Page 533 HLVDIP ZCDIP C3IP C2IP C1IP PMD0 SYSCMD FVRMD HLVDMD CRCMD SCANMD NVMMD CLKRMD IOCMD Note 1: — = unimplemented, read as ‘ 0 ’. Shaded cells are unused by the HLVD module. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 533...
  • Page 534: In-Circuit Serial Programming™ (Icsp™)

    MCLR Reset function is automatically enabled and cannot be disabled. See Section 8.6 “MCLR” for more information. The LVP bit can only be reprogrammed to ‘0’ by using the High-Voltage Programming mode. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 534...
  • Page 535 The 6-pin header (0.100" spacing) accepts 0.025" square pins. FIGURE 35-3: TYPICAL CONNECTION FOR ICSP™ PROGRAMMING External Programming Device to be Signals Programmed MCLR/V Data ICSPDAT Clock ICSPCLK To Normal Connections Isolation devices (as required). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 535...
  • Page 536: Instruction Set Summary

    The bit field designator ‘b’ selects the number of the bit affected by the operation, while the file register designator ‘f’ represents the number of the file in which the bit is located. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 536...
  • Page 537 Specifies bit n of the register indicated by the pointer expr. [expr]<n>  Assigned to. Register bit field. < >  In the set of. User defined term (font is Courier). italics Preliminary  2016 Microchip Technology Inc. DS40001841B-page 537...
  • Page 538 1111 n = 20-bit immediate value OPCODE n<7:0> (literal) CALL MYFUNC 12 11 n<19:8> (literal) 1111 S = Fast bit 11 10 OPCODE n<10:0> (literal) BRA MYFUNC OPCODE n<7:0> (literal) BC MYFUNC Preliminary  2016 Microchip Technology Inc. DS40001841B-page 538...
  • Page 539 Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem- ory locations have a valid instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 539...
  • Page 540 Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem- ory locations have a valid instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 540...
  • Page 541 Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem- ory locations have a valid instruction. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 541...
  • Page 542 Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in symbolic addressing. If a label is used, the instruction format then becomes: {label} instruction argument(s). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 542...
  • Page 543 After Instruction Words: Cycles: Q Cycle Activity: Decode Read Process Write to register ‘f’ Data destination Example: ADDWFC REG, 0, 1 Before Instruction CARRY bit = After Instruction CARRY bit = Preliminary  2016 Microchip Technology Inc. DS40001841B-page 543...
  • Page 544 ‘n’ Data operation Example: ANDWF REG, 0, 0 Example: HERE Before Instruction Before Instruction address (HERE) After Instruction After Instruction If CARRY address (HERE + 12) If CARRY address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 544...
  • Page 545 ‘n’ Data operation Before Instruction FLAG_REG = After Instruction Example: HERE Jump FLAG_REG = Before Instruction address (HERE) After Instruction If NEGATIVE = address (Jump) If NEGATIVE = address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 545...
  • Page 546 Before Instruction address (HERE) address (HERE) After Instruction After Instruction If CARRY If NEGATIVE = address (Jump) address (Jump) If CARRY If NEGATIVE = address (HERE + 2) address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 546...
  • Page 547 Before Instruction address (HERE) address (HERE) After Instruction After Instruction If OVERFLOW = If ZERO address (Jump) address (Jump) If OVERFLOW = If ZERO address (HERE + 2) address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 547...
  • Page 548 Q Cycle Activity: Example: HERE Jump Before Instruction Decode Read Process Write address (HERE) register ‘f’ Data register ‘f’ After Instruction address (Jump) Example: FLAG_REG, 7, 1 Before Instruction FLAG_REG After Instruction FLAG_REG Preliminary  2016 Microchip Technology Inc. DS40001841B-page 548...
  • Page 549 FALSE FALSE TRUE TRUE Before Instruction Before Instruction address (HERE) address (HERE) After Instruction After Instruction If FLAG<1> If FLAG<1> address (TRUE) address (FALSE) If FLAG<1> If FLAG<1> address (FALSE) address (TRUE) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 549...
  • Page 550 PORTC = 0111 0101 [75h] Example: HERE Jump After Instruction: Before Instruction PORTC = 0110 0101 [65h] address (HERE) After Instruction If OVERFLOW = address (Jump) If OVERFLOW = address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 550...
  • Page 551 After Instruction If ZERO Example: HERE CALL THERE, 1 address (Jump) Before Instruction If ZERO address (HERE + 2) address (HERE) After Instruction address (THERE) address (HERE + 4) BSRS STATUSS = Status Preliminary  2016 Microchip Technology Inc. DS40001841B-page 551...
  • Page 552 Q Cycle Activity: Before Instruction WDT Counter After Instruction Decode Read Process Write WDT Counter register ‘f’ Data register ‘f’ WDT Postscaler Example: CLRF FLAG_REG, 1 Before Instruction FLAG_REG After Instruction FLAG_REG Preliminary  2016 Microchip Technology Inc. DS40001841B-page 552...
  • Page 553 If skip and followed by 2-word instruction: operation operation operation operation operation operation operation operation Example: HERE CPFSEQ REG, 0 NEQUAL EQUAL Before Instruction PC Address HERE After Instruction If REG Address (EQUAL)  If REG Address (NEQUAL) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 553...
  • Page 554 CPFSGT REG, 0 NGREATER After Instruction GREATER If REG < Before Instruction Address (LESS) Address (HERE)  If REG Address (NLESS) After Instruction  If REG Address (GREATER)  If REG Address (NGREATER) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 554...
  • Page 555 Q Cycle Activity: Example1: Decode Read Process Write to Before Instruction register ‘f’ Data destination Example: DECF CNT, 1, 0 After Instruction Before Instruction After Instruction Example 2: Before Instruction After Instruction Preliminary  2016 Microchip Technology Inc. DS40001841B-page 555...
  • Page 556 After Instruction CNT - 1 If CNT TEMP TEMP – 1, PC = Address (CONTINUE) If TEMP  If CNT Address (ZERO)  PC = Address (HERE + 2) If TEMP Address (NZERO) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 556...
  • Page 557 Q Cycle Activity: Example: GOTO THERE Decode Read Process Write to After Instruction register ‘f’ Data destination PC = Address (THERE) Example: INCF CNT, 1, 0 Before Instruction After Instruction Preliminary  2016 Microchip Technology Inc. DS40001841B-page 557...
  • Page 558 Address (HERE) Address (HERE) After Instruction After Instruction REG + 1 CNT + 1  If CNT If REG Address (ZERO) Address (NZERO)  If CNT If REG Address (NZERO) Address (ZERO) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 558...
  • Page 559 Offset Mode” for details. Words: Cycles: Q Cycle Activity: Decode Read Process Write to register ‘f’ Data destination Example: IORWF RESULT, 0, 1 Before Instruction RESULT = After Instruction RESULT = Preliminary  2016 Microchip Technology Inc. DS40001841B-page 559...
  • Page 560 LFSR 2, 3ABh eral Offset Mode” for details. After Instruction Words: FSR2H FSR2L Cycles: Q Cycle Activity: Decode Read Process Write W register ‘f’ Data Example: MOVF REG, 0, 0 Before Instruction After Instruction Preliminary  2016 Microchip Technology Inc. DS40001841B-page 560...
  • Page 561 Q Cycle Activity: Decode Read Process register ‘f’ Data operation (src) Decode Write operation operation register ‘f’ (dest) No dummy read Example: MOVFF REG1, REG2 Before Instruction REG1 REG2 After Instruction REG1 REG2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 561...
  • Page 562 Oriented Instructions in Indexed Lit- eral Offset Mode” for details. Words: Cycles: Q Cycle Activity: Decode Read Process Write register ‘f’ Data register ‘f’ Example: MOVWF REG, 0 Before Instruction After Instruction Preliminary  2016 Microchip Technology Inc. DS40001841B-page 562...
  • Page 563 PRODH Cycles: PRODL Q Cycle Activity: After Instruction Decode Read Process Write PRODH PRODL register ‘f’ Data registers PRODH: PRODL Example: MULWF REG, 1 Before Instruction PRODH PRODL After Instruction PRODH PRODL Preliminary  2016 Microchip Technology Inc. DS40001841B-page 563...
  • Page 564 Offset Mode” for details. Words: Cycles: Q Cycle Activity: Decode Read Process Write register ‘f’ Data register ‘f’ Example: NEGF REG, 1 Before Instruction 0011 1010 [3Ah] After Instruction 1100 0110 [C6h] Preliminary  2016 Microchip Technology Inc. DS40001841B-page 564...
  • Page 565 Example: Example: PUSH GOTO Before Instruction Before Instruction 345Ah 0124h 0031A2h Stack (1 level down) 014332h After Instruction After Instruction 0126h 0126h 014332h Stack (1 level down) 345Ah Preliminary  2016 Microchip Technology Inc. DS40001841B-page 565...
  • Page 566 ‘n’ Data PUSH PC to stack operation operation operation operation Example: HERE RCALL Jump Before Instruction PC = Address (HERE) After Instruction PC = Address (Jump) TOS = Address (HERE + 2) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 566...
  • Page 567 ; W = offset RETLW k0 ; Begin table Example: RETLW k1 RETFIE After Interrupt RETLW kn ; End of table BSRS Status STATUSS Before Instruction GIE/GIEH, PEIE/GIEL After Instruction value of kn Preliminary  2016 Microchip Technology Inc. DS40001841B-page 567...
  • Page 568 Q Cycle Activity: Example: RETURN After Instruction: Decode Read Process Write to PC = TOS register ‘f’ Data destination Example: RLCF REG, 0, 0 Before Instruction 1110 0110 After Instruction 1110 0110 1100 1100 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 568...
  • Page 569 ‘f’ Data destination Example: RLNCF REG, 1, 0 Before Instruction Example: RRCF REG, 0, 0 1010 1011 After Instruction Before Instruction 0101 0111 1110 0110 After Instruction 1110 0110 0111 0011 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 569...
  • Page 570 Data destination Example 1: RRNCF REG, 1, 0 Before Instruction 1101 0111 After Instruction 1110 1011 Example 2: RRNCF REG, 0, 0 Before Instruction 1101 0111 After Instruction 1110 1011 1101 0111 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 570...
  • Page 571 ; result is negative Example 2: SUBFWB REG, 0, 0 Before Instruction After Instruction ; result is positive Example 3: SUBFWB REG, 1, 0 Before Instruction After Instruction ; result is zero Preliminary  2016 Microchip Technology Inc. DS40001841B-page 571...
  • Page 572 ; result is positive Example 2: SUBWF REG, 0, 0 Before Instruction After Instruction ; result is zero Example 3: SUBWF REG, 1, 0 Before Instruction After Instruction FFh ;(2’s complement) ; result is negative Preliminary  2016 Microchip Technology Inc. DS40001841B-page 572...
  • Page 573 After Instruction (0001 1011) ; result is zero Example 3: SUBWFB REG, 1, 0 Before Instruction (0000 0011) (0000 1110) After Instruction (1111 0101) ; [2’s comp] (0000 1110) ; result is negative Preliminary  2016 Microchip Technology Inc. DS40001841B-page 573...
  • Page 574 TBLPTR as follows: • no change • post-increment • post-decrement • pre-increment Words: Cycles: Q Cycle Activity: Decode operation operation operation No operation No operation operation (Read Program operation (Write TABLAT) Memory) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 574...
  • Page 575 TBLPTR as follows: • no change • post-increment • post-decrement • pre-increment Words: Cycles: Q Cycle Activity: Decode operation operation operation operation operation operation operation (Read (Write to TABLAT) Holding Register ) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 575...
  • Page 576 Example: HERE TSTFSZ CNT, 1 NZERO ZERO Before Instruction Address (HERE) After Instruction If CNT 00h, Address (ZERO)  If CNT 00h, Address (NZERO) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 576...
  • Page 577 Oriented Instructions in Indexed Lit- eral Offset Mode” for details. Words: Cycles: Q Cycle Activity: Decode Read Process Write to register ‘f’ Data destination Example: XORWF REG, 1, 0 Before Instruction After Instruction Preliminary  2016 Microchip Technology Inc. DS40001841B-page 577...
  • Page 578 Store literal at FSR2, None 1110 1010 kkkk kkkk decrement FSR2 SUBFSR f, k Subtract literal from FSR None 1110 1001 ffkk kkkk SUBULNK Subtract literal from FSR2 and None 1110 1001 11kk kkkk return Preliminary  2016 Microchip Technology Inc. DS40001841B-page 578...
  • Page 579 Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in symbolic addressing. If a label is used, the instruction syntax then becomes: {label} instruction argument(s). Preliminary  2016 Microchip Technology Inc. DS40001841B-page 579...
  • Page 580 PCLATU = read After Instruction 001006h Example: MOVSF [05h], REG2 address (HERE + 2) PCLATH = Before Instruction PCLATU = FSR2 Contents of 85h REG2 After Instruction FSR2 Contents of 85h REG2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 580...
  • Page 581 Determine Determine Write dest addr dest addr to dest reg Example: MOVSS [05h], [06h] Before Instruction FSR2 Contents of 85h Contents of 86h After Instruction FSR2 Contents of 85h Contents of 86h Preliminary  2016 Microchip Technology Inc. DS40001841B-page 581...
  • Page 582 Decode Read Process Write to FSR2 03FFh register ‘f’ Data destination After Instruction FSR2 03DCh Operation Operation Operation Operation Example: SUBULNK 23h Before Instruction FSR2 03FFh 0100h After Instruction FSR2 03DCh (TOS) Preliminary  2016 Microchip Technology Inc. DS40001841B-page 582...
  • Page 583 Legacy applica- tions shown in the examples are applicable to all tions that heavily use the Access Bank will most likely instructions of these types. not benefit from using the extended instruction set. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 583...
  • Page 584 FSR2, offset by ‘k’, are set to FFh. Words: Cycles: Q Cycle Activity: Decode Read ‘k’ Process Write Data register Example: SETF [OFST] Before Instruction OFST FSR2 0A00h Contents of 0A2Ch After Instruction Contents of 0A2Ch Preliminary  2016 Microchip Technology Inc. DS40001841B-page 584...
  • Page 585 • A command line option • A directive in the source code These options vary between different compilers, assemblers and development environments. Users are encouraged to review the documentation accompanying their development systems appropriate information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 585...
  • Page 586: Development Support

    Project-Based Workspaces: • Multiple projects • Multiple tools • Multiple configurations • Simultaneous debugging sessions File History and Bug Tracking: • Local file history feature • Built-in support for Bugzilla issue tracker Preliminary  2016 Microchip Technology Inc. DS40001841B-page 586...
  • Page 587 The MPASM Assembler features include: • Integration into MPLAB X IDE projects • User-defined macros to streamline assembly code • Conditional assembly for multipurpose source files • Directives that allow complete control over the assembly process Preliminary  2016 Microchip Technology Inc. DS40001841B-page 587...
  • Page 588 PC via an RS-232 or USB cable. The MPLAB PM3 has high-speed communications and optimized algorithms for quick programming of large memory devices, and incorporates an MMC card for file storage and data applications. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 588...
  • Page 589 This usually includes a single application and debug capability, all on one board. Check the Microchip web page (www.microchip.com) for the complete list of demonstration, development and evaluation kits. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 589...
  • Page 590: Electrical Specifications

    Storage temperature ........................-65°C to +150°C Voltage on pins with respect to V on V PIC18F67K40 ......................-0.3V to +6.5V PIC18LF67K40 ......................-0.3V to +4.0V on MCLR pin ........................... -0.3V to +9.0V on all other pins ......................-0.3V to (V + 0.3V)
  • Page 591 (Fosc  64 MHz) ......................+3.0V DDMIN ............................ +5.5V DDMAX — Operating Ambient Temperature Range Industrial Temperature ............................-40°C ............................ +85°C Extended Temperature ............................-40°C ..........................+125°C Note 1: See Parameter Supply Voltage, DS Characteristics: Supply Voltage. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 591...
  • Page 592 VOLTAGE FREQUENCY GRAPH, -40°C +125°C, PIC18LF67K40 ONLY Frequency (MHz) Note 1: The shaded region indicates the permissible combinations of voltage and frequency. 2: Refer to Table 38-7 for each Oscillator mode’s supported frequencies. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 592...
  • Page 593 This is the limit to which V can be lowered in Sleep mode without losing RAM data. Figure 38-3, POR and POR REARM with Slow Rising V Please see Table 38-11 for BOR and LPBOR trip point information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 593...
  • Page 594 POR AND POR REARM WITH SLOW RISING V PORR NPOR POR REARM VLOW Note 1: When NPOR is low, the device is held in Reset. 1  s typical. 2.7  s typical. VLOW Preliminary  2016 Microchip Technology Inc. DS40001841B-page 594...
  • Page 595 = [I *(N-1)/N] + I 16/N where N = DOZE Ratio (Register 6-2). DD DOZE DD IDLE DD HFO PMD bits are all in the default state, no modules are disabled. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 595...
  • Page 596 Sleep mode with all I/O pins in high-impedance state and tied to V All peripheral currents listed are on a per-peripheral basis if more than one instance of a peripheral is available. ADC clock source is FRC. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 596...
  • Page 597 2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 597...
  • Page 598 Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: Flash Memory Cell Endurance for the Flash memory is defined as: One Row Erase operation and one Self-Timed Write. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 598...
  • Page 599 2: T = Ambient Temperature, T = Junction Temperature 3: See absolute maximum ratings for total power dissipation. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 599...
  • Page 600 PIC18(L)F67K40 38.4 AC Characteristics FIGURE 38-4: LOAD CONDITIONS Rev. 10-000133A 8/1/2013 Load Condition Legend: CL=50 pF for all pins Preliminary  2016 Microchip Technology Inc. DS40001841B-page 600...
  • Page 601 LP, XT and HS oscillator modes require an appropriate crystal or resonator to be connected to the device. For clocking the device with the external square wave, one of the EC mode selections must be used. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 601...
  • Page 602 LP, XT and HS oscillator modes require an appropriate crystal or resonator to be connected to the device. For clocking the device with the external square wave, one of the EC mode selections must be used. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 602...
  • Page 603 Figure 38-6: Precision Calibrated HFINTOSC Frequency Accuracy Over Device V and Tempera- ture. FIGURE 38-6: PRECISION CALIBRATED HFINTOSC FREQUENCY ACCURACY OVER DEVICE AND TEMPERATURE ± 5% ± 3% ± 2% ± 5% Preliminary  2016 Microchip Technology Inc. DS40001841B-page 603...
  • Page 604 † Data in “Typ” column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: The output frequency of the PLL must meet the F requirements listed in Parameter D002. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 604...
  • Page 605 IO10* INT pin high or low time to trigger an — — interrupt IO11* Interrupt-on-Change minimum high or low — — time to trigger interrupt *These parameters are characterized but not tested. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 605...
  • Page 606 (Device not in Brown-out Reset) RST08 Reset RST04 (due to BOR) Note 1: Only if PWRTE bit in the Configuration Word register is programmed to ‘ 1 ’; 2 ms delay if PWRTE = 0 . Preliminary  2016 Microchip Technology Inc. DS40001841B-page 606...
  • Page 607 HLVDSEL<3:0>= 1000 — 3.60 — HLVDSEL<3:0>= 1001 — 3.75 — HLVDSEL<3:0>= 1010 — 4.00 — HLVDSEL<3:0>= 1011 — 4.20 — HLVDSEL<3:0>= 1100 — 4.35 — HLVDSEL<3:0>= 1101 — 4.65 — HLVDSEL<3:0>= 1110 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 607...
  • Page 608 2: The ADC conversion result never decreases with an increase in the input and has no missing codes. 3: This is the impedance seen by the V pads when the external reference pads are selected. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 608...
  • Page 609 Does not apply for the ADCRC oscillator. FIGURE 38-10: ADC CONVERSION TIMING (ADC CLOCK F -BASED) BSF ADCON0, GO AD133 AD131 AD130 ADC_clk ADC Data NEW_DATA OLD_DATA ADRES ADIF DONE Sampling Stopped AD132 Sample Preliminary  2016 Microchip Technology Inc. DS40001841B-page 609...
  • Page 610 AD132 Sample Note 1: If the ADC clock source is selected as ADCRC, a time of T is added before the ADC clock starts. This allows the SLEEP instruction to be executed. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 610...
  • Page 611 RESPH s Response Time, Falling Edge — — RESPL † Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 611...
  • Page 612 Increment mode These parameters are characterized but not tested. † Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 612...
  • Page 613 N = prescale value These parameters are characterized but not tested. † Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 613...
  • Page 614 (unless otherwise stated) Param. Symbol Characteristic Min. Max. Units Conditions US125 SYNC RCV (Master and Slave) Data-setup before CK  (DT hold time) — Data-hold after CK  (DT hold time) US126 — Preliminary  2016 Microchip Technology Inc. DS40001841B-page 614...
  • Page 615 (CKP = 1 ) SP80 SP78 bit 6 - - - - - -1 SP75, SP76 MSb In bit 6 - - - -1 LSb In SP74 Note: Refer to Figure 38-4 for load conditions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 615...
  • Page 616 (CKP = 1 ) SP80 bit 6 - - - - - -1 SP77 SP75, SP76 MSb In bit 6 - - - -1 LSb In SP74 Note: Refer to Figure 38-4 for load conditions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 616...
  • Page 617 — — These parameters are characterized but not tested. † Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 617...
  • Page 618 These parameters are characterized but not tested. FIGURE 38-21: C BUS DATA TIMING SP100 SP102 SP103 SP101 SP90 SP106 SP107 SP91 SP92 SP110 SP109 SP109 Note: Refer to Figure 38-4 for load conditions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 618...
  • Page 619 SCL signal. If such a device does stretch the low period of the SCL signal, it must output the next data bit to the SDA line T max. + T = 1000 + 250 = 1250 ns (according to the Standard mode I C bus specification), before the SCL line is released. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 619...
  • Page 620: Dc And Ac Characteristics Graphs And Tables

    PIC18(L)F67K40 39.0 DC AND AC CHARACTERISTICS GRAPHS AND TABLES Graphs and tables are not available at this time. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 620...
  • Page 621: Packaging Information

    In the event the full Microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 621...
  • Page 622 PIC18(L)F67K40 40.1 Package Details The following sections give the technical details of the packages. Note: For the most current package drawings, please see the Microchip Packaging Specification located at http://www.microchip.com/packaging Preliminary  2016 Microchip Technology Inc. DS40001841B-page 622...
  • Page 623 PIC18(L)F67K40 Note: For the most current package drawings, please see the Microchip Packaging Specification located at http://www.microchip.com/packaging Preliminary  2016 Microchip Technology Inc. DS40001841B-page 623...
  • Page 624 PIC18(L)F67K40 Note: For the most current package drawings, please see the Microchip Packaging Specification located at http://www.microchip.com/packaging Preliminary  2016 Microchip Technology Inc. DS40001841B-page 624...
  • Page 625 0.20 C A-B D NOTE 1 0.20 H A-B D TOP VIEW 0.05 SEATING PLANE 64 X b 0.08 C 0.08 C A-B D SIDE VIEW Microchip Technology Drawing C04-085C Sheet 1 of 2 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 625...
  • Page 626 4. Dimensioning and tolerancing per ASME Y14.5M BSC: Basic Dimension. Theoretically exact value shown without tolerances. REF: Reference Dimension, usually without tolerance, for information purposes only. Microchip Technology Drawing C04-085C Sheet 2 of 2 Preliminary  2016 Microchip Technology Inc.
  • Page 627 Contact Pad Length (X28) 1.50 Distance Between Pads 0.20 Notes: 1. Dimensioning and tolerancing per ASME Y14.5M BSC: Basic Dimension. Theoretically exact value shown without tolerances. Microchip Technology Drawing C04-2085B Sheet 1 of 1 Preliminary  2016 Microchip Technology Inc. DS40001841B-page 627...
  • Page 628: Appendix A: Revision History

    4-2, 4-5, 13-18 and 32-6; Sections 1.2, 4.4.1, 4.5, 4.5.4, 17.3, 17.5, 17.7, 18.1, 18.1.1, 18.1.1.1, 18.1.2, 18.1.6, 18.3, 18.4, 18.7, 19.0, 19.8.1, 20.0, 21.3 and 26.3; Tables 4-2, 10-4, 38-5 and 38-14. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 628...
  • Page 629: Appendix B: Device Differences

    Table B-1. TABLE B-1: DEVICE DIFFERENCES Features PIC18(L)F65K40 PIC18(L)F66K40 PIC18(L)F67K40 32768 65536 131072 Program Memory (Bytes) SRAM (Bytes) 2048 3562 3562 Note 1: PIC18F6xK40: operating voltage, 2.3V-5.5V. PIC18LF6xK40: operating voltage, 1.8V-3.6V. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 629...
  • Page 630: The Microchip Website

    Microchip website www.microchip.com. Under “Support”, click “Customer Change Notification” and follow the registration instructions. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 630...
  • Page 631: Product Identification System

    Tape and Reel identifier only appears in Pattern: QTP, SQTP, Code or Special Requirements catalog part number description. This (blank otherwise) identifier is used for ordering purposes and is not printed on the device package. Preliminary  2016 Microchip Technology Inc. DS40001841B-page 631...

This manual is also suitable for:

Pic18f67k40

Table of Contents