Datasheet PIC18F24K42, PIC18F25K42, PIC18LF24K42, PIC18LF25K42 (Microchip) - 3

制造商Microchip
描述28-Pin, Low-Power High-Performance Microcontrollers with XLP Technology
页数 / 页794 / 3 — PIC18(L)F24/25K42. Analog Peripherals. Flexible Oscillator Structure
文件格式/大小PDF / 9.9 Mb
文件语言英语

PIC18(L)F24/25K42. Analog Peripherals. Flexible Oscillator Structure

PIC18(L)F24/25K42 Analog Peripherals Flexible Oscillator Structure

文件文字版本

PIC18(L)F24/25K42 Analog Peripherals Flexible Oscillator Structure
• Analog-to-Digital Converter with Computation • High-Precision Internal Oscillator (ADC2): - Selectable frequency range up to 64 MHz - 12-bit with up to 35 external channels - ±1% at calibration (nominal) - Automated post-processing • Low-Power Internal 32 kHz Oscillator - Automated math functions on input signals: (LFINTOSC) averaging, filter calculations, oversampling • External 32 kHz Crystal Oscillator (SOSC) and threshold comparison • External Oscillator Block with: - Operates in Sleep - x4 PLL with external sources - Integrated charge pump for improved low- - Three crystal/resonator modes up to 20 MHz voltage operation - Three external clock modes up to 20 MHz • Hardware Capacitive Voltage Divider (CVD): • Fail-Safe Clock Monitor - Automates touch sampling and reduces • Oscillator Start-up Timer (OST) software size and CPU usage when touch or - Ensures stability of crystal oscillator sources proximity sensing is required - Adjustable sample and hold capacitor array - Two guard ring output drives • Temperature Sensor - Internal connection to ADC - Can be calibrated for improved accuracy • Two Comparators: - Low-Power/High-Speed mode - Fixed Voltage Reference at noninverting input(s) - Comparator outputs externally accessible • 5-bit Digital-to-Analog Converter (DAC): - 5-bit resolution, rail-to-rail - Positive Reference Selection - Unbuffered I/O pin output - Internal connections to ADCs and comparators • Voltage Reference - Fixed Voltage Reference with 1.024V, 2.048V and 4.096V output levels  2016-2019 Microchip Technology Inc. DS40001869D-page 3 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 Most Current Data Sheet Errata Customer Notification System 28-Pin, Low-Power High-Performance Microcontrollers with XLP Technology 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 2.0 Guidelines for Getting Started with PIC18(L)F24/ 25K42 Microcontrollers 2.1 Basic Connection Requirements FIGURE 2-1: Recommended Minimum Connections 2.2 Power Supply Pins 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)F24/25K42 Family Block Diagram 3.1 System Arbitration TABLE 3-1: Default Priorities FIGURE 3-2: System Arbiter Block Diagram EXAMPLE 3-1: Priority Lock Sequence EXAMPLE 3-2: Priority Unlock Sequence 3.2 Memory Access Scheme 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) TABLE 4-1: Program and Data EEPROM Memory Map TABLE 4-2: Program Flash Memory Partition FIGURE 4-1: Return Address Stack and Associated Registers 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 EXAMPLE 4-1: Fast Register Stack Code Example EXAMPLE 4-2: Computed GOTO Using an Offset Value 4.4 PIC18 Instruction Cycle EXAMPLE 4-3: Instruction Pipeline Flow FIGURE 4-2: Instructions in Program Memory EXAMPLE 4-4: Two-Word Instructions EXAMPLE 4-5: Three-Word Instructions 4.5 Data Memory Organization FIGURE 4-3: Data Memory Map for PIC18(L)F24/25K42 Devices FIGURE 4-4: FIGURE 4-4: Use of the Bank Select Register (Direct Addressing) TABLE 4-3: Special Function Register Map for PIC18(L)F24/25K42 Devices (DMA ACCESS ONLY) TABLE 4-4: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 63 TABLE 4-5: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 62 TABLE 4-6: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 61 TABLE 4-7: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 60 TABLE 4-8: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 59 TABLE 4-9: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 58 TABLE 4-10: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 57 TABLE 4-11: Special Function Register Map for PIC18(L)F24/25K42 Devices Bank 56 4.6 Register Definitions: Status Registers Register 4-2: STATUS: Status Register 4.7 Data Addressing Modes EXAMPLE 4-6: How to Clear RAM (Bank 1) Using Indirect Addressing FIGURE 4-5: Indirect Addressing 4.8 Data Memory and the Extended Instruction Set FIGURE 4-6: Comparing Addressing Options for Bit-Oriented and Byte-Oriented Instructions (Extended Instruction Set Enabled) 4.9 PIC18 Instruction Execution and the Extended Instruction Set FIGURE 4-7: 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.8 Device Configuration Information TABLE 5-4: Device Configuration Information for PIC18(L)F24/25K42 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) 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.5 MCLR TABLE 6-2: MCLR Configuration 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.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 FIGURE 7-2: External Clock (EC) Mode Operation FIGURE 7-3: Quartz Crystal Operation (LP, XT or HS Mode) FIGURE 7-4: Ceramic Resonator Operation (XT or HS Mode) FIGURE 7-5: Quartz Crystal Operation (Secondary Oscillator) 7.3 Clock Switching 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 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.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) TABLE 9-1: IVT Address Calculation Summary EXAMPLE 9-1: IVT Unlock Sequence EXAMPLE 9-2: IVT lock Sequence 9.3 Interrupt Priority TABLE 9-2: Interrupt Vector Priority Table 9.4 Interrupt Operation FIGURE 9-1: Vectored Interrupts State Transition Diagram FIGURE 9-2: Interrupt Execution: High/Low Priority Interrupt When Executing Main Routine FIGURE 9-3: Interrupt Execution: High Priority Interrupt with a Low Priority Interrupt Pending FIGURE 9-4: Interrupt Execution: High Priority Interrupt Preempting Low Priority Interrupts FIGURE 9-5: Interrupt Execution: Simultaneous Low and High Priority Interrupts 9.5 Context Saving 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 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 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 FIGURE 10-2: Wake-Up from Sleep through Interrupt 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 TABLE 11-1: WWDT Operating Modes 11.3 Time-out Period 11.4 Watchdog Window 11.5 Clearing the WWDT 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 FIGURE 13-1: Table Read Operation FIGURE 13-2: Table Write Operation TABLE 13-2: Table Pointer Operations with TBLRD and TBLWT Instructions FIGURE 13-3: Table Pointer Boundaries Based on Operation 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 FIGURE 13-6: NVM Unlock Sequence Flowchart EXAMPLE 13-2: NVM Unlock Sequence EXAMPLE 13-3: Erasing a Program Flash Memory block FIGURE 13-7: PFM Row Erase Flowchart FIGURE 13-8: Table Writes to Program Flash Memory 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 FIGURE 13-10: Program Flash Memory Verify Flowchart 13.2 Device Information Area, Device Configuration Area, User ID, Device ID and Configuration Word Access TABLE 13-3: DIA, DCI, User ID, Dev/REV ID and Configuration Word Access (REG[1:0] = x1) 13.3 Data EEPROM Memory FIGURE 13-11: Data EEPROM Read Flowchart EXAMPLE 13-5: Data EEPROM Read EXAMPLE 13-6: Data EEPROM Write 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.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.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 FIGURE 15-2: DMA Pointers Block Diagram 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.6 Types of Hardware Triggers 15.7 Types of Data Transfers 15.8 DMA Interrupts 15.9 DMA Setup and Operation FIGURE 15-4: DMA Operation with hardware trigger FIGURE 15-5: GPR-GPR Transactions with Hardware Triggers, SSTP = 1 FIGURE 15-6: GPR-GPR Transactions with Hardware Triggers, DSTP = 1 FIGURE 15-7: GPR-GPR Transactions with Hardware Triggers, SSTP, DSTP = 0 FIGURE 15-8: SFR Space to GPR Space Transfer FIGURE 15-9: Overrun Interrupt FIGURE 15-10: Abort at the End of Message 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.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 FIGURE 16-1: Generic I/O Port Operation 16.1 I/O Priorities 16.2 PORTx Registers EXAMPLE 16-1: Initializing PORTA 16.3 PORTE Registers 16.4 Register Definitions: Port Control Register 16-1: PORTx: PORTx Register(1) TABLE 16-1: PORT Registers Register 16-2: TRISx: Tri-State Control Register TABLE 16-2: TRIS Registers Register 16-3: LATx: LATx Register(1) TABLE 16-3: LAT Registers Register 16-4: ANSELx: Analog Select Register TABLE 16-4: Analog Select PORT Registers Register 16-5: WPUx: Weak Pull-up Register TABLE 16-5: Weak Pull-Up Port Registers Register 16-6: ODCONx: Open-Drain Control Register TABLE 16-6: Open-Drain Control Registers Register 16-7: SLRCONx: Slew Rate Control Register TABLE 16-7: Slew Rate Control Registers Register 16-8: INLVLx: Input Level Control Register TABLE 16-8: Input Level Port Registers Register 16-9: RxyI2C: I2C PAD Rxy Control Register TABLE 16-9: I2C Pad Control Registers TABLE 16-10: 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 Register 17-3: PPSLOCK: PPS Lock Register TABLE 17-2: 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) FIGURE 18-2: 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.2 Clock Source Selection 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.3 Timer1/3/5 Prescaler 21.4 Timer1/3/5 Operation 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 TABLE 21-2: Timer1/3/5 Gate Enable Selections 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.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 FIGURE 22-4: Software Gate Mode Timing Diagram FIGURE 22-5: Hardware Gate Mode Timing Diagram (MODE = 00001) FIGURE 22-6: Edge Triggered Hardware Limit Mode Timing Diagram (MODE=00100) FIGURE 22-7: Level Triggered Hardware Limit Mode Timing Diagram (MODE = 00111) FIGURE 22-8: Software Start One-shot Mode Timing Diagram (MODE = 01000) FIGURE 22-9: Edge Triggered One-Shot Mode Timing Diagram (MODE = 01001) FIGURE 22-10: Edge Triggered Hardware Limit One-Shot Mode Timing Diagram (MODE = 01100)) FIGURE 22-11: Low Level Reset, Edge-Triggered hardware Limit one-Shot Mode Timing Diagram (MODE = 01110) FIGURE 22-12: Rising Edge-Triggered Monostable Mode Timing Diagram (MODE = 10001) 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 TABLE 23-1: CCP Mode – Timer Resource 23.2 Capture Mode FIGURE 23-1: Capture Mode Operation Block Diagram 23.3 Compare Mode FIGURE 23-2: Compare Mode Operation Block Diagram 23.4 PWM Overview FIGURE 23-3: CCP PWM Output Signal FIGURE 23-4: Simplified PWM Block Diagram EQUATION 23-1: PWM Period FIGURE 23-5: PWM 10-Bit Alignment EQUATION 23-2: Pulse Width EQUATION 23-3: Duty Cycle Ratio 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.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 EQUATION 24-1: PWM Period EQUATION 24-2: Pulse Width EQUATION 24-3: Duty Cycle Ratio 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.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.2 Basic Timer Function Registers 25.3 Halt Operation 25.4 Polarity Control 25.5 Status Information 25.6 Modes of Operation TABLE 25-1: Modes of Operation FIGURE 25-3: Timer Mode Timing Diagram FIGURE 25-4: Gated Timer Mode Repeat Acquisition Timing Diagram FIGURE 25-5: Gated Timer Mode Single Acquisition Timing Diagram FIGURE 25-6: Period And Duty-Cycle Repeat Acquisition Mode Timing Diagram FIGURE 25-7: Period And Duty-Cycle Single Acquisition Timing Diagram FIGURE 25-8: High and Low Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-9: High and Low Measure Mode Single Acquisition Timing Diagram FIGURE 25-10: Windowed Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-11: Windowed Measure Mode Single Acquisition Timing Diagram FIGURE 25-12: Gated Windowed Measure Mode Repeat Acquisition Timing Diagram FIGURE 25-13: Gated Windowed Measure Mode Single Acquisition Timing Diagrams FIGURE 25-14: Time Of Flight Mode Repeat Acquisition Timing Diagram FIGURE 25-15: Time Of Flight Mode Single Acquisition Timing Diagram FIGURE 25-16: Capture Mode Repeat Acquisition Timing Diagram FIGURE 25-17: Capture Mode Single Acquisition Timing Diagram FIGURE 25-18: Counter Mode Timing Diagram FIGURE 25-19: Gated Counter Mode Repeat Acquisition Timing Diagram FIGURE 25-20: Gated Counter Mode Single Acquisition Timing Diagram FIGURE 25-21: Windowed Counter Mode Repeat Acquisition Timing Diagram FIGURE 25-22: Windowed Counter Mode Single Acquisition Timing Diagram 25.7 Interrupts 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 FIGURE 26-1: Simplified CWG Block Diagram (Half-Bridge Mode, MODE[2:0] = 100) FIGURE 26-2: CWGx Half-Bridge Mode Operation FIGURE 26-3: Simplified CWG Block Diagram (Push-Pull Mode, MODE[2:0] = 101) FIGURE 26-4: CWGx Push-Pull Mode Operation 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 FIGURE 26-8: Example of PWM Direction Change at Near 100% Duty Cycle FIGURE 26-9: Example of Synchronous Steering (MODE[2:0] = 001) FIGURE 26-10: Example of Asynchronous Steering (MODE[2:0]= 000) FIGURE 26-11: Simplified CWG Block Diagram (Output Steering Modes) 26.3 Clock Source 26.4 Selectable Input Sources 26.5 Output Control 26.6 Dead-Band Control 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.11 Auto-Shutdown 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-1: Summary of Registers Associated with CWG 27.0 Configurable Logic Cell (CLC) FIGURE 27-1: CLCx Simplified Block Diagram 27.1 CLCx Setup TABLE 27-1: CLCx Data Input Selection TABLE 27-2: Data Gating Logic 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.2 FIXED DUTY CYCLE MODE 28.3 PULSE FREQUENCY MODE 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 FIGURE 31-3: Asynchronous Transmission FIGURE 31-4: Asynchronous Transmission (Back-to-Back) FIGURE 31-5: Asynchronous Reception 31.3 Asynchronous Address Mode 31.4 DMX Mode (UART1 only) FIGURE 31-6: DMX Transmit Sequence 31.5 LIN Modes (UART1 only) 31.6 DALI Mode (UART1 only) 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.10 Operation after FIFO overflow 31.11 Receive and Transmit Buffers 31.12 Flow Control FIGURE 31-10: Flow Control FIGURE 31-11: RS-485 Configuration 31.13 Checksum (UART1 only) 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 TABLE 31-2: BRG Counter Clock Rates FIGURE 31-12: Automatic Baud Rate Calibration 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.4 Transfer Counter 32.5 Master mode TABLE 32-1: Master Mode TXR/RXR Settings FIGURE 32-3: SPI Master Operation – Data Exchange, TXR/RXR = 1/1 FIGURE 32-4: SPI Master Operation, Command+Write Data, TXR/RXR=1/0 FIGURE 32-5: SPI Master Operation, Command+Read Data, TXR/RXR=0/1 FIGURE 32-6: SPI Master SS Operation- CKE = 0, BMODE = 1, TCWIDTH = 0, SSP = 0 EQUATION 32-1: Frequency of SCK Output Signal 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.6 Slave Mode TABLE 32-2: Slave Mode Transmit FIGURE 32-11: SPI Slave Mode Operation – Interrupt-Driven, Master Writes 2+3 Bytes 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 FIGURE 32-14: Transfer and Slave Select Interrupt timings 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 TABLE 33-1: I2C BUS TERMS FIGURE 33-3: Start and Stop Conditions FIGURE 33-4: Restart Condition TABLE 33-2: Address Buffer Direction as per I2C Mode 33.4 I2C Slave Mode FIGURE 33-5: Slave Mode General Call Address Sequence 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) FIGURE 33-9: I2C Slave, 7-Bit Address, Transmission FIGURE 33-10: I2C Slave, 7-Bit Address, Transmission (No Clock Stretching) FIGURE 33-11: I2C Slave, 10-Bit Address, Reception With Stop (ADB = 1) FIGURE 33-12: I2C Slave, 10-Bit Address, Transmission 33.5 I2C Master Mode FIGURE 33-13: Clock Synthesis Timing (FME = 0) FIGURE 33-14: Clock Synthesis Timing (FME = 1) FIGURE 33-15: Start Condition Timing FIGURE 33-16: Repeated Start Condition Timing FIGURE 33-17: Acknowledge Sequence Timing FIGURE 33-18: Stop Condition during Receive or Transmit FIGURE 33-19: I2C Master, 7-Bit Address, Transmission FIGURE 33-20: I2C Master, 7-Bit Address, Reception FIGURE 33-21: I2C Master, 10-Bit Address, Transmission FIGURE 33-22: I2C Master, 10-Bit Address, Reception (Using RSEN Bit) 33.6 I2C Multi-Master Mode 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 TABLE 35-1: Recommended Vdd vs. Range 35.2 Temperature Calculation EQUATION 35-1: Sensor Temperature 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 TABLE 36-1: ADC Clock Period (Tad) Vs. Device Operating Frequencies(1,3) FIGURE 36-2: Analog-to-Digital Conversion Cycles FIGURE 36-3: 12-Bit ADC Conversion Result Format 36.2 ADC Operation 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 TABLE 36-3: Low-pass Filter -3 dB Cut-off Frequency 36.6 Capacitive Voltage Divider (CVD) Features FIGURE 36-7: Hardware Capacitive Voltage Divider Block Diagram FIGURE 36-8: Differential CVD Measurement Waveform FIGURE 36-9: Guard Ring Circuit FIGURE 36-10: Differential CVD with Guard Ring Output Waveform 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 TABLE 38-1: Comparator Output State vs. Input Conditions 38.3 Comparator Hysteresis 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: PIC18(L)F24/25K42Instruction Set 41.2 Extended Instruction Set TABLE 41-3: Extensions to the PIC18 Instruction Set 42.0 Register Summary TABLE 42-1: Register File Summary for PIC18(L)F24/25K42 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, PIC18F24/25K42 Only FIGURE 44-2: Voltage Frequency Graph, -40°C £ Ta £ +125°C, PIC18LF24/25K42 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: Power-Down Current (Ipd)(1,2) TABLE 44-4: I/O Ports TABLE 44-5: Memory Programming Specifications TABLE 44-6: Thermal Characteristics 44.4 AC Characteristics FIGURE 44-4: Load Conditions FIGURE 44-5: Clock Timing TABLE 44-7: External Clock/Oscillator Timing Requirements TABLE 44-8: INTERNAL Oscillator Parameters(1) FIGURE 44-6: Precision Calibrated HFINTOSC and MFINTOSC Frequency Accuracy Over Device Vdd and Temperature TABLE 44-9: PLL Specifications FIGURE 44-7: CLKOUT and I/O Timing TABLE 44-10: 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-11: Reset, WDT, Oscillator Start-up Timer, Power-up Timer, Brown-Out Reset and Low-Power Brown-Out Reset Specifications TABLE 44-12: High/Low-Voltage Detect Characteristics TABLE 44-13: Analog-to-Digital Converter (ADC) Accuracy Specifications(1,2): TABLE 44-14: 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-15: Comparator Specifications TABLE 44-16: 5-Bit DAC Specifications TABLE 44-17: Fixed Voltage Reference (FVR) Specifications TABLE 44-18: Zero-Cross Detect (ZCD) Specifications FIGURE 44-12: Timer0 and Timer1 External Clock Timings TABLE 44-19: Timer0 and Timer1 External Clock Requirements FIGURE 44-13: Capture/Compare/PWM Timings (CCP) TABLE 44-20: 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-21: SPI Mode requirements (Master Mode) TABLE 44-22: SPI Mode requirements (Slave Mode) FIGURE 44-18: I2C Bus Start/Stop Bits Timing TABLE 44-23: I2C Bus Start/Stop Bits Requirements FIGURE 44-19: I2C Bus Data Timing TABLE 44-24: I2C Bus Data Requirements TABLE 44-25: 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 and Service