Datasheet PIC18(L)F26/27/45/46/47/55/56/57K42 (Microchip) - 4

ManufacturerMicrochip
Description28/40/44/48-Pin, Low-Power High-Performance Microcontrollers with XLP Technology
Pages / Page833 / 4 — PIC18(L)F2X/4X/5XK42 FAMILY TYPES. (KB). ime. t T. rtition. dex. Select. …
File Format / SizePDF / 11.3 Mb
Document LanguageEnglish

PIC18(L)F2X/4X/5XK42 FAMILY TYPES. (KB). ime. t T. rtition. dex. Select. 6-bi. (by. tor. rru. le Disab. (1). ins. Device. eet. PROM (. ara p. T) /1. tchd

PIC18(L)F2X/4X/5XK42 FAMILY TYPES (KB) ime t T rtition dex Select 6-bi (by tor rru le Disab (1) ins Device eet PROM ( ara p T) /1 tchd

Model Line for this Datasheet

Text Version of Document

 2017
PIC18(L)F2X/4X/5XK42 FAMILY TYPES
-2019 Microchip
r r r le (KB) ime ) T ime ime B s) t ts T t T rtition p dex te 2 g Select In 6-bi en (by tor o Pa rru le Disab m te u (1)
Technology In
ins Device eet PROM ( ara p T) /1 tchd Access (DMA) cess In PIC18(L)F26/27/45/46/47/55/56/57K42 it ADC (ch) a ure CWG NCO CLC ry (ch) C/SPI al Pin bug I/O P HL (SMT) o ed UART 2 I er a Sh (WWDT) a EE SRAM 5-bit DAC W or De ta 12-b Com th ry Ac eral Mod Dat m Flash Memory ow Dat CCP/10-bit PWM Da al Meas Zero-Cross Detect ect t/ (wi ind ct Mem V Periph riph
c.
W Memo Progra Pe 8-bi Sign Dire
PIC18(L)F24K42 A 16 256 1024 25 24 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F25K42 A 32 256 2048 25 24 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F26K42 B 64 1024 4096 25 24 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F27K42 B 128 1024 8192 25 24 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F45K42 B 32 256 2048 36 35 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F46K42 B 64 1024 4096 36 35 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F47K42 B 128 1024 8192 36 35 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F55K42 B 32 256 2048 44 43 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F56K42 B 64 1024 4096 44 43 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I PIC18(L)F57K42 B 128 1024 8192 44 43 1 2 3/4 Y Y 4/4 3 1 4 Y 2 Y Y 2 2/1 Y Y I
Note 1:
I – Debugging integrated on chip.
Data Sheet Index: Shaded devices are not described in this document. A:
DS40001869 PIC18(L)F24/25K42 Data Sheet, 28-Pin
B:
DS40001919 PIC18(L)F26/27/45/46/47/55/56/57K42 Data Sheet, 28/40/44/48-Pin D S 40001919E-
Note:
For other small form-factor package availability and marking information, visit
http://www.microchip.com/packaging
or contact your local sales office. page 4 Document Outline Description Core Features Memory Operating Characteristics Power-Saving Functionality eXtreme Low-Power (XLP) Features Digital Peripherals Analog Peripherals Flexible Oscillator Structure PIC18(L)F2X/4X/5XK42 Family Types Pin Diagrams Pin Allocation Tables Most Current Data Sheet Errata Customer Notification System 1.0 Device Overview 1.1 New Features 1.2 Details on Individual Family Members TABLE 1-1: Device Features 1.3 Register and Bit naming conventions 1.3.1 Register Names 1.3.2 Bit Names 1.3.2.1 Short Bit Names 1.3.2.2 Long Bit Names 1.3.2.3 Bit Fields 1.3.3 Register and Bit Naming Exceptions 1.3.3.1 Status, Interrupt, and Mirror Bits 2.0 Guidelines for Getting Started with PIC18(L)F26/ 27/45/46/47/55/56/57K42 Microcontrollers 2.1 Basic Connection Requirements FIGURE 2-1: Recommended Minimum Connections 2.2 Power Supply Pins 2.2.1 Decoupling Capacitors 2.2.2 Tank Capacitors 2.3 Master Clear (MCLR) Pin FIGURE 2-2: Example of MCLR Pin Connections 2.4 ICSP™ Pins 2.5 External Oscillator Pins 2.6 Unused I/Os FIGURE 2-3: Suggested Placement of the Oscillator Circuit 3.0 PIC18 CPU FIGURE 3-1: PIC18(L)F26/27/45/46/47/55/56/57K42 Family Block Diagram 3.1 System Arbitration TABLE 3-1: Default Priorities FIGURE 3-2: Simplified Block Diagram of On-Chip Reset Circuit 3.1.1 Priority Lock EXAMPLE 3-1: Priority Lock Sequence EXAMPLE 3-2: Priority Unlock Sequence 3.2 Memory Access Scheme 3.2.1 ISR Priority > MAIN Priority > Peripheral Priority 3.2.2 Peripheral Priority > ISR Priority > MAIN Priority 3.2.3 ISR Priority > Peripheral Priority > MAIN Priority 3.2.4 Peripheral 1 Priority > ISR Priority > MAIN Priority > Peripheral 2 Priority Register 3-1: ISRPR: Interrupt Service Routine Priority Register Register 3-2: MAINPR: Main Routine Priority Register Register 3-3: DMA1PR: DMA1 Priority Register Register 3-4: DMA2PR: DMA2 Priority Register Register 3-5: SCANPR: Scanner Priority Register Register 3-6: PRLOCK: Priority Lock Register TABLE 3-2: Summary of Registers Associated with CPU 4.0 Memory Organization 4.1 Program Flash Memory Organization 4.2 Memory Access Partition (MAP) 4.2.1 Application Block 4.2.2 Boot Block 4.2.3 Storage Area Flash TABLE 4-1: Program and Data EEPROM Memory Map TABLE 4-2: Program Flash Memory Partition 4.2.4 Program Counter 4.2.5 Return Address Stack 4.2.5.1 Top-of-Stack Access FIGURE 4-1: Return Address Stack and Associated Registers 4.2.5.2 Return Stack Pointer (STKPTR) 4.2.5.3 PUSH and POP Instructions 4.3 Register Definitions: Stack Pointer Register 4-1: TOSU: Top of Stack Upper Byte Register 4-2: TOSH: Top of Stack High Byte Register 4-3: TOSL: Top of Stack Low Byte Register 4-4: STKPTR: Stack Pointer Register 4.3.1 Fast Register Stack EXAMPLE 4-1: Fast Register Stack Code Example 4.3.2 Look-up Tables in Program Memory 4.3.2.1 Computed GOTO EXAMPLE 4-2: Computed GOTO Using an Offset Value 4.3.2.2 Table Reads and Table Writes 4.4 PIC18 Instruction Cycle 4.4.1 Instruction Flow/Pipelining EXAMPLE 4-3: Instruction Pipeline Flow 4.4.2 Instructions in Program Memory 4.4.3 Multi-Word Instructions FIGURE 4-2: Instructions in Program Memory EXAMPLE 4-4: Two-Word Instructions EXAMPLE 4-5: Three-Word Instructions 4.5 Data Memory Organization 4.5.1 Bank Select Register (BSR) FIGURE 4-3: Data Memory Map for Devices FIGURE 4-4: Data Memory Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices FIGURE 4-5: Use of the Bank Select Register (Direct Addressing) 4.5.2 General Purpose Register File 4.5.3 Special Function Registers 4.5.4 Access Bank TABLE 4-3: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices (DMA Access Only) TABLE 4-4: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 63 TABLE 4-5: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 62 TABLE 4-6: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 61 TABLE 4-7: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 60 TABLE 4-8: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 59 TABLE 4-9: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 58 TABLE 4-10: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 57 TABLE 4-11: Special Function Register Map for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices Bank 56 4.5.5 Status Register 4.5.6 Call Shadow Register 4.6 Register Definitions: Status Registers Register 4-2: STATUS: Status Register 4.7 Data Addressing Modes 4.7.1 Inherent and Literal Addressing 4.7.2 Direct Addressing 4.7.3 Indirect Addressing EXAMPLE 4-6: How to Clear RAM (Bank 1) Using Indirect Addressing 4.7.3.1 FSR Registers and the INDF Operand 4.7.3.2 FSR Registers, POSTINC, POSTDEC, PREINC and PLUSW FIGURE 4-6: Indirect Addressing 4.7.3.3 Operations by FSRs on FSRs 4.8 Data Memory and the Extended Instruction Set 4.8.1 Indexed Addressing with Literal Offset 4.8.2 Instructions Affected by Indexed Literal Offset Mode FIGURE 4-7: Comparing Addressing Options for Bit-Oriented and Byte-Oriented Instructions (Extended Instruction Set Enabled) 4.8.3 Mapping the Access Bank in Indexed Literal Offset Mode 4.9 PIC18 Instruction Execution and the Extended Instruction Set FIGURE 4-8: Remapping the Access Bank with Indexed Literal Offset Addressing 5.0 Device Configuration 5.1 Configuration Words 5.2 Register Definitions: Configuration Words Register 5-1: Configuration Word 1L (30 0000h) Register 5-2: Configuration Word 1H (30 0001h) Register 5-3: Configuration Word 2L (30 0002h) Register 5-4: Configuration Word 2H (30 0003h) Register 5-5: Configuration Word 3L (30 0004h) Register 5-6: Configuration Word 3H (30 0005h) Register 5-7: Configuration Word 4L (30 0006h) TABLE 5-1: Boot Block Size Bits Register 5-8: Configuration Word 4H (30 0007h) Register 5-9: Configuration Word 5L (30 0008h) Register 5-10: Configuration Word 5H (30 0009h) TABLE 5-2: Summary of Configuration Words 5.3 Code Protection 5.4 User ID 5.5 Device ID and Revision ID 5.6 Register Definitions: Device ID and Revision ID Register 5-11: DEVICE ID: Device ID Register Register 5-12: REVISION ID: Revision ID Register 5.7 Device Information Area TABLE 5-3: Device Information Area 5.7.1 Microchip Unique identifier (MUI) 5.7.2 External Unique Identifier (EUI) 5.7.3 Analog-to-Digital Conversion Data of the Temperature Sensor 5.7.4 Fixed Voltage Reference Data 5.8 Device Configuration Information TABLE 5-4: Device Configuration Information for PIC18(L)F26/27/45/55/46/47/56/57K42 6.0 Resets FIGURE 6-1: Simplified Block Diagram of On-Chip Reset Circuit FIGURE 6-2: LPBOR, BOR, POR Relationship 6.1 Power-on Reset (POR) 6.2 Brown-out Reset (BOR) 6.2.1 BOR is Always On 6.2.2 BOR is Off in Sleep 6.2.3 BOR Controlled by Software 6.2.4 BOR and Bulk Erase TABLE 6-1: BOR Operating Modes FIGURE 6-3: Brown-out Situations 6.3 Register Definitions: BOR Control Register 6-1: BORCON: Brown-out Reset Control Register 6.4 Low-Power Brown-out Reset (LPBOR) 6.4.1 Enabling LPBOR 6.4.1.1 LPBOR Module Output 6.5 MCLR TABLE 6-2: MCLR Configuration 6.5.1 MCLR Enabled 6.5.2 MCLR Disabled 6.6 Windowed Watchdog Timer (WWDT) Reset 6.7 RESET Instruction 6.8 Stack Overflow/Underflow Reset 6.9 Programming Mode Exit 6.10 Power-up Timer (PWRT) 6.11 Start-up Sequence FIGURE 6-4: Reset Start-up Sequence 6.11.1 Memory Execution Violation 6.12 Determining the Cause of a Reset TABLE 6-3: Reset Condition for Special Registers 6.13 Power Control (PCON0/PCON1) Register 6.14 Register Definitions: Power Control Register 6-2: PCON0: Power Control Register 0 Register 6-3: PCON1: Power Control Register 1 TABLE 6-4: Summary of Registers Associated with Resets 7.0 Oscillator Module (with Fail-Safe Clock Monitor) 7.1 Overview FIGURE 7-1: Simplified PIC® MCU Clock Source Block Diagram 7.2 Clock Source Types 7.2.1 External Clock Sources 7.2.1.1 EC Mode FIGURE 7-2: External Clock (EC) Mode Operation 7.2.1.2 LP, XT, HS Modes FIGURE 7-3: Quartz Crystal Operation (LP, XT or HS Mode) FIGURE 7-4: Ceramic Resonator Operation (XT or HS Mode) 7.2.1.3 Oscillator Start-up Timer (OST) 7.2.1.4 4x PLL 7.2.1.5 Secondary Oscillator FIGURE 7-5: Quartz Crystal Operation (Secondary Oscillator) 7.2.2 Internal Clock Sources 7.2.2.1 HFINTOSC 7.2.2.2 MFINTOSC 7.2.2.3 Internal Oscillator Frequency Adjustment 7.2.2.4 LFINTOSC 7.2.2.5 ADCRC 7.2.2.6 Oscillator Status and Manual Enable 7.2.2.7 HFOR and MFOR Bits 7.3 Clock Switching 7.3.1 New Oscillator Source (NOSC) and New Divider Selection Request (NDIV) Bits 7.3.2 Clock Switch and Sleep FIGURE 7-6: Clock Switch (CSWHOLD = 0) FIGURE 7-7: Clock Switch (CSWHOLD = 1) FIGURE 7-8: Clock Switch Abandoned 7.4 Fail-Safe Clock Monitor FIGURE 7-9: FSCM Block Diagram 7.4.1 Fail-Safe Detection 7.4.2 Fail-Safe Operation 7.4.3 Fail-Safe Condition Clearing 7.4.4 Reset or Wake-up from Sleep FIGURE 7-10: FSCM Timing Diagram TABLE 7-1: NOSC/COSC and NDIV/CDIV Bit Settings 7.5 Register Definitions: Oscillator Control Register 7-1: OSCCON1: Oscillator Control Register 1 TABLE 7-2: Default Oscillator Settings Register 7-2: OSCCON2: Oscillator Control Register 2 Register 7-3: OSCCON3: Oscillator Control Register 3 Register 7-4: OSCSTAT: Oscillator Status Register 1 Register 7-5: OSCFRQ: HFINTOSC Frequency Selection Register Register 7-6: OSCTUNE: HFINTOSC Tuning Register Register 7-7: OSCEN: Oscillator Manual Enable Register TABLE 7-3: Summary of Registers Associated with Clock Sources 8.0 Reference Clock Output Module FIGURE 8-1: Clock Reference Block Diagram FIGURE 8-2: Clock Reference Timing 8.1 Clock Source 8.1.1 Clock Synchronization 8.2 Programmable Clock Divider 8.3 Selectable Duty Cycle 8.4 Operation in Sleep Mode 8.5 Register Definitions: Reference Clock Register 8-1: CLKRCON: Reference Clock Control Register Register 8-2: CLKRCLK: Clock Reference Clock Selection MUX TABLE 8-1: Summary of Registers Associated with Clock Reference Output 9.0 Interrupt Controller 9.1 Interrupt Control and Status Registers 9.2 Interrupt Vector Table (IVT) 9.2.1 Interrupt Vector Table base address (IVTBASE) 9.2.2 Interrupt Vector Table Contents 9.2.3 Interrupt Vector Table (IVT) address calculation TABLE 9-1: IVT Address Calculation Summary 9.2.4 Access control for IVTBASE registers EXAMPLE 9-1: IVT Unlock Sequence EXAMPLE 9-2: IVT lock Sequence 9.3 Interrupt Priority 9.3.1 User (Software) priority 9.3.2 Natural Order (Hardware) Priority TABLE 9-2: Interrupt Vector Priority Table 9.4 Interrupt Operation FIGURE 9-1: Vectored Interrupts State Transition Diagram 9.4.1 Serving a high or low priority interrupt when main routine code is executing FIGURE 9-2: Interrupt Execution: High/Low Priority Interrupt When Executing Main Routine 9.4.2 Serving a high priority interrupt While a low priority interrupt pending FIGURE 9-3: Interrupt Execution: High Priority Interrupt with a Low Priority Interrupt Pending 9.4.3 Preempting Low Priority Interrupts FIGURE 9-4: Interrupt Execution: High Priority Interrupt Preempting Low Priority Interrupts 9.4.4 Simultaneous Low and High Priority Interrupts FIGURE 9-5: Interrupt Execution: Simultaneous Low and High Priority Interrupts 9.5 Context Saving 9.5.1 Accessing Shadow Registers FIGURE 9-6: Context Save State Machine Diagram 9.6 Returning from Interrupt Service Routine (ISR) 9.7 Interrupt Latency FIGURE 9-7: Interrupt Timing Diagram - One Cycle Instruction FIGURE 9-8: Interrupt Timing Diagram - Two Word Instruction FIGURE 9-9: Interrupt Timing Diagram - Three Cycle Instruction 9.7.1 Aborting Interrupts FIGURE 9-10: Interrupt Timing Diagram - Aborting Interrupts 9.8 Interrupt Setup Procedure 9.9 External Interrupt Pins 9.10 Wake-up from Sleep 9.11 Interrupt Compatibility EXAMPLE 9-3: Setting Up Vectored Interrupts Using MPASM EXAMPLE 9-4: Setting Up Vectored Interrupts Using XC8 9.12 Register Definitions: Interrupt Control Register 9-1: INTCON0: Interrupt Control Register 0 Register 9-2: INTCON1: Interrupt Control Register 1 Register 9-3: PIR0: Peripheral Interrupt Request Register 0 Register 9-4: PIR1: Peripheral Interrupt Request Register 1 Register 9-5: PIR2: Peripheral Interrupt Register 2(1) Register 9-6: PIR3: Peripheral Interrupt Register 3(1) Register 9-7: PIR4: Peripheral Interrupt Register 4(1) Register 9-8: PIR5: Peripheral Interrupt Register 5(1) Register 9-9: PIR6: Peripheral Interrupt Register 6(1) Register 9-10: PIR7: Peripheral Interrupt Register 7(1) Register 9-11: PIR8: Peripheral Interrupt Register 8(1) Register 9-12: PIR9: Peripheral Interrupt Register 9(1) Register 9-13: PIR10: Peripheral Interrupt Register 10(1) Register 9-14: PIE0: Peripheral Interrupt Enable Register 0 Register 9-15: PIE1: Peripheral Interrupt Enable Register 1 Register 9-16: PIE2: Peripheral Interrupt Enable Register 2 Register 9-17: PIE3: Peripheral Interrupt Enable Register 3 Register 9-18: PIE4: Peripheral Interrupt Enable Register 4 Register 9-19: PIE5: Peripheral Interrupt Enable Register 5 Register 9-20: PIE6: Peripheral Interrupt Enable Register 6 Register 9-21: PIE7: Peripheral Interrupt Enable Register 7 Register 9-22: PIE8: Peripheral Interrupt Enable Register 8 Register 9-23: PIE9: Peripheral Interrupt Enable Register 9 Register 9-24: PIE10: Peripheral Interrupt Enable Register 10 Register 9-25: IPR0: Peripheral Interrupt Priority Register 0 Register 9-26: IPR1: Peripheral Interrupt Priority Register 1 Register 9-27: IPR2: Peripheral Interrupt Priority Register 2 Register 9-28: IPR3: Peripheral Interrupt Priority Register 3 Register 9-29: IPR4: Peripheral Interrupt Priority Register 4 Register 9-30: IPR5: Peripheral Interrupt Priority Register 5 Register 9-31: IPR6: Peripheral Interrupt Priority Register 6 Register 9-32: IPR7: Peripheral Interrupt Priority Register 7 Register 9-33: IPR8: Peripheral Interrupt Priority Register 8 Register 9-34: IPR9: Peripheral Interrupt Priority Register 9 Register 9-35: IPR10: Peripheral Interrupt Priority Register 10 Register 9-36: IVTBASEU: Interrupt Vector Table Base Address Upper Register Register 9-37: IVTBASEH: Interrupt Vector Table Base Address High Register Register 9-38: IVTBASEL: Interrupt Vector Table Base Address Low Register Register 9-39: IVTADU: Interrupt Vector Table Address Upper Register Register 9-40: IVTADH: Interrupt Vector Table Address High Register Register 9-41: IVTADL: Interrupt Vector Table Address Low Register Register 9-42: IVTLOCK: Interrupt Vector Table Lock Register Register 9-43: SHADCON: Shadow Control Register TABLE 9-3: Summary of Registers Associated with Interrupts 10.0 Power-Saving Operation Modes 10.1 Doze Mode 10.1.1 Doze Operation 10.1.2 Interrupts During Doze TABLE 10-1: System Behavior for Interrupt During Doze EXAMPLE 10-1: Doze Software Example FIGURE 10-1: Doze Mode Operation Example (DOZE[2:0] = 001, 1:4) 10.2 Sleep Mode 10.2.1 Wake-up from Sleep 10.2.2 Wake-up Using Interrupts FIGURE 10-2: Wake-Up from Sleep through Interrupt 10.2.3 Low-Power Sleep Mode 10.2.3.1 Sleep Current vs. Wake-up Time 10.2.3.2 Peripheral Usage in Sleep 10.2.4 Idle Mode 10.2.4.1 Idle and Interrupts 10.2.4.2 Idle and WWDT 10.3 Peripheral Operation in Power Saving Modes 10.4 Register Definitions: Voltage Regulator Control Register 10-1: VREGCON: Voltage Regulator Control Register(1) Register 10-2: CPUDOZE: Doze and Idle Register TABLE 10-2: Summary of Registers Associated with Power-down Mode 11.0 Windowed Watchdog Timer (WWDT) FIGURE 11-1: Windowed Watchdog Timer Block Diagram 11.1 Independent Clock Source 11.2 WWDT Operating Modes 11.2.1 WWDT Is Always On 11.2.2 WWDT Is Off in Sleep 11.2.3 WWDT Controlled by Software TABLE 11-1: WWDT Operating Modes 11.3 Time-out Period 11.4 Watchdog Window 11.5 Clearing the WWDT 11.5.1 CLRWDT Considerations (Windowed Mode) 11.6 Operation During Sleep TABLE 11-2: WWDT Clearing Conditions FIGURE 11-2: Window Period and Delay 11.7 Register Definitions: Windowed Watchdog Timer Control Register 11-1: WDTCON0: Watchdog Timer Control Register 0 Register 11-2: WDTCON1: Watchdog Timer Control Register 1 Register 11-3: WDTPSL: WWDT Prescale Select Low Byte Register (Read-Only) Register 11-4: WDTPSH: WWDT Prescale Select High Byte Register (Read-Only) Register 11-5: WDTTMR: WDT Timer Register (Read-Only) TABLE 11-3: Summary of Registers Associated with Windowed Watchdog Timer TABLE 11-4: Summary of Configuration Word with Windowed Watchdog Timer 12.0 8x8 Hardware Multiplier 12.1 Introduction 12.2 Operation EXAMPLE 12-1: 8x8 Unsigned Multiply Routine EXAMPLE 12-2: 8x8 Signed Multiply Routine TABLE 12-1: Performance Comparison for Various Multiply Operations EQUATION 12-1: 16 x 16 Unsigned Multiplication Algorithm EXAMPLE 12-3: 16 x 16 Unsigned Multiply Routine EQUATION 12-2: 16 x 16 Signed Multiplication Algorithm EXAMPLE 12-4: 16 x 16 Signed Multiply Routine 13.0 Nonvolatile Memory (NVM) Control TABLE 13-1: NVM Organization and Access Information 13.1 Program Flash Memory 13.1.1 Table Reads and Table Writes FIGURE 13-1: Table Read Operation FIGURE 13-2: Table Write Operation 13.1.2 Control Registers 13.1.2.1 NVMCON1 and NVMCON2 Registers 13.1.2.2 TABLAT – Table Latch Register 13.1.2.3 TBLPTR – Table Pointer Register 13.1.2.4 Table Pointer Boundaries TABLE 13-2: Table Pointer Operations with TBLRD and TBLWT Instructions FIGURE 13-3: Table Pointer Boundaries Based on Operation 13.1.3 Reading the Program Flash Memory FIGURE 13-4: Reads from Program Flash Memory EXAMPLE 13-1: Reading a Program Flash Memory Word FIGURE 13-5: Program Flash Memory Read Flowchart 13.1.4 NVM Unlock Sequence FIGURE 13-6: NVM Unlock Sequence Flowchart EXAMPLE 13-2: NVM Unlock Sequence 13.1.5 Erasing Program Flash Memory 13.1.5.1 Program Flash Memory Erase Sequence EXAMPLE 13-3: Erasing a Program Flash Memory block FIGURE 13-7: PFM Row Erase Flowchart 13.1.6 Writing to Program Flash Memory FIGURE 13-8: Table Writes to Program Flash Memory 13.1.6.1 Program Flash Memory Write Sequence EXAMPLE 13-4: Writing to Program Flash Memory EXAMPLE 13-4: Writing to Program Flash Memory (Continued) FIGURE 13-9: Program Flash Memory (PFM) Write Flowchart 13.1.6.2 Write Verify FIGURE 13-10: Program Flash Memory Verify Flowchart 13.1.6.3 Unexpected Termination of Write Operation 13.1.6.4 Protection Against Spurious Writes 13.2 Device Information Area, Device Configuration Area, User ID, Device ID and Configuration Word Access 13.2.1 Reading Access 13.2.2 Writing Access TABLE 13-3: DIA, DCI, User ID, Dev/REV ID and Configuration Word Access (REG[1:0] = x1) 13.3 Data EEPROM Memory 13.3.1 NVMADRL and NVMADRH Registers 13.3.2 NVMCON1 and NVMCON2 Registers 13.3.3 Reading the Data EEPROM Memory FIGURE 13-11: Data EEPROM Read Flowchart 13.3.4 Writing to the Data EEPROM Memory 13.3.5 Write Verify EXAMPLE 13-5: Data EEPROM Read EXAMPLE 13-6: Data EEPROM Write 13.3.6 Operation During Code- Protect 13.3.7 Protection Against Spurious Write 13.3.8 Erasing the Data EEPROM Memory EXAMPLE 13-7: Data EEPROM Refresh Routine 13.4 Register Definitions: Nonvolatile Memory Register 13-1: NVMCON1: Nonvolatile Memory Control 1 Register Register 13-2: NVMCON2: Nonvolatile Memory Control 2 Register Register 13-3: NVMADRL: Data EEPROM Memory Address Low Register 13-4: NVMADRH: Data EEPROM Memory Address High(1) Register 13-5: NVMDAT: Data EEPROM Memory Data TABLE 13-4: Summary OF Registers Associated with Nonvolatile Memory Control 14.0 Cyclic Redundancy Check (CRC) Module with Memory Scanner 14.1 CRC Module Overview 14.2 CRC Functional Overview EXAMPLE 14-1: CRC Example 14.3 CRC Polynomial Implementation EXAMPLE 14-2: CRC LFSR Example 14.4 CRC Data Sources 14.4.1 CRC from User Data 14.4.2 CRC from Flash 14.5 CRC Check Value 14.6 CRC Interrupt 14.7 Configuring the CRC 14.8 Scanner Module Overview 14.9 Configuring the Scanner 14.10 Scanner Interrupt 14.11 Scanning Modes 14.11.1 TRIGEN = 0, BURSTMD = 0 14.11.2 TRIGEN = 1, BURSTMD = 0 14.11.3 TRIGEN = x, BURSTMD = 1 14.12 Register Definitions: CRC and Scanner Control Register 14-1: CRCCON0: CRC Control Register 0 Register 14-2: CRCCON1: CRC Control Register 1 Register 14-3: CRCDATH: CRC Data High Byte Register Register 14-4: CRCDATL: CRC Data Low Byte Register Register 14-5: CRCACCH: CRC Accumulator High Byte Register Register 14-6: CRCACCL: CRC Accumulator Low Byte Register Register 14-7: CRCSHIFTH: CRC Shift High Byte Register Register 14-8: CRCSHIFTL: CRC Shift Low Byte Register Register 14-9: CRCXORH: CRC XOR High Byte Register Register 14-10: CRCXORL: CRC XOR Low Byte Register Register 14-11: SCANCON0: Scanner Access Control Register 0 TABLE 14-1: Scanner Operating Modes(1) Register 14-12: SCANLADRU: Scan Low Address Upper Byte Register Register 14-13: SCANLADRH: SCAN Low Address High Byte Register Register 14-14: SCANLADRL: SCAN Low Address Low Byte Register Register 14-15: SCANHADRU: Scan High Address Upper Byte Register Register 14-16: SCANHADRH: SCAN High Address High Byte Register Register 14-17: SCANHADRL: SCAN High Address Low Byte Register Register 14-18: SCANTRIG: SCAN Trigger Selection Register TABLE 14-2: Summary of Registers Associated with CRC 15.0 Direct Memory Access (DMA) 15.1 Introduction 15.2 DMA Registers 15.3 DMA Organization FIGURE 15-1: DMA Functional Block Diagram 15.4 DMA Interface TABLE 15-1: DMA Memory Access 15.4.1 DMA Addressing FIGURE 15-2: DMA Pointers Block Diagram 15.4.2 DMA Message Size/Counters FIGURE 15-3: DMA Counters Block Diagram TABLE 15-2: Example Message Size Table 15.5 DMA Message Transfers TABLE 15-3: DMA Initial Conditions TABLE 15-4: DMA Source Pointer/Counter during Operation TABLE 15-5: DMA Destination Pointer/Counter during Operation 15.5.1 Starting DMA Message transfers 15.5.1.1 User Software Control 15.5.1.2 Hardware Trigger, SIRQ 15.5.2 Stopping DMA Message transfers 15.5.2.1 User Software Control 15.5.2.2 Hardware Trigger, AIRQ 15.5.2.3 Source Count Reload 15.5.2.4 Destination Count Reload 15.5.2.5 Clearing the Enable bit 15.5.3 Disable DMA Messages transfers upon completion 15.5.3.1 Clearing the SIRQEN bit 15.5.3.2 Source/Destination Stop 15.6 Types of Hardware Triggers 15.6.1 Edge TRIGGER Requests 15.6.2 Level TRIGGER Requests 15.7 Types of Data Transfers 15.8 DMA Interrupts 15.8.1 DMA Source Count Interrupt 15.8.2 DMA Destination Count Interrupt 15.8.3 Abort Interrupt 15.8.4 Overrun Interrupt 15.9 DMA Setup and Operation FIGURE 15-4: DMA Operation with hardware trigger 15.9.1 Source Stop FIGURE 15-5: GPR-GPR Transactions with Hardware Triggers, SSTP = 1 15.9.2 Destination Stop FIGURE 15-6: GPR-GPR Transactions with Hardware Triggers, DSTP = 1 15.9.3 Continuous Transfer FIGURE 15-7: GPR-GPR Transactions with Hardware Triggers, SSTP, DSTP = 0 15.9.4 Transfer from SFR to GPR FIGURE 15-8: SFR Space to GPR Space Transfer 15.9.5 Overrun Interrupt FIGURE 15-9: Overrun Interrupt 15.9.6 Abort trigger, Message Complete FIGURE 15-10: Abort at the End of Message 15.9.7 Abort trigger, Message In progress FIGURE 15-11: Abort during Message Transfer TABLE 15-6: Example DMA Use Case Table 15.10 Reset 15.11 Power Saving Mode Operation 15.11.1 Sleep Mode 15.11.2 Idle Mode 15.11.3 Doze Mode 15.11.4 Peripheral Module Disable 15.12 DMA Register Interfaces EXAMPLE 15-1: Setup DMA1 to move data from Program Flash Memory to UART1 Transmit Buffer using hardware triggers 15.13 Register definitions: DMA TABLE 15-7: Register and Bit Naming TABLE 15-2: DMAxSIRQ AND DMAxAIRQ Trigger Sources TABLE 15-3: Summary of Registers Associated with DMA 16.0 I/O Ports TABLE 16-1: Port Allocation Table for PIC18(L)F26/27/45/46/47/ 55/56/57K42 Devices FIGURE 16-1: Generic I/O Port Operation 16.1 I/O Priorities 16.2 PORTx Registers 16.2.1 Data Register EXAMPLE 16-1: Initializing PORTA 16.2.2 Direction Control 16.2.3 Analog Control 16.2.4 Open-Drain Control 16.2.5 Slew Rate Control 16.2.6 Input Threshold Control 16.2.7 Weak Pull-up Control 16.2.8 Edge Selectable Interrupt-on-Change 16.2.9 I2C Pad Control 16.3 PORTE Registers 16.3.1 PORTE on 40/44/48-Pin Devices EXAMPLE 16-2: Initializing PORTE 16.3.2 PORTE on 28-Pin Devices 16.3.3 RE3 Weak Pull-up 16.3.4 Interrupt-on-Change 16.4 Register Definitions: Port Control Register 16-1: PORTx: PORTx Register(1) TABLE 16-2: PORT Registers Register 16-2: TRISx: Tri-State Control Register TABLE 16-3: TRIS Registers Register 16-3: LATx: LATx Register(1) TABLE 16-4: LAT Registers Register 16-4: ANSELx: Analog Select Register TABLE 16-5: Analog Select PORT Registers Register 16-5: WPUx: Weak Pull-up Register TABLE 16-6: Weak Pull-Up Port Registers Register 16-6: ODCONx: Open-Drain Control Register TABLE 16-7: Open-Drain Control Registers Register 16-7: SLRCONx: Slew Rate Control Register TABLE 16-8: Slew Rate Control Registers Register 16-8: INLVLx: Input Level Control Register TABLE 16-9: Input Level Port Registers Register 16-9: RxyI2C: I2C PAD Rxy Control Register TABLE 16-10: I2C Pad Control Registers TABLE 16-11: Summary of Registers Associated with I/O 17.0 Peripheral Pin Select (PPS) Module 17.1 PPS Inputs 17.2 PPS Outputs FIGURE 17-1: Simplified PPS Block Diagram 17.3 Bidirectional Pins 17.4 PPS Lock EXAMPLE 17-1: PPS Lock sequence EXAMPLE 17-2: PPS Unlock sequence 17.5 PPS One-way Lock 17.6 Operation During Sleep 17.7 Effects of a Reset 17.8 Register Definitions: PPS Input Selection Register 17-1: xxxPPS: Peripheral xxx Input Selection TABLE 17-1: PPS Input Register Details Register 17-2: RxyPPS: Pin Rxy Output Source Selection Register TABLE 17-2: PPS Output Register Details Register 17-3: PPSLOCK: PPS Lock Register TABLE 17-3: Summary of Registers Associated with the PPS Module 18.0 Interrupt-on-Change 18.1 Enabling the Module 18.2 Individual Pin Configuration 18.3 Interrupt Flags 18.4 Clearing Interrupt Flags EXAMPLE 18-1: Clearing Interrupt Flags (PORTA Example) 18.5 Operation in Sleep FIGURE 18-1: Interrupt-on-Change Block Diagram (PORTA Example) 18.6 Register Definitions: Interrupt-on-Change Control Register 18-1: IOCxP: Interrupt-on-Change Positive Edge Register Example Register 18-2: IOCxN: Interrupt-on-Change Negative Edge Register Example Register 18-3: IOCxF: Interrupt-on-Change Flag Register Example TABLE 18-1: IOC Registers TABLE 18-2: Summary of Registers Associated with Interrupt-on-Change 19.0 Peripheral Module Disable (PMD) 19.1 Disabling a Module 19.2 Enabling a Module 19.3 Effects of a Reset 19.4 System Clock Disable 19.5 Register Definitions: Peripheral Module Disable Register 19-1: PMD0: PMD Control Register 0 Register 19-2: PMD1: PMD Control Register 1 Register 19-3: PMD2: PMD Control Register 2 Register 19-4: PMD3: PMD Control Register 3 Register 19-5: PMD4: PMD Control Register 4 Register 19-6: PMD5: PMD Control Register 5 Register 19-7: PMD6: PMD Control Register 6 Register 19-8: PMD7: PMD Control Register 7 TABLE 19-1: Summary of Registers Associated with Peripheral Module Disable 20.0 Timer0 Module FIGURE 20-1: Block Diagram of Timer0 20.1 Timer0 Operation 20.1.1 16-Bit Mode 20.1.1.1 Timer0 Reads and Writes in 16-Bit Mode 20.1.2 8-BIT Mode 20.1.3 Counter Mode 20.1.4 Timer Mode 20.1.5 Asynchronous Mode 20.1.6 Synchronous Mode 20.2 Clock Source Selection 20.2.1 Internal Clock Source 20.2.2 External Clock Source 20.3 Programmable Prescaler 20.4 Programmable Postscaler 20.5 Operation During Sleep 20.6 Timer0 Interrupts 20.7 Timer0 Output 20.8 Register Definitions: Timer0 Control Register 20-1: T0CON0: TIMER0 Control Register 0 Register 20-2: T0CON1: TIMER0 Control Register 1 Register 20-3: TMR0L: TIMER0 Count Register Register 20-4: TMR0H: TIMER0 Period Register TABLE 20-1: Summary of Registers Associated with TIMER0 21.0 Timer1/3/5 Module with Gate Control FIGURE 21-1: Timer1/3/5 Block Diagram 21.1 Timer1/3/5 Operation TABLE 21-1: Timer1/3/5 Enable Selections 21.2 Clock Source Selection 21.2.1 Internal Clock Source 21.2.2 External Clock Source 21.3 Timer1/3/5 Prescaler 21.4 Timer1/3/5 Operation in Asynchronous Counter Mode 21.4.1 Reading and Writing Timer1/3/ 5 in Asynchronous Counter Mode 21.5 Timer1/3/5 16-Bit Read/Write Mode FIGURE 21-2: Timer1/3/5 16-Bit Read/ Write Mode Block Diagram 21.6 Timer1/3/5 Gate 21.6.1 Timer1/3/5 Gate Enable TABLE 21-2: Timer1/3/5 Gate Enable Selections 21.6.2 Timer1/3/5 Gate Source Selection 21.6.3 Timer1/3/5 Gate Toggle Mode 21.6.4 Timer1/3/5 Gate Single-Pulse Mode 21.6.5 Timer1/3/5 Gate Value Status 21.6.6 Timer1/3/5 Gate Event Interrupt 21.7 Timer1/3/5 Interrupt 21.8 Timer1/3/5 Operation During Sleep 21.9 CCP Capture/Compare Time Base 21.10 CCP Special Event Trigger FIGURE 21-3: Timer1/3/5 Incrementing Edge FIGURE 21-4: Timer1/3/5 Gate Enable Mode FIGURE 21-5: Timer1/3/5 Gate Toggle Mode FIGURE 21-6: Timer1/3/5 Gate Single-Pulse Mode FIGURE 21-7: Timer1/3/5 Gate Single-Pulse and Toggle Combined Mode 21.11 Peripheral Module Disable 21.12 Register Definitions: Timer1/3/5 Register 21-1: TxCON: Timerx Control Register Register 21-2: TxGCON: Timerx Gate Control Register Register 21-3: TxCLK: Timerx Clock Register Register 21-4: TxGATE: Timerx Gate ISM Register Register 21-5: TMRxL: Timerx Low Byte Register Register 21-6: TMRxH: Timerx High Byte Register TABLE 21-3: Summary of Registers Associated with Timer1/3/5 as a Timer/Counter 22.0 Timer2/4/6 Module FIGURE 22-1: Timer2 Block Diagram FIGURE 22-2: Timer2 Clock Source Block Diagram 22.1 Timer2 Operation 22.1.1 Free Running Period Mode 22.1.2 One-Shot Mode 22.1.3 Monostable Mode 22.2 Timer2 Output 22.3 External Reset Sources TABLE 22-1: Timer2 Operating Modes 22.4 Timer2 Interrupt FIGURE 22-3: Timer2 Prescaler, Postscaler, and Interrupt Timing Diagram 22.5 Operation Examples 22.5.1 Software Gate Mode FIGURE 22-4: Software Gate Mode Timing Diagram 22.5.2 Hardware Gate Mode FIGURE 22-5: Hardware Gate Mode Timing Diagram (MODE = 00001) 22.5.3 Edge-Triggered Hardware Limit Mode FIGURE 22-6: Edge Triggered Hardware Limit Mode Timing Diagram (MODE=00100) 22.5.4 Level-Triggered Hardware Limit Mode FIGURE 22-7: Level Triggered Hardware Limit Mode Timing Diagram (MODE = 00111) 22.5.5 Software Start One-Shot Mode FIGURE 22-8: Software Start One-shot Mode Timing Diagram (MODE = 01000) 22.5.6 Edge-Triggered One-Shot Mode FIGURE 22-9: Edge Triggered One-Shot Mode Timing Diagram (MODE = 01001) 22.5.7 Edge-Triggered Hardware Limit One-Shot Mode FIGURE 22-10: Edge Triggered Hardware Limit One-Shot Mode Timing Diagram (MODE = 01100)) 22.5.8 Level Reset, Edge-Triggered Hardware Limit One-Shot Modes FIGURE 22-11: Low Level Reset, Edge-Triggered hardware Limit one-Shot Mode Timing Diagram (MODE = 01110) 22.5.9 Edge-Triggered Monostable Modes FIGURE 22-12: Rising Edge-Triggered Monostable Mode Timing Diagram (MODE = 10001) 22.5.10 Level-Triggered Hardware Limit One-Shot Modes FIGURE 22-13: Level-Triggered hardware Limit one-Shot Mode Timing Diagram (MODE = 10110) 22.6 Timer2 Operation During Sleep 22.7 Register Definitions: Timer2/4/6 Control TABLE 22-2: Operating Modes Register 22-1: TxCLK: Timerx Clock Selection Register Register 22-2: TxRST: Timer2 External Reset Signal Selection Register Register 22-3: TxTMR: Timerx Counter Register Register 22-4: TxPR: Timerx Period Register Register 22-5: TxCON: Timerx Control Register Register 22-6: TxHLT: Timerx Hardware Limit Control Register TABLE 22-3: Summary of Registers Associated with Timer2 23.0 Capture/Compare/PWM Module 23.1 CCP Module Configuration 23.1.1 CCP Modules and Timer Resources TABLE 23-1: CCP Mode – Timer Resource 23.1.2 Open-Drain Output Option 23.2 Capture Mode 23.2.1 Capture Sources 23.2.2 Timer1 Mode Resource FIGURE 23-1: Capture Mode Operation Block Diagram 23.2.3 Software Interrupt Mode 23.2.4 Capture During Sleep 23.3 Compare Mode FIGURE 23-2: Compare Mode Operation Block Diagram 23.3.1 CCPx Pin Configuration 23.3.2 Timer1 Mode Resource 23.3.3 Auto-Conversion Trigger 23.3.4 Compare During Sleep 23.4 PWM Overview 23.4.1 Standard PWM Operation FIGURE 23-3: CCP PWM Output Signal FIGURE 23-4: Simplified PWM Block Diagram 23.4.2 Setup for PWM Operation 23.4.3 Timer2 Timer Resource 23.4.4 PWM Period EQUATION 23-1: PWM Period 23.4.5 PWM Duty Cycle FIGURE 23-5: PWM 10-Bit Alignment EQUATION 23-2: Pulse Width EQUATION 23-3: Duty Cycle Ratio 23.4.6 PWM Resolution EQUATION 23-4: PWM Resolution TABLE 23-2: Example PWM Frequencies and Resolutions (Fosc = 20 MHz) TABLE 23-3: Example PWM Frequencies and Resolutions (Fosc = 8 MHz) 23.4.7 Operation in Sleep Mode 23.4.8 Changes in System Clock Frequency 23.4.9 Effects of Reset 23.5 Register Definitions: CCP Control Register 23-1: CCPxCON: CCPx Control Register Register 23-2: CCPTMRS0: CCP Timers Control Register 0 Register 23-3: CCPxCAP: Capture Input Selection Multiplexer Register Register 23-4: CCPRxL: CCPx Register Low Byte Register 23-5: CCPRxH: CCPx Register High Byte TABLE 23-4: Summary of Registers Associated with CCPx 24.0 Pulse-Width Modulation (PWM) FIGURE 24-1: Simplified PWM Block Diagram FIGURE 24-2: PWM Output 24.1 PWMx Pin Configuration 24.1.1 Fundamental Operation 24.1.2 PWM Output Polarity 24.1.3 PWM Period EQUATION 24-1: PWM Period 24.1.4 PWM Duty Cycle EQUATION 24-2: Pulse Width EQUATION 24-3: Duty Cycle Ratio 24.1.5 PWM Resolution EQUATION 24-4: PWM Resolution TABLE 24-1: Example PWM Frequencies and Resolutions (Fosc = 20 MHz) TABLE 24-2: Example PWM Frequencies and Resolutions (Fosc = 8 MHz) 24.1.6 Operation in Sleep Mode 24.1.7 Changes in System Clock Frequency 24.1.8 Effects of Reset 24.1.9 Setup for PWM Operation using PWMx Pins 24.1.10 Setup for PWM Operation to Other Device Peripherals 24.2 Register Definitions: PWM Control Register 24-1: PWMxCON: PWM Control Register Register 24-2: CCPTMRS1: CCP Timers Control Register 1 Register 24-3: PWMXDCH: PWM Duty Cycle High Bits Register 24-4: PWMxDCL: PWM Duty Cycle Low Bits TABLE 24-3: Summary of Registers Associated with PWM 25.0 Signal Measurement Timer (SMT) FIGURE 25-1: SMT Block Diagram FIGURE 25-2: SMT Signal and Window Block Diagram 25.1 SMT Operation 25.1.1 Clock Sources 25.1.2 Period Match interrupt 25.2 Basic Timer Function Registers 25.2.1 Time Base 25.2.2 Pulse-Width Latch registers 25.2.3 Period Latch registers 25.3 Halt Operation 25.4 Polarity Control 25.5 Status Information 25.5.1 Window Status 25.5.2 Signal Status 25.5.3 GO Status 25.6 Modes of Operation 25.6.1 Timer Mode TABLE 25-1: Modes of Operation FIGURE 25-3: Timer Mode Timing Diagram 25.6.2 Gated Timer Mode FIGURE 25-4: Gated Timer Mode Repeat Acquisition Timing Diagram FIGURE 25-5: Gated Timer Mode Single Acquisition Timing Diagram 25.6.3 Period and Duty Cycle Mode FIGURE 25-6: Period And Duty-Cycle Repeat Acquisition Mode Timing Diagram FIGURE 25-7: Period And Duty-Cycle Single Acquisition Timing Diagram 25.6.4 High and Low Measure Mode FIGURE 25-8: High and Low Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-9: High and Low Measure Mode Single Acquisition Timing Diagram 25.6.5 Windowed Measure Mode FIGURE 25-10: Windowed Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-11: Windowed Measure Mode Single Acquisition Timing Diagram 25.6.6 Gated Windowed Measure Mode FIGURE 25-12: Gated Windowed Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-13: Gated Windowed Measure Mode Single Acquisition Timing Diagrams 25.6.7 Time of Flight Measure Mode FIGURE 25-14: Time Of Flight Mode Repeat Acquisition Timing Diagram FIGURE 25-15: Time Of Flight Mode Single Acquisition Timing Diagram 25.6.8 Capture Mode FIGURE 25-16: Capture Mode Repeat Acquisition Timing Diagram FIGURE 25-17: Capture Mode Single Acquisition Timing Diagram 25.6.9 Counter Mode FIGURE 25-18: Counter Mode Timing Diagram 25.6.10 Gated Counter Mode FIGURE 25-19: Gated Counter Mode Repeat Acquisition Timing Diagram FIGURE 25-20: Gated Counter Mode Single Acquisition Timing Diagram 25.6.11 Windowed Counter Mode FIGURE 25-21: Windowed Counter Mode Repeat Acquisition Timing Diagram FIGURE 25-22: Windowed Counter Mode Single Acquisition Timing Diagram 25.7 Interrupts 25.7.1 PW and PR Acquisition interrupts 25.7.2 Counter Period Match interrupt 25.8 Register Definitions: SMT Control TABLE 25-2: Long Bit Names Prefixes for SMT Peripherals Register 25-1: SMT1CON0: SMT Control Register 0 Register 25-2: SMT1CON1: SMT Control Register 1 Register 25-3: SMT1STAT: SMT Status Register Register 25-4: SMT1CLK: SMT Clock Selection Register Register 25-5: SMT1WIN: SMT1 Window Input Select Register Register 25-6: SMT1SIG: SMT1 Signal Input Select Register Register 25-7: SMT1TMRL: SMT Timer Register – Low Byte Register 25-8: SMT1TMRH: SMT Timer Register – High Byte Register 25-9: SMT1TMRU: SMT Timer Register – Upper Byte Register 25-10: SMT1CPRL: SMT Captured Period Register – Low Byte Register 25-11: SMT1CPRH: SMT Captured Period Register – High Byte Register 25-12: SMT1CPRU: SMT Captured Period Register – Upper Byte Register 25-13: SMT1CPWL: SMT Captured Pulse Width Register – Low Byte Register 25-14: SMT1CPWH: SMT Captured Pulse Width Register – High Byte Register 25-15: SMT1CPWU: SMT Captured Pulse Width Register – Upper Byte Register 25-16: SMT1PRL: SMT Period Register – Low Byte Register 25-17: SMT1PRH: SMT Period Register – High Byte Register 25-18: SMT1PRU: SMT Period Register – Upper Byte TABLE 25-3: Summary of Registers Associated with SMT1 26.0 Complementary Waveform Generator (CWG) Module 26.1 Fundamental Operation 26.2 Operating Modes 26.2.1 Half-Bridge Mode FIGURE 26-1: Simplified CWG Block Diagram (Half-Bridge Mode, MODE[2:0] = 100) FIGURE 26-2: CWGx Half-Bridge Mode Operation 26.2.2 Push-Pull Mode FIGURE 26-3: Simplified CWG Block Diagram (Push-Pull Mode, MODE[2:0] = 101) FIGURE 26-4: CWGx Push-Pull Mode Operation 26.2.3 Full-Bridge Modes FIGURE 26-5: Example of Full-Bridge Application FIGURE 26-6: Simplified CWG Block Diagram (Forward and Reverse Full-Bridge Modes) FIGURE 26-7: Example of Full-Bridge Output 26.2.3.1 Direction Change in Full-Bridge Mode 26.2.3.2 Dead-Band Delay in Full-Bridge Mode FIGURE 26-8: Example of PWM Direction Change at Near 100% Duty Cycle 26.2.4 Steering Modes 26.2.4.1 Synchronous Steering Mode FIGURE 26-9: Example of Synchronous Steering (MODE[2:0] = 001) 26.2.4.2 Asynchronous Steering Mode FIGURE 26-10: Example of Asynchronous Steering (MODE[2:0] = 000) 26.2.4.3 Start-up Considerations FIGURE 26-11: Simplified CWG Block Diagram (Output Steering Modes) 26.3 Clock Source 26.4 Selectable Input Sources TABLE 26-1: Selectable Input Sources 26.5 Output Control 26.5.1 CWG Outputs 26.5.2 Polarity Control 26.6 Dead-Band Control 26.6.1 Dead-Band Functionality in Half-Bridge mode 26.6.2 Dead-Band Functionality in Full-Bridge mode 26.7 Rising Edge and Reverse Dead Band 26.8 Falling Edge and Forward Dead Band FIGURE 26-12: Dead-Band Operation, CWGxDBR = 0x01, CWGxDBF = 0x02 FIGURE 26-13: Dead-Band Operation, CWGxDBR = 0x03, CWGxDBF = 0x06, Source Shorter Than Dead Band 26.9 Dead-Band Jitter EQUATION 26-1: Dead-Band Delay Time Calculation 26.10 Auto-Shutdown 26.10.1 Shutdown 26.10.1.1 Software Generated Shutdown 26.10.1.2 External Input Source 26.10.1.3 Pin Override Levels 26.10.1.4 Auto-Shutdown Interrupts 26.11 Auto-Shutdown Restart 26.11.1 Software-Controlled Restart 26.11.2 Auto-Restart 26.12 Operation During Sleep 26.13 Configuring the CWG FIGURE 26-14: CWG Shutdown Block Diagram FIGURE 26-15: Shutdown Functionality, Auto-Restart Disabled (REN = 0, LSAC = 01, LSBD = 01) FIGURE 26-16: Shutdown Functionality, Auto-Restart Enabled (REN = 1, LSAC = 01, LSBD = 01) 26.14 Register Definitions: CWG Control Register 26-1: CWGxCON0: CWG Control Register 0 Register 26-2: CWGxCON1: CWG Control Register 1 Register 26-3: CWGxCLK: CWGx Clock Input Selection Register Register 26-4: CWGxISM: CWGx Input Selection Register Register 26-5: CWGxSTR(1): CWG Steering Control Register Register 26-6: CWGxAS0: CWG Auto-Shutdown Control Register 0 Register 26-7: CWGxAS1: CWG Auto-Shutdown Control Register 1 Register 26-8: CWGxDBR: CWG Rising Dead-Band Count Register Register 26-9: CWGxDBF: CWG Falling Dead-Band Count Register TABLE 26-2: Summary of Registers Associated with CWG 27.0 Configurable Logic Cell (CLC) FIGURE 27-1: CLCx Simplified Block Diagram 27.1 CLCx Setup 27.1.1 Data Selection TABLE 27-1: CLCx Data Input Selection 27.1.2 Data Gating TABLE 27-2: Data Gating Logic 27.1.3 Logic Function 27.1.4 Output Polarity 27.2 CLCx Interrupts 27.3 Output Mirror Copies 27.4 Effects of a Reset 27.5 Operation During Sleep 27.6 CLCx Setup Steps FIGURE 27-2: Input Data Selection and Gating FIGURE 27-3: Programmable Logic Functions 27.7 Register Definitions: CLC Control Register 27-1: CLCxCON: Configurable Logic Cell Control Register Register 27-2: CLCxPOL: Signal Polarity Control Register Register 27-3: CLCxSEL0: Generic CLCx Data 0 Select Register Register 27-4: CLCxSEL1: Generic CLCx Data 1 Select Register Register 27-5: CLCxSEL2: Generic CLCx Data 2 Select Register Register 27-6: CLCxSEL3: Generic CLCx Data 3 Select Register Register 27-7: CLCxGLS0: Gate 0 Logic Select Register Register 27-8: CLCxGLS1: Gate 1 Logic Select Register Register 27-9: CLCxGLS2: Gate 2 Logic Select Register Register 27-10: CLCxGLS3: Gate 3 Logic Select Register Register 27-11: CLCDATA: CLC Data Output TABLE 27-3: Summary of Registers Associated with CLCx 28.0 Numerically Controlled Oscillator (NCO) Module FIGURE 28-1: Direct Digital Synthesis Module Simplified Block Diagram 28.1 NCO Operation EQUATION 28-1: NCO Overflow Frequency 28.1.1 NCO CLOCK SOURCES 28.1.2 ACCUMULATOR 28.1.3 ADDER 28.1.4 INCREMENT REGISTERS 28.2 FIXED DUTY CYCLE MODE 28.3 PULSE FREQUENCY MODE 28.3.1 OUTPUT PULSE-WIDTH CONTROL 28.4 OUTPUT POLARITY CONTROL 28.5 Interrupts 28.6 Effects of a Reset 28.7 Operation in Sleep FIGURE 28-2: FDC Output Mode Operation Diagram 28.8 NCO Control Registers Register 28-1: NCO1CON: NCO Control Register Register 28-2: NCO1CLK: NCO1 Input Clock Control Register Register 28-3: NCO1ACCL: NCO1 Accumulator Register – Low Byte Register 28-4: NCO1ACCH: NCO1 Accumulator Register – High Byte Register 28-5: NCO1ACCU: NCO1 Accumulator Register – Upper Byte(1) Register 28-6: NCO1INCL: NCO1 Increment Register – Low Byte(1,2) Register 28-7: NCO1INCH: NCO1 Increment Register – High Byte(1) Register 28-8: NCO1INCU: NCO1 Increment Register – Upper Byte(1) TABLE 28-1: Summary of Registers Associated with NCO 29.0 Zero-Cross Detection (ZCD) Module 29.1 External Resistor Selection EQUATION 29-1: External Resistor FIGURE 29-1: External Voltage FIGURE 29-2: Simplified ZCD Block Diagram 29.2 ZCD Logic Output 29.3 ZCD Logic Polarity 29.4 ZCD Interrupts 29.5 Correcting for Vcpinv offset EQUATION 29-2: ZCD Event Offset EQUATION 29-3: ZCD Pull-up/down EQUATION 29-4: Pull-up/down Resistor Values 29.6 Handling Vpeak Variations EQUATION 29-5: Series R for V range 29.7 Operation During Sleep 29.8 Effects of a Reset 29.9 Disabling the ZCD Module 29.10 Register Definitions: ZCD Control Register 29-1: ZCDCON: Zero-Cross Detect Control Register TABLE 29-1: Summary of Registers Associated with the ZCD Module 30.0 Data Signal Modulator (DSM) Module FIGURE 30-1: Simplified Block Diagram of the Data Signal Modulator 30.1 DSM Operation 30.2 Modulator Signal Sources 30.3 Carrier Signal Sources 30.4 Carrier Synchronization FIGURE 30-2: On Off Keying (OOK) Synchronization FIGURE 30-3: No Synchronization (CHSYNC = 0, CLSYNC = 0) FIGURE 30-4: Carrier High Synchronization (CHSYNC = 1, CLSYNC = 0) FIGURE 30-5: Carrier Low Synchronization (CHSYNC = 0, CLSYNC = 1) FIGURE 30-6: Full Synchronization (CHSYNC = 1, CLSYNC = 1) 30.5 Carrier Source Polarity Select 30.6 Programmable Modulator Data 30.7 Modulated Output Polarity 30.8 Operation in Sleep Mode 30.9 Effects of a Reset 30.10 Peripheral Module Disable 30.11 Register Definitions: Modulation Control Register 30-1: MD1CON0: Modulation Control Register 0 Register 30-2: MD1CON1: Modulation Control Register 1 Register 30-3: MD1CARH: Modulation High Carrier Control Register Register 30-4: MD1CARL: Modulation Low Carrier Control Register TABLE 30-1: MD1CARH/MD1CARL Selection MUX Connections Register 30-5: MD1SRC: Modulation Source Control Register TABLE 30-2: MD1SRC Selection MUX Connections TABLE 30-3: Summary of Registers Associated with Data Signal Modulator Mode 31.0 Universal Asynchronous Receiver Transmitter (UART) With Protocol Support FIGURE 31-1: UART Transmit Block Diagram FIGURE 31-2: UART Receive Block Diagram 31.1 UART I/O Pin Configuration 31.2 UART Asynchronous Modes 31.2.1 UART Asynchronous Transmitter 31.2.1.1 Enabling the Transmitter 31.2.1.2 Transmitting Data 31.2.1.3 Transmit Data Polarity 31.2.1.4 Transmit Interrupt Flag 31.2.1.5 TSR Status 31.2.1.6 Transmitter 7-bit Mode 31.2.1.7 Transmitter Parity Modes 31.2.1.8 Asynchronous Transmission Setup FIGURE 31-3: Asynchronous Transmission FIGURE 31-4: Asynchronous Transmission (Back-to-Back) 31.2.2 UART Asynchronous Receiver 31.2.2.1 Enabling the Receiver 31.2.2.2 Receiving Data 31.2.2.3 Receive Interrupts 31.2.2.4 Receive Framing Error 31.2.2.5 Receiver Parity Modes 31.2.2.6 Receive FIFO Overflow 31.2.2.7 Asynchronous Reception Setup FIGURE 31-5: Asynchronous Reception 31.3 Asynchronous Address Mode 31.3.1 Address Mode Transmit 31.3.2 Address Mode Receive 31.4 DMX Mode (UART1 only) 31.4.1 DMX Controller 31.4.2 DMX Receiver FIGURE 31-6: DMX Transmit Sequence 31.5 LIN Modes (UART1 only) 31.5.1 LIN Master/Slave Mode 31.5.2 LIN Slave Mode 31.5.2.1 LIN Slave Receiver 31.5.2.2 LIN Slave Transmitter 31.6 DALI Mode (UART1 only) 31.6.1 Control Device 31.6.2 Control Gear FIGURE 31-7: Manchester Timing FIGURE 31-8: DALI Frame Timing FIGURE 31-9: DALI Forward/Back Frame Timing 31.7 General Purpose Manchester (UART1 only) 31.8 Polarity 31.9 Stop Bits 31.9.1 Delayed UxRXIF 31.10 Operation after FIFO overflow 31.11 Receive and Transmit Buffers 31.11.1 FIFO status 31.11.2 FIFO Reset 31.12 Flow Control 31.12.1 Hardware Flow Control FIGURE 31-10: Flow Control 31.12.2 RS-485 Transceiver control FIGURE 31-11: RS-485 Configuration 31.12.3 XON/XOFF Flow Control 31.13 Checksum (UART1 only) 31.13.1 Transmit Checksum Method 31.13.2 Receive Checksum Method 31.14 Collision Detection 31.15 RX/TX Activity Timeout 31.16 Clock Accuracy with Asynchronous Operation 31.17 UART Baud Rate Generator (BRG) EXAMPLE 31-1: Calculating Baud Rate Error TABLE 31-1: Baud Rate Formulas 31.17.1 Auto-Baud Detect TABLE 31-2: BRG Counter Clock Rates FIGURE 31-12: Automatic Baud Rate Calibration 31.17.2 Auto-Baud Overflow 31.17.3 Auto-Wake-up on Break 31.17.3.1 Special Considerations FIGURE 31-13: Auto-Wake-up Bit (WUE) Timing During Normal Operation FIGURE 31-14: Auto-Wake-up Bit (WUE) Timings During Sleep 31.18 Transmitting a Break 31.19 Receiving a Break 31.20 UART Operation During Sleep FIGURE 31-15: Send Break Character Sequence 31.21 Register Definitions: UART Control Register 31-1: UxCON0: UART Control Register 0 Register 31-2: UxCON1: UART Control Register 1 Register 31-3: UxCON2: UART Control Register 2 Register 31-4: UxERRIR: UART Error Interrupt Flag Register Register 31-5: UxERRIE: UART Error Interrupt Enable Register Register 31-6: UxUIR: UART General Interrupt Register Register 31-7: UxFIFO: UART FIFO Status Register Register 31-8: UxBRGL: UART Baud Rate Generator Low Register Register 31-9: UxBRGH: UART Baud Rate Generator High Register Register 31-10: UxRXB: UART Receive Register Register 31-11: UxTXB: UART Transmit Register Register 31-12: UxP1H: UART Parameter 1 High Register Register 31-13: UxP1L: UART Parameter 1 Low Register Register 31-14: UxP2H: UART Parameter 2 High Register Register 31-15: UxP2L: UART Parameter 2 Low Register Register 31-16: UxP3H: UART Parameter 3 High Register Register 31-17: UxP3L: UART Parameter 3 Low Register Register 31-18: UxTXCHK: UART Transmit Checksum Result Register Register 31-19: UxRXCHK: UART Receive Checksum Result Register TABLE 31-3: Summary of Registers Associated with the UART 32.0 Serial Peripheral Interface (SPI) Module 32.1 SPI Module Overview FIGURE 32-1: SPI Module Simplified Block Diagram FIGURE 32-2: SPI Master/Slave Connection With FIFOs 32.2 SPI REGISTERS 32.3 SPI MODE OPERATION 32.3.1 Enabling and Disabling the SPI module 32.3.2 BUSY bit 32.3.3 Transmit and Receive FIFOs 32.3.4 LSb vs. MSb-first operation 32.3.5 Input and Output Polarity Bits 32.4 Transfer Counter 32.4.1 Total Bit Count Mode (BMODE = 0) 32.4.2 Variable Transfer Size Mode (BMODE = 1) 32.4.3 Transfer Counter in Slave mode 32.5 Master mode TABLE 32-1: Master Mode TXR/RXR Settings 32.5.1 Full Duplex Mode FIGURE 32-3: SPI Master Operation – Data Exchange, TXR/RXR = 1/1 32.5.2 Transmit Only Mode FIGURE 32-4: SPI Master Operation, Command+Write Data, TXR/RXR=1/0 32.5.3 Receive Only Mode FIGURE 32-5: SPI Master Operation, Command+Read Data, TXR/RXR=0/1 32.5.4 Transfer Off Mode 32.5.5 Master Mode Slave Select Control 32.5.5.1 Hardware Slave Select Control FIGURE 32-6: SPI Master SS Operation- CKE = 0, BMODE = 1, TCWIDTH = 0, SSP = 0 32.5.5.2 Software Slave Select Control 32.5.6 Master Mode SPI Clock Configuration 32.5.6.1 SPI Clock Selection EQUATION 32-1: Frequency of SCK Output Signal 32.5.6.2 CKE, CKP and SMP FIGURE 32-7: Clocking Detail-Master Mode, CKE/SMP = 0/0 FIGURE 32-8: Clocking Detail - Master Mode, CKE/SMP = 1/1 FIGURE 32-9: Clocking Detail-Master Mode, CKE = 0, SMP = 1 FIGURE 32-10: Clocking Detail-Master Mode, CKE = 1, SMP = 0 32.5.6.3 SCK Start-Up Delay 32.6 Slave Mode 32.6.1 Slave Mode Transmit options 32.6.1.1 SDO Drive/Tri-state 32.6.1.2 SDO Output Data TABLE 32-2: Slave Mode Transmit 32.6.2 Slave Mode Receive Options FIGURE 32-11: SPI Slave Mode Operation – Interrupt-Driven, Master Writes 2+3 Bytes 32.6.3 Slave Mode Slave Select 32.6.4 Slave Mode Clock Configuration 32.6.5 Daisy-Chain Configuration FIGURE 32-12: Traditional SPI Daisy-Chain Connection FIGURE 32-13: SPI Daisy-Chain Connection with Chained SCK 32.7 SPI Operation in Sleep Mode 32.8 SPI Interrupts 32.8.1 SPI Receiver data interrupt 32.8.2 SPI Transmitter Data Interrupt 32.8.3 SPI Module Status Interrupts 32.8.3.1 Shift Register Empty Interrupt 32.8.3.2 Transfer Counter is Zero Interrupt 32.8.3.3 Start of Slave Select and End of Slave Select Interrupts FIGURE 32-14: Transfer and Slave Select Interrupt timings 32.8.3.4 Receiver Overflow and Transmitter Underflow Interrupts 32.9 Register definitions: SPI Register 32-1: SPIxINTF: SPI INTERRUPT FLAG REGISTER Register 32-2: SPIxINTE: SPI INTERRUPT ENABLE REGISTER Register 32-3: SPIxTCNTL – SPI TRANSFER COUNTER LSB REGISTER Register 32-4: SPIxTCNTH: SPI TRANSFER COUNTER MSB REGISTER Register 32-5: SPIxTWIDTH: SPI TRANSFER WIDTH REGISTER Register 32-6: SPIxBAUD: SPI BAUD RATE REGISTER Register 32-7: SPIxCON0: SPI CONFIGURATION REGISTER 0 Register 32-8: SPIxCON1: SPI CONFIGURATION REGISTER 1 Register 32-9: SPIxCON2: SPI CONFIGURATION REGISTER 2 Register 32-10: SPIxSTATUS: SPI Status Register Register 32-11: SPIxRXB: SPI Read Buffer Register Register 32-12: SPIxTxB: SPI Transmit Buffer Register Register 32-13: SPIxCLK: SPI Clock Selection Register TABLE 32-3: Summary of Registers Associated with SPI 33.0 I2C Module FIGURE 33-1: I2C Module Block Diagram 33.1 I2C Features 33.2 I2C Module Overview FIGURE 33-2: I2C Master/Slave Connections 33.3 I2C Mode Operation 33.3.1 Definition of I2C Terminology TABLE 33-1: I2C BUS TERMS 33.3.2 Byte Format 33.3.3 SDA and SCL pins 33.3.4 SDA Hold Time 33.3.5 Start Condition 33.3.6 Stop Condition FIGURE 33-3: Start and Stop Conditions 33.3.7 Restart Condition FIGURE 33-4: Restart Condition 33.3.8 Acknowledge Sequence 33.3.9 Bus Time-Out 33.3.10 Address Buffers TABLE 33-2: Address Buffer Direction as per I2C Mode 33.3.10.1 Slave Mode (7-bit) 33.3.10.2 Slave Mode (10-bit) 33.3.10.3 Master Mode (7-bit) 33.3.10.4 Master Mode (10-bit) 33.3.10.5 Multi-Master Mode (7-bit only) 33.3.11 Receive and Transmit Buffer 33.3.12 Clock Stretching 33.3.12.1 Clock Stretching for Buffer Operations 33.3.12.2 Clock Stretching for Other Slave Operations 33.3.13 Data Byte Count 33.4 I2C Slave Mode 33.4.1 Slave Addressing Modes 33.4.1.1 7-bit Addresses Mode 33.4.1.2 7-bit Addresses with Masking 33.4.1.3 10-bit Addresses 33.4.1.4 10-bit Address with Masking 33.4.2 General Call Address Support FIGURE 33-5: Slave Mode General Call Address Sequence 33.4.3 Slave Operation in 7-bit Addressing Mode 33.4.3.1 Slave Reception (7-bit Addressing Mode) FIGURE 33-6: I2C Slave, 7-Bit Address, Reception (ACKTIE = 0, ADRIE = 0, WRIE = 0) FIGURE 33-7: I2C Slave, 7-Bit Address, Reception With I2CxCNT (ACKTIE = 1, ADRIE = 0, WRIE = 0) FIGURE 33-8: I2C Slave, 7-Bit Address, Reception (ACKTIE = 0, ADRIE = 1, WRIE = 1) 33.4.3.2 Slave Transmission (7-bit Addressing Mode) FIGURE 33-9: I2C Slave, 7-Bit Address, Transmission FIGURE 33-10: I2C Slave, 7-Bit Address, Transmission (No Clock Stretching) 33.4.3.3 Slave operation in 10-bit Addressing Mode 33.4.3.4 Slave Reception (10-bit Addressing Mode) FIGURE 33-11: I2C Slave, 10-Bit Address, Reception With Stop (ADB = 1) 33.4.3.5 Slave Transmission (10-bit Addressing Mode) FIGURE 33-12: I2C Slave, 10-Bit Address, Transmission 33.5 I2C Master Mode 33.5.1 I2C Master Mode Operation 33.5.1.1 Master Transmitter 33.5.1.2 Master Receiver 33.5.2 Master Clock Source and Arbitration 33.5.3 Bus Free Time 33.5.4 Master Clock Timing 33.5.4.1 Clock Timing with FME = 0 FIGURE 33-13: Clock Synthesis Timing (FME = 0) 33.5.4.2 Clock Timing with FME = 1 FIGURE 33-14: Clock Synthesis Timing (FME = 1) 33.5.5 I2C Master Mode Start Condition Timing FIGURE 33-15: Start Condition Timing 33.5.6 I2C Master Mode Repeated Start Condition Timing FIGURE 33-16: Repeated Start Condition Timing 33.5.7 Acknowledge Sequence Timing FIGURE 33-17: Acknowledge Sequence Timing 33.5.8 Stop Condition Timing FIGURE 33-18: Stop Condition during Receive or Transmit 33.5.9 Master Transmission in 7-bit Addressing Mode FIGURE 33-19: I2C Master, 7-Bit Address, Transmission 33.5.10 Master Reception in 7-bit Addressing Mode FIGURE 33-20: I2C Master, 7-Bit Address, Reception 33.5.11 Master Transmission in 10-bit Addressing Mode FIGURE 33-21: I2C Master, 10-Bit Address, Transmission 33.5.12 Master Reception in 10-bit Addressing Mode FIGURE 33-22: I2C Master, 10-Bit Address, Reception (Using RSEN Bit) 33.6 I2C Multi-Master Mode 33.6.1 Multi-Master Mode Bus Collision FIGURE 33-23: Bus Collision Timing for Transmit and Acknowledge FIGURE 33-24: I2C Multi-Master, 7-Bit Address, Write (ADRIE = 1, WRIE = 0) 33.7 Register Definitions: I2C Control Register 33-1: I2CxCon0: I2C Control register 0 Register 33-2: I2CxCon1: I2C Control register 1 Register 33-3: I2CxCon2: I2C Control register 2 Register 33-4: I2CxCLK: I2C Clock Selection Register Register 33-5: I2CxBTO: I2C Bus Timeout Selection Register Register 33-6: I2CxSTAT0: I2C STATUS REGISTER 0 Register 33-7: I2CxSTAT1: I2C STATUS REGISTER 1 Register 33-8: I2CxERR: I2C Error REGISTER Register 33-9: I2CxCNT: I2C Byte Count REGISTER Register 33-10: I2CxPIR: I2CxIF Interrupt Flag REGISTER Register 33-11: I2CxPIE: I2CxIE Interrupt and Hold Enable REGISTER Register 33-12: I2CxADR0: I2C ADDRESS 0 REGISTER Register 33-13: I2CxADR1: I2C ADDRESS 1 REGISTER Register 33-14: I2CxADR2: I2C ADDRESS 2 REGISTER Register 33-15: I2CxADR3: I2C ADDRESS 3 REGISTER Register 33-16: I2CxADB0: I2C ADDRESS Data BUFFER 0 register(1) Register 33-17: I2CxADB1: I2C ADDRESS Data BUFFER 1 register(1) 34.0 Fixed Voltage Reference (FVR) 34.1 Independent Gain Amplifiers 34.2 FVR Stabilization Period FIGURE 34-1: Voltage Reference Block Diagram 34.3 Register Definitions: FVR Control Register 34-1: FVRCON: Fixed Voltage Reference Control Register TABLE 34-1: Summary of Registers Associated with Fixed Voltage Reference 35.0 Temperature Indicator Module 35.1 Module Operation FIGURE 35-1: Temperature Indicator Module Block Diagram 35.1.1 Temperature Indicator Range 35.1.2 Minimum Operating Vdd TABLE 35-1: Recommended Vdd vs. Range 35.2 Temperature Calculation EQUATION 35-1: Sensor Temperature 35.2.1 Calibration 35.2.1.1 Higher-Order Calibration 35.2.2 Temperature Resolution 35.3 ADC Acquisition Time TABLE 35-2: Summary of Registers Associated with the Temperature Indicator(1) 36.0 Analog-to-Digital Converter with Computation (ADC2) Module FIGURE 36-1: ADC2 Block Diagram 36.1 ADC Configuration 36.1.1 Port Configuration 36.1.2 Channel Selection 36.1.3 ADC Voltage Reference 36.1.4 Conversion Clock TABLE 36-1: ADC Clock Period (Tad) Vs. Device Operating Frequencies(1,3) FIGURE 36-2: Analog-to-Digital Conversion Cycles 36.1.5 Interrupts 36.1.6 Result Formatting FIGURE 36-3: 12-Bit ADC Conversion Result Format 36.2 ADC Operation 36.2.1 Starting a Conversion 36.2.2 Completion of a Conversion 36.2.3 ADC Operation During Sleep 36.2.4 External Trigger During Sleep 36.2.5 Auto-Conversion Trigger 36.2.6 ADC Conversion Procedure (Basic Mode) EXAMPLE 36-1: ADC Conversion 36.3 ADC Acquisition Requirements EQUATION 36-1: Acquisition Time Example FIGURE 36-4: Analog Input Model FIGURE 36-5: ADC Transfer Function 36.4 ADC Charge Pump 36.5 Computation Operation FIGURE 36-6: Computational Features Simplified Block Diagram TABLE 36-2: Computation Modes 36.5.1 Digital Filter/Average TABLE 36-3: Low-pass Filter -3 dB Cut-off Frequency 36.5.2 Basic Mode 36.5.3 Accumulate Mode 36.5.4 Average Mode 36.5.5 Burst Average Mode 36.5.6 Low-pass Filter Mode 36.5.7 Threshold Comparison 36.5.8 Continuous Sampling mode 36.5.9 Double Sample Conversion 36.6 Capacitive Voltage Divider (CVD) Features FIGURE 36-7: Hardware Capacitive Voltage Divider Block Diagram 36.6.1 CVD Operation FIGURE 36-8: Differential CVD Measurement Waveform 36.6.2 PreCharge Control 36.6.3 Acquisition Control For CVD (ADPRE > 0) 36.6.4 Guard Ring Outputs FIGURE 36-9: Guard Ring Circuit FIGURE 36-10: Differential CVD with Guard Ring Output Waveform 36.6.5 Additional Sample and Hold Capacitance 36.7 Register Definitions: ADC Control Register 36-1: ADCON0: ADC Control Register 0 Register 36-2: ADCON1: ADC Control Register 1 Register 36-3: ADCON2: ADC Control Register 2 Register 36-4: ADCON3: ADC Control Register 3 Register 36-5: ADSTAT: ADC Status Register Register 36-6: ADCLK: ADC Clock Selection Register Register 36-7: ADREF: ADC Reference Selection Register Register 36-8: ADPCH: ADC Positive Channel Selection Register Register 36-9: ADPREL: ADC Precharge Time Control Register (Low Byte) Register 36-10: ADPREH: ADC Precharge Time Control Register (High Byte) TABLE 36-4: Precharge Time Register 36-11: ADACQL: ADC Acquisition Time Control Register (Low Byte) Register 36-12: ADACQH: ADC Acquisition Time Control Register (High Byte) TABLE 36-5: Acquisition Time Register 36-13: ADCAP: ADC Additional Sample Capacitor Selection Register Register 36-14: ADRPT: ADC Repeat Setting Register Register 36-15: ADCNT: ADC Repeat Counter Register Register 36-16: ADFLTRH: ADC Filter High Byte Register Register 36-17: ADFLTRL: ADC Filter Low Byte Register Register 36-18: ADRESH: ADC Result Register High, FM = 0 Register 36-19: ADRESL: ADC Result Register Low, FM = 0 Register 36-20: ADRESH: ADC Result Register High, FM = 1 Register 36-21: ADRESL: ADC Result Register Low, FM = 1 Register 36-22: ADPREVH: ADC Previous Result Register Register 36-23: ADPREVL: ADC Previous Result Register Register 36-24: ADACCU: ADC Accumulator Register Upper Register 36-25: ADACCH: ADC Accumulator Register High Register 36-26: ADACCL: ADC Accumulator Register Low Register 36-27: ADSTPTH: ADC Threshold Setpoint Register High Register 36-28: ADSTPTL: ADC Threshold Setpoint Register Low Register 36-29: ADERRH: ADC Setpoint Error Register High Register 36-30: ADERRL: ADC Setpoint Error Low Byte Register Register 36-31: ADLTHH: ADC Lower Threshold High Byte Register Register 36-32: ADLTHL: ADC Lower Threshold Low Byte Register Register 36-33: ADUTHH: ADC Upper Threshold High Byte Register Register 36-34: ADUTHL: ADC Upper Threshold Low Byte Register Register 36-35: ADACT: ADC AUTO Conversion Trigger Control Register Register 36-36: ADCP: ADC Charge Pump Control Register TABLE 36-6: Summary of Registers Associated with ADC 37.0 5-Bit Digital-to-Analog Converter (DAC) Module FIGURE 37-1: Digital-to-Analog Converter Block Diagram 37.1 Output Voltage Selection 37.2 Ratiometric Output Level 37.3 DAC Voltage Reference Output 37.4 Operation During Sleep 37.5 Effects of a Reset EQUATION 37-1: DAC Output Voltage 37.6 Register Definitions: DAC Control Register 37-1: DAC1CON0: DAC Control Register Register 37-2: DAC1CON1: DAC Data Register TABLE 37-1: Summary of Registers Associated with the DAC Module 38.0 Comparator Module 38.1 Comparator Overview FIGURE 38-1: Single Comparator FIGURE 38-2: Comparator Module Simplified Block Diagram 38.2 Comparator Control 38.2.1 Comparator Enable 38.2.2 Comparator Output 38.2.3 Comparator Output Polarity TABLE 38-1: Comparator Output State vs. Input Conditions 38.3 Comparator Hysteresis 38.3.1 Comparator Output Synchronization 38.4 Comparator Interrupt 38.5 Comparator Positive Input Selection 38.6 Comparator Negative Input Selection 38.7 Comparator Response Time 38.8 Analog Input Connection Considerations FIGURE 38-3: Analog Input Model 38.9 CWG1 Auto-Shutdown Source 38.10 ADC Auto-Trigger Source 38.11 TMR2/4/6 Reset 38.12 Operation in Sleep Mode 38.13 Register Definitions: Comparator Control TABLE 38-2: Register 38-1: CMxCON0: Comparator x Control Register 0 Register 38-2: CMxCON1: Comparator x Control Register 1 Register 38-3: CMxNCH: Comparator x Inverting Channel Select Register Register 38-4: CMxPCH: Comparator x Non-Inverting Channel Select Register Register 38-5: CMOUT: Comparator Output Register TABLE 38-3: Summary of Registers Associated with Comparator Module 39.0 High/Low-Voltage Detect (HLVD) 39.1 Operation FIGURE 39-1: HLVD Module Block Diagram 39.2 HLVD Setup 39.3 Current Consumption 39.4 HLVD Start-up Time FIGURE 39-2: Low-Voltage Detect Operation (INTL = 1) FIGURE 39-3: High-Voltage Detect Operation (INTH = 1) 39.5 Applications FIGURE 39-4: Typical Low-Voltage Detect Application 39.6 Operation During Sleep 39.7 Operation During Idle and Doze Modes 39.8 Operation During Freeze 39.9 Effects of a Reset 39.10 Register Definitions: HLVD Control TABLE 39-1: Register 39-1: HLVDCON0: High/Low-Voltage Detect Control Register 0 Register 39-2: HLVDCON1: Low-voltage Detect CONTROL REGISTER 1 TABLE 39-2: Summary of Registers Associated with High/Low-Voltage Detect Module 40.0 In-Circuit Serial Programming™ (ICSP™) 40.1 High-Voltage Programming Entry Mode 40.2 Low-Voltage Programming Entry Mode 40.3 Common Programming Interfaces FIGURE 40-1: ICD RJ-11 Style Connector Interface FIGURE 40-2: PICkit™ Programmer Style Connector Interface FIGURE 40-3: Typical Connection for ICSP™ Programming 41.0 Instruction Set Summary 41.1 Standard Instruction Set TABLE 41-1: Opcode Field Descriptions FIGURE 41-1: General Format for Instructions (1/2) FIGURE 41-2: General Format for Instructions (2/2) TABLE 41-2: Instruction Set 41.1.1 Standard Instruction Set 41.2 Extended Instruction Set 41.2.1 Extended Instruction Syntax TABLE 41-3: Extensions to the PIC18 Instruction Set 41.2.2 Extended Instruction Set 41.2.3 Byte-Oriented and Bit-Oriented Instructions in Indexed Literal Offset Mode 41.2.3.1 Extended Instruction Syntax with Standard PIC18 Commands 41.2.4 Considerations when Enabling the Extended Instruction Set 41.2.5 Special Considerations with Microchip MPLAB® IDE Tools 42.0 Register Summary TABLE 42-1: Register File Summary for PIC18(L)F26/27/45/46/47/55/56/57K42 Devices 43.0 Development Support 43.1 MPLAB X Integrated Development Environment Software 43.2 MPLAB XC Compilers 43.3 MPASM Assembler 43.4 MPLINK Object Linker/ MPLIB Object Librarian 43.5 MPLAB Assembler, Linker and Librarian for Various Device Families 43.6 MPLAB X SIM Software Simulator 43.7 MPLAB REAL ICE In-Circuit Emulator System 43.8 MPLAB ICD 3 In-Circuit Debugger System 43.9 PICkit 3 In-Circuit Debugger/ Programmer 43.10 MPLAB PM3 Device Programmer 43.11 Demonstration/Development Boards, Evaluation Kits, and Starter Kits 43.12 Third-Party Development Tools 44.0 Electrical Specifications 44.1 Absolute Maximum Ratings(†) 44.2 Standard Operating Conditions FIGURE 44-1: Voltage Frequency Graph, -40°C £ Ta £ +125°C, PIC18F26/27/45/46/47/55/ 56/57K42 Only FIGURE 44-2: Voltage Frequency Graph, -40°C £ Ta £ +125°C, PIC18LF26/27/45/46/47/55/ 56/57K42 Only 44.3 DC Characteristics TABLE 44-1: Supply Voltage FIGURE 44-3: POR and POR Rearm with Slow Rising Vdd TABLE 44-2: Supply Current (Idd)(1,2,4) TABLE 44-3: Supply Current (Idd)(1,2,4,5) TABLE 44-4: Power-Down Current (Ipd)(1,2) TABLE 44-5: I/O Ports TABLE 44-6: Memory Programming Specifications TABLE 44-7: Thermal Characteristics 44.4 AC Characteristics FIGURE 44-4: Load Conditions FIGURE 44-5: Clock Timing TABLE 44-8: External Clock/Oscillator Timing Requirements TABLE 44-9: INTERNAL Oscillator Parameters(1) FIGURE 44-6: Precision Calibrated HFINTOSC and MFINTOSC Frequency Accuracy Over Device Vdd and Temperature TABLE 44-10: PLL Specifications FIGURE 44-7: CLKOUT and I/O Timing TABLE 44-11: I/O and CLKOUT Timing Specifications FIGURE 44-8: Reset, Watchdog Timer, Oscillator Start-up Timer and Power-up Timer Timing FIGURE 44-9: Brown-Out Reset Timing and Characteristics TABLE 44-12: Reset, WDT, Oscillator Start-up Timer, Power-up Timer, Brown-Out Reset and Low-Power Brown-Out Reset Specifications TABLE 44-13: High/Low-Voltage Detect Characteristics TABLE 44-14: Analog-to-Digital Converter (ADC) Accuracy Specifications(1,2): TABLE 44-15: Analog-to-Digital Converter (ADC) Conversion Timing Specifications FIGURE 44-10: ADC Conversion Timing (ADC Clock Fosc-based) FIGURE 44-11: ADC Conversion Timing (ADC Clock from ADCRC) TABLE 44-16: Comparator Specifications TABLE 44-17: 5-Bit DAC Specifications TABLE 44-18: Fixed Voltage Reference (FVR) Specifications TABLE 44-19: Zero-Cross Detect (ZCD) Specifications FIGURE 44-12: Timer0 and Timer1 External Clock Timings TABLE 44-20: Timer0 and Timer1 External Clock Requirements FIGURE 44-13: Capture/Compare/PWM Timings (CCP) TABLE 44-21: Capture/Compare/PWM Requirements (CCP) FIGURE 44-14: SPI Master Mode Timing (CKE = 0, SMP = 0) FIGURE 44-15: SPI Master Mode Timing (CKE = 1, SMP = 1) FIGURE 44-16: SPI Slave Mode Timing (CKE = 0) FIGURE 44-17: SPI Slave Mode Timing (CKE = 1) TABLE 44-22: SPI Mode requirements (Master Mode) TABLE 44-23: SPI Mode requirements (Slave Mode) FIGURE 44-18: I2C Bus Start/Stop Bits Timing TABLE 44-24: I2C Bus Start/Stop Bits Requirements FIGURE 44-19: I2C Bus Data Timing TABLE 44-25: I2C Bus Data Requirements TABLE 44-26: Temperature Indicator Requirements 45.0 DC and AC Characteristics Graphs and Charts 46.0 Packaging Information 46.1 Package Details Appendix A: Revision History The Microchip WebSite Customer Change Notification Service Customer Support Product Identification System Trademarks Worldwide Sales
EMS supplier