Section 34. Comparator

Similar documents
Section 54. Comparator with Blanking

Section 22. Basic 8-bit A/D Converter

Section 45. High-Speed Analog Comparator

Section bit A/D Converter

Charge Time Measurement Unit (CTMU) and CTMU Operation with Threshold Detect

LM12L Bit + Sign Data Acquisition System with Self-Calibration

Section Bit A/D Converter with Threshold Detect

MCP4021/2/3/4. Low-Cost NV Digital POT with WiperLock Technology. Package Types. Features. Block Diagram. Applications. Description.

MCP3426/7/8. 16-Bit, Multi-Channel ΔΣ Analog-to-Digital Converter with I 2 C Interface and On-Board Reference. Features.

Section 2. Oscillator

Liquid Crystal Display (LCD)

LM12454,LM12458,LM12H458

Building an Analog Communications System

4 x 10 bit Free Run A/D 4 x Hi Comparator 4 x Low Comparator IRQ on Compare MX839. C-BUS Interface & Control Logic

ADC0808/ADC Bit µp Compatible A/D Converters with 8-Channel Multiplexer

Microchip mtouch Solution Microchip Technology Incorporated. All Rights Reserved. Insert Class Code Here

MCP3422/3/4. 18-Bit, Multi-Channel ΔΣ Analog-to-Digital Converter with I 2 C Interface and On-Board Reference. Description.

Section 59. Oscillators with DCO

Section 16. Quadrature Encoder Interface (QEI)

ADC Bit High-Speed µp-compatible A/D Converter with Track/Hold Function

Section 35. Output Compare with Dedicated Timer

Hello, and welcome to this presentation of the STM32G0 digital-to-analog converter. This block is used to convert digital signals to analog voltages

2-, 4-, or 8-Channel, 16/24-Bit Buffered Σ Multi-Range ADC

AUR3840. Serial-interface, Touch screen controller. Features. Description. Applications. Package Information. Order Information

MCU Reset and Oscillator Circuits Application Note

P14155A: 128 Channel Cross-correlator ASIC Datasheet Rev 2.1

ADC Resolution: Myth and Reality

Section 25. Device Configuration

ADC Bit µp Compatible A/D Converter

ADC Bit A/D Converter

Capture/Compare/PWM/Timer (MCCP and SCCP)

dspic Analogue to Digital Converter

MCP6S91/2/3. Single-Ended, Rail-to-Rail I/O, Low-Gain PGA. Features. Description. Typical Applications. Package Types.

Real Time Embedded Systems. Lecture 1 January 17, 2012

Technical Brief FAQ (FREQUENCLY ASKED QUESTIONS) For further information, please contact Crystal Semiconductor at (512) or 1 (800)

AD Channel, ±10 V Input Range, High Throughput, 24-Bit - ADC FEATURES FUNCTIONAL BLOCK DIAGRAM APPLICATIONS GENERAL DESCRIPTION

Low-Power, Low-Glitch, Octal 12-Bit Voltage- Output DACs with Serial Interface

Low Power Windowed Watchdog with Reset, Sleep Mode Functions. Features. Applications. Selection Table. Part Number V REF

LSI/CSI LS8292 LS8293. PRELIMINARY MICRO-STEPPING MOTOR CONTROLLER June 2013

AZ309. John Suchyta 8-Bit MCD Applications Engineer. June, 2007 Design Tips & Tricks for Analog Functions on 8-bit MCUs

Fault Protection and Detection, 10 Ω RON, Dual SPDT Switch ADG5436F

Application Circuits 3. 3V R2. C4 100n G PI O. 0 G PI O S e t u p d a ta G PI O. 5 G PI O M o t i o n I n t G PI O. 4 G PI O.

Linear Integrated Circuits

16.1 ADC ADC ADC10

LSI/CSI LS7290 STEPPER MOTOR CONTROLLER. LSI Computer Systems, Inc Walt Whitman Road, Melville, NY (631) FAX (631)

An Analog Phase-Locked Loop

STELLARIS ERRATA. Stellaris LM3S8962 RevA2 Errata

12-Bit, Low-Power, Dual, Voltage-Output DAC with Serial Interface

Ultralow Power, UART, 1-Phase Power Measurement IC

Small, Dynamic Voltage Management Solution Based on TPS62300 High-Frequency Buck Converter and DAC6571

Frequency Synthesizer Project ECE145B Winter 2011

Features. Support for external one-path, internal three-path D/A converter reference voltages

10-Bit, Low-Power, Rail-to-Rail Voltage-Output Serial DAC in SOT23

Section 30. Capture/Compare/PWM/Timer (MCCP and SCCP)

8-Bit, high-speed, µp-compatible A/D converter with track/hold function ADC0820

MOSA ELECTRONICS. Features. Description. MS8870 DTMF Receiver

SH X Grayscale Dot Matrix OLED/PLED Driver with Controller. Features. General Description 1 V2.2

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

3 V/5 V, 2 MSPS, 8-Bit, 8-Channel ADC AD7829-1

ADC0808/ADC Bit µp Compatible A/D Converters with 8-Channel Multiplexer

16-Bit, Single-Channel, Ultra-Low Power, Delta-Sigma ADC with 2-Wire Serial Interface

ELCT 912: Advanced Embedded Systems

TOP VIEW. Maxim Integrated Products 1

MCP3550/1/3. Low-Power, Single-Channel 22-Bit Delta-Sigma ADCs. Description: Features: Applications: Package Types. Block Diagram

A3987. DMOS Microstepping Driver with Translator

Section 38. Oscillator with 500 khz Low-Power FRC

Analog Interface 8.1 OVERVIEW 8 1

IZ602 LCD DRIVER Main features: Table 1 Pad description Pad No Pad Name Function

PLL Frequency Synthesizer. Technical Data YYWW HPLL HPLL-8001

Section 39. Op amp/comparator

DS1075. EconOscillator/Divider PRELIMINARY FEATURES PIN ASSIGNMENT FREQUENCY OPTIONS

Tel: Fax:

Sigma-Delta ADCs. Benefits and Features. General Description. Applications. Functional Diagram

JTAG pins do not have internal pull-ups enabled at power-on reset. JTAG INTEST instruction does not work

LSI/CSI LS8397 STEPPER MOTOR CONTROLLER. LSI Computer Systems, Inc Walt Whitman Road, Melville, NY (631) FAX (631)

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

The rangefinder can be configured using an I2C machine interface. Settings control the

SG8F160P. 8-BIT MCU With Embedded Touch Sensor Version 1.1. Sigma reserves the right to change this documentation without prior notice

Pin 19 GPIO. Counters/Delay Generators CNT1 CNT2 CNT3 CNT4 CNT5 CNT6 CNT7 CNT8 CNT9. DFF/Latches. Pin 15 GPIO DFF0 DFF1 DFF2 DFF3 DFF4

DS Wire Digital Potentiometer

SD2085 Low Power HART TM Modem

MM58174A Microprocessor-Compatible Real-Time Clock

ML4818 Phase Modulation/Soft Switching Controller

SD bits ADC SOC. Features. Applications. Ordering Information. Description. Pin Diagram and Descriptions

Fault Protection and Detection, 10 Ω RON, Quad SPST Switches ADG5412F-EP

Section 3. Reset HIGHLIGHTS. Reset. This section of the manual contains the following major topics:

Simultaneous Sampling Video Rate Codec ADV7202

STPW12. Programmable electronic power breaker for 12 V bus. Datasheet. Features. Applications. Description

Dual, 8-Bit, Low-Power, 2-Wire, Serial Voltage-Output DAC

PART MAX5166NECM MAX5166MCCM MAX5166LECM MAX5166MECM OUT31 MAX5166 TQFP. Maxim Integrated Products 1

10-Bit, Low-Power, 2-Wire Interface, Serial, Voltage-Output DAC

CD4541BC Programmable Timer

High Temperature, High Voltage, Latch-Up Proof, 8-Channel Multiplexer ADG5298

SD2057 Low Power HART TM Modem

NJU6655. Preliminary. 64-common X 160-segment + 1-icon common Bitmap LCD Driver ! GENERAL DESCRIPTION ! PACKAGE OUTLINE ! FEATURES

UMAINE ECE Morse Code ROM and Transmitter at ISM Band Frequency

DATA SHEET. PCD pixels matrix LCD controller/driver INTEGRATED CIRCUITS Apr 12

1X6610 Signal/Power Management IC for Integrated Driver Module

ADC0808/ADC Bit µp Compatible A/D Converters with 8-Channel Multiplexer

Princeton Technology Corp.

Transcription:

Section 34. HIGHLIGHTS This section of the manual contains the following major topics: 34.1 Introduction... 34-2 34.2 Registers... 34-3 34.3 Operation... 34-6 34.4 Configuration... 34-7 34.5 Interrupts... 34-8 34.6 Voltage Reference Generator... 34-10 34.7 Initialization... 34-12 34.8 Register Map... 34-13 34.9 Design Tips... 34-14 34.10 Related Application Notes... 34-15 34.11 Revision History... 34-16 34 2009 Microchip Technology Inc. DS70212B-page 34-1

dspic33f Family Reference Manual 34.1 INTRODUCTION The dspic33f module provides two comparators that can be configured in a variety of ways. As shown in Figure 34-1, individual comparator options are specified by Configuration bits in the Control (CMCON) register to do the following: Enable the comparator Select input combinations Enable output inversion Enable output on an I/O pin The comparator operating mode is determined by the input selections (i.e., whether the input voltage is compared to a second input voltage or to an internal reference voltage). The internal reference voltage is generated by a resistor ladder network that is configured by the Voltage Reference Control (CVRCON) register. Figure 34-1: I/O Operating Modes C1IN+ CMCON<C1NEG> VIN- s CMCON<C1EN> CMCON<C1INV> Output Stages C1OUT C1IN- CMCON<C1OUTEN> CMCON<C1POS> C1 CVREFIN VIN+ READ CMCON D Latches CMCON<C1OUT> IFS1<CMIF> C2IN+ CMCON<C2NEG> VIN- CMCON<C2EN> CMCON<C2INV> C2OUT C2IN- CMCON<C2POS> C2 CMCON<C2OUTEN> CVREFIN VIN+ READ CMCON D Latches CMCON<C2OUT> IFS1<CMIF> CVREFIN Device Supply Voltage AVDD AVSS External Voltage (VREF+) (VREF-) MUX Internal Voltage Reference Generator CVRCON<CVROE> CVREF CVRCON<CVRSS> Note: The quantity (VREF+) - (VREF-) and (AVDD - AVSS) is generally represented as CVRSRC in subsequent sections. DS70212B-page 34-2 2009 Microchip Technology Inc.

Section 34. 34.2 COMPARATOR REGISTERS The module uses these registers: CMCON: Control Register This register allows the application program to enable, configure and interact with the individual comparators. CVRCON: Voltage Reference Control Register This register allows the application program to enable, configure and interact with the comparator internal voltage reference generator (see 34.6 Voltage Reference Generator for details). Register 34-1: CMCON: Control Register R/W-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 CMIDL C2EVT C1EVT C2EN C1EN C2OUTEN C1OUTEN bit 15 bit 8 R-0 R-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 C2OUT C1OUT C2INV C1INV C2NEG C2POS C1NEG C1POS bit 7 bit 0 Legend: C = Clearable bit R = Readable bit W = Writable bit U = Unimplemented bit, read as 0 -n = Value at POR 1 = Bit is set 0 = Bit is cleared x = Bit is unknown bit 15 CMIDL: Stop in Idle Mode bit 1 = When device enters Idle mode, module does not generate interrupts. Module is still enabled 0 = Continue normal module operation in Idle mode bit 14 Unimplemented: Read as 0 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 C2EVT: 2 Event bit 1 = output changed states 0 = output did not change states C1EVT: 1 Event bit 1 = output changed states 0 = output did not change states C2EN: 2 Enable bit 1 = is enabled 0 = is disabled C1EN: 1 Enable bit 1 = is enabled 0 = is disabled C2OUTEN: 2 Output Enable bit 1 = output is driven on the output pad 0 = output is not driven on the output pad C1OUTEN: 1 Output Enable bit 1 = output is driven on the output pad 0 = output is not driven on the output pad 34 2009 Microchip Technology Inc. DS70212B-page 34-3

dspic33f Family Reference Manual C1OUT: 1 Output bit When C1INV = 0: 1 = VIN+ > VIN- 0 = VIN+ < VIN- When C1INV = 1: 0 = VIN+ > VIN- 1 = VIN+ < VIN- Register 34-1: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 CMCON: Control Register (Continued) C2OUT: 2 Output bit When C2INV = 0: 1 = VIN+ > VIN- 0 = VIN+ < VIN- When C2INV = 1: 0 = VIN+ > VIN- 1 = VIN+ < VIN- C2INV: 2 Output Inversion bit 1 = C2 output inverted 0 = C2 output not inverted C1INV: 1 Output Inversion bit 1 = C1 output inverted 0 = C1 output not inverted C2NEG: 2 Negative Input Configure bit 1 = Input is connected to C2IN+ 0 = Input is connected to C2IN- See Figure 34-1 for the modes. C2POS: 2 Positive Input Configure bit 1 = Input is connected to C2IN+ 0 = Input is connected to CVREFIN See Figure 34-1 for the modes. C1NEG: 1 Negative Input Configure bit 1 = Input is connected to C1IN+ 0 = Input is connected to C1IN- See Figure 34-1 for the modes. C1POS: 1 Positive Input Configure bit 1 = Input is connected to C1IN+ 0 = Input is connected to CVREFIN See Figure 34-1 for the modes. DS70212B-page 34-4 2009 Microchip Technology Inc.

Section 34. Register 34-2: CVRCON: Voltage Reference Control Register U-0 U-0 U-0 U-0 U-0 U-0 U-0 U-0 bit 15 bit 8 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 CVREN CVROE (1) CVRR CVRSS CVR<3:0> bit 7 bit 0 Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as 0 -n = Value at POR 1 = Bit is set 0 = Bit is cleared x = Bit is unknown bit 15-8 Unimplemented: Read as 0 bit 7 CVREN: Voltage Reference Enable bit 1 = voltage reference circuit powered on 0 = voltage reference circuit powered down bit 6 CVROE: Voltage Reference Output Enable bit (1) bit 5 bit 4 bit 3-0 Note 1: 1 = Voltage level is output on CVREF pin 0 = Voltage level is disconnected from CVREF pin CVRR: Voltage Reference Range Selection bit 1 = 0 CVRSRC to 0.67 CVRSRC, with CVRSRC/24 step size 0 = 0.25 CVRSRC to 0.75 CVRSRC, with CVRSRC/32 step size CVRSS: Voltage Reference Source Selection bit 1 = voltage reference source, CVRSRC = (VREF+) (VREF-) 0 = voltage reference source, CVRSRC = AVDD AVSS CVR<3:0> Voltage Reference Value Selection 0 CVR<3:0> 15 bits When CVRR = 1: CVREFIN = (CVR<3:0>/24) x (CVRSRC) When CVRR = 0: CVREFIN = 1/4 x (CVRSRC) + (CVR<3:0>/32) x (CVRSRC) CVROE overrides the TRIS bit setting. 34 2009 Microchip Technology Inc. DS70212B-page 34-5

dspic33f Family Reference Manual 34.3 COMPARATOR OPERATION The operation of a typical comparator is shown in Figure 34-2, along with the relationship between the analog input levels and the digital output. Depending on the comparator operating mode, the monitored analog signal is compared to either an external or internal voltage reference. Each of the two comparators can be configured to use the same, or different reference sources. For example, one comparator can use an external reference while the other uses the internal reference. However, if both comparators use an internal reference, they must use the same reference voltage value (CVREFIN). For further details on comparator operation, see 34.6 Voltage Reference Generator. In Figure 34-2, the external reference VIN-, is a fixed external voltage. The analog signal present at VIN+ is compared to the reference signal at VIN-, and the digital output of the comparator is created when the difference is great enough. When VIN+ is less than VIN-, the output of the comparator is a digital low level. When VIN+ is greater than VIN-, the output of the comparator is a digital high level. The shaded areas of the output represent the area of uncertainty due to input offsets and response time. Figure 34-2: Operation VIN+ + Output Input Offset VIN- VIN- VIN+ Output Input offset represents the range of voltage levels within which the comparator trip point can occur. The output can switch at any point in this offset range. Response time is the minimum time required for the comparator to recognize a change in input levels. DS70212B-page 34-6 2009 Microchip Technology Inc.

Section 34. 34.4 COMPARATOR CONFIGURATION Each of the two comparators in the module is configured independently by Configuration bits in the Control (CMCON) register (Register 34-1). This register enables the application program to interact with the module to control: Input signal source (CxPOS and CxNEG bits) Output signal polarity (CxINV bits) Output signal path (CxOUT bits) 34.4.1 Input Signal Source The input signals can be connected to either of the positive (VIN+) or the negative (VIN-) comparator terminals. The connections are defined by these Configuration bits: C1POS 1 Positive Input Configure bit (CMCON<0>) C1NEG 1 Negative Input Configure bit (CMCON<1>) C2POS 2 Positive Input Configure bit (CMCON<2>) C2NEG 2 Negative Input Configure bit (CMCON<3>) Table 34-1 outlines the possible input signal configurations and the Configuration bit settings for each. Table 34-1: Input Signal Configurations Positive (VIN+) Input Terminal Negative (VIN-) CxPOS CxNEG CVREFIN C1IN- 0 0 CVREFIN C1IN+ 0 1 C1IN+ C1IN- 1 0 Note: The reference voltage CVREFIN can be generated either from the device supply voltage (AVDD - AVSS) or from an external voltage (VREF+) - (VREF-). This selection is done using the CVRCON<CVRSS> bits. 34.4.2 Output Signal Polarity The polarity of the output signal is determined by these Configuration bits: C1INV 1 Output Inversion bit (CMCON<4>) C2INV 2 Output Inversion bit (CMCON<5>) The configuration of these bits specifies how the state of the corresponding Output bit is achieved. 34.4.3 Output Signal Paths The module provides two output signal paths as reflected in Figure 34-3. The first path is through these CMCON register bits: C1OUT 1 Output (CMCON<6>) C2OUT 2 Output (CMCON<7>) These bits are read-only. Their state is determined by the relationship of the input signals as defined by the signal source and signal polarity configurations at the time of a Read operation. The second output path is through the C1OUT and C2OUT I/O pins. The real-time output of the comparator can be gated directly to the C1OUT and C2OUT I/O pins by these Configuration bits: C1OUTEN 1 Output Enable (CMCON<8>) C2OUTEN 2 Output Enable (CMCON<9>) The associated TRIS bits still function as an output enable/disable for the I/O pins while this output signal path is in use. 34 2009 Microchip Technology Inc. DS70212B-page 34-7

dspic33f Family Reference Manual Figure 34-3: Output Block Diagram CxOUTEN Port Pins Multiplex + To CxOUT Pin CxINV D Q To CMCON<CxOUT> (Via Data Bus) Read CMCON EN D Q Set IFS1<CMIF> (in Interrupt Module) EN CL Reset From other 34.5 COMPARATOR INTERRUPTS The Interrupt Flag, CMIF (IFS1<2>), is set when the synchronized output value of either comparator changes with respect to the last read value. These status bits reflect the output change: C1EVT 1 Event (CMCON<12>) C2EVT 2 Event (CMCON<13>) Software can read C1EVT and C2EVT to determine the actual change that occurred. Since it is also possible to write a 1 to this register, a simulated interrupt can be software initiated. Both the CMIF and CxEVT bits must be reset by clearing them in software. These bits can be cleared in the Interrupt Service Routine (ISR). Refer to Section 6. Interrupts (DS70184), for more information. Note: The comparison required for generating interrupts is based on the current comparator state and the last read value of the comparator outputs. Reading the C1OUT and C2OUT bits in the CMCON register will update the values used for the interrupt generation. 34.5.1 Interrupt Operation During Sleep If a comparator is enabled, and the dspic33f device is placed in Sleep mode, the comparator remains active. If the comparator interrupt is enabled in the Interrupt module, it also remains functional. Under these conditions, a comparator interrupt event will wake the device from Sleep mode. Each operational comparator consumes additional current. To minimize power consumption in Sleep mode, turn off the comparators before entering Sleep by disabling the C1EN and C2EN bits (CMCON<11:10>). If the device wakes up from Sleep, the contents of the CMCON register are not affected. Refer to Section 9. Watchdog Timer and Power-Saving Modes (DS70196), for more information on Sleep mode. DS70212B-page 34-8 2009 Microchip Technology Inc.

Section 34. 34.5.2 Effects of a Reset A device Reset forces the CMCON register to its Reset state, causing the comparator modules to be turned off (CxEN = 0). However, the input pins multiplexed with analog input sources are configured as analog inputs by default on device Reset. The I/O configuration for these pins is determined by the setting of the ADxPCFG register. Therefore, device current is minimized when analog inputs are present at Reset time. 34.5.3 Analog Input Connection Considerations A simplified circuit for an analog input is shown in Figure 34-4. A maximum source impedance of 10 kω is recommended for the analog sources. Any external component connected to an analog input pin, such as a capacitor or Zener diode, should have very little leakage current. 34.5.4 Interrupt Operation During Idle interrupt operation during idle is controlled by the Stop in Idle Mode (CMIDL) bit (CMCON<15>). If CMIDL = 0, normal interrupt operation continues. If CMIDL = 1, the comparator continues to operate, but it does not generate interrupts. The comparator remains active in Idle mode. Refer to Section 9. Watchdog Timer and Power-Saving Modes (DS70196), for more information on Idle mode. Figure 34-4: Analog Input Model VDD VA RS < 10k AIN CPIN 5 pf ILEAKAGE ±500 na RIC Input VSS Legend: CPIN = Input Capacitance ILEAKAGE = Leakage Current at the pin due to various junctions RIC = Interconnect Resistance RS = Source Impedance VA = Analog Voltage 34 2009 Microchip Technology Inc. DS70212B-page 34-9

dspic33f Family Reference Manual 34.6 COMPARATOR VOLTAGE REFERENCE GENERATOR The internal comparator voltage reference is derived from a 16-tap resistor ladder network that provides a selectable voltage level, as shown in Figure 34-5. This resistor network generates the internal voltage reference for the analog comparators. This voltage generator network is managed by the Voltage Reference Control (CVRCON) register (see Register 34-2) via these control bits: CVREN Voltage Reference Enable (CVRCON<7>) This control bit enables the voltage reference circuit. CVROE Voltage Reference Output Enable (CVRCON<6>) This control bit enables the reference voltage to be placed on the CVREF pin. When enabled, this bit overrides the corresponding TRIS bit setting. CVRSS Voltage Reference Source Selection (CVRCON<4>) This control bit specifies that the source (CVRSS) for the voltage reference circuit is either the device voltage supply (AVDD and AVSS) or an external reference (VREF+ and VREF-). CVRR Voltage Reference Range Selection (CVRCON<5>) This control bit selects one of two voltage ranges covered by the 16-tap resistor-ladder network: - 0 CVRSRC through 0.67 CVRSRC - 0.25 CVRSRC through 0.75 CVRSRC The range selected also determines the voltage increment available from the resistor-ladder taps (see 34.6.1 Configuring the Voltage Reference ). CVR<3:0> Voltage Reference Value Selection (CVRCOM<3:0>) These bits designate the resistor-ladder tap position. Table 34-2 lists the voltage at each tap for both ranges with CVRSRC = 3.3V. Figure 34-5: Voltage Reference Block Diagram VREF+ CVRSS = 1 CVRSRC CVRCON<3:0> AVDD CVRSS = 0 8R CVR3 CVR2 CVR1 CVR0 CVREN R R R CVREFIN 16 Steps R R R 16-to-1 MUX CVRCON<CVROE> CVREF R CVRR VREF- CVRSS = 1 8R AVSS CVRSS = 0 DS70212B-page 34-10 2009 Microchip Technology Inc.

Section 34. Table 34-2: Typical Voltage Reference with CVRSRC = 3.3V CVR<3:0> Tap Voltage Reference CVRR = 0 CVRR = 1 0000 0 0.83V 0.00V 0001 1 0.93V 0.14V 0010 2 1.03V 0.28V 0011 3 1.13V 0.41V 0100 4 1.24V 0.55V 0101 5 1.34V 0.69V 0110 6 1.44V 0.83V 0111 7 1.55V 0.96V 1000 8 1.65V 1.10V 1001 9 1.75V 1.24V 1010 10 1.86V 1.38V 1011 11 1.96V 1.51V 1100 12 2.06V 1.65V 1101 13 2.17V 1.79V 1110 14 2.27V 1.93V 1111 15 2.37V 2.06V 34.6.1 Configuring the Voltage Reference The voltage range selected by the CVRR bit also determines the size of the steps selected by the CVR<3:0> bits. One range (CVRR = 0) provides finer resolution by offering smaller voltage increments for each step. The equations used to calculate the comparator voltage reference are as follows: If CVRR = 1: Voltage Reference = ((CVR<3:0>)/24) x (CVRSRC) If CVRR = 0: Voltage Reference = (CVRSRC/4) + ((CVR<3:0>)/32) x (CVRSRC) 34.6.2 Voltage Reference Accuracy/Error The full voltage reference range cannot be realized because the transistors on the top and bottom of the resistor ladder network (Figure 34-5) keep the voltage reference from approaching the reference source rails. The voltage reference is derived from the reference source; therefore, the voltage reference output changes with fluctuations in that source. Check the Electrical Characteristics of the device you are using for reference voltage accuracy. 34.6.3 Operation During Sleep When the device wakes up from Sleep through an interrupt or Watchdog Timer time-out, the contents of the CVRCON register are not affected. To minimize current consumption in Sleep mode, the voltage reference should be disabled. 34 34.6.4 Effects of a Reset A device Reset has these effects: Disables the voltage reference by clearing the CVREN bit (CVRCON<7>) Disconnects the reference from the CVREF pin by clearing the CVROE bit (CVRCON<6>) Selects the high-voltage range by clearing the CVRR bit (CVRCON<5>) Clears the CVR value bits (CVRCON<3:0>) 2009 Microchip Technology Inc. DS70212B-page 34-11

dspic33f Family Reference Manual 34.6.5 Connection Considerations The voltage reference generator operates independently of the module. The output of the reference generator is connected to the CVREF pin, if the CVROE bit (CVRCON<6>) is set. Enabling the voltage reference output onto the I/O when it is configured as a digital input will increase current consumption. Configuring the port associated with CVREF as a digital output, with CVRSS enabled, will also increase current consumption. The CVREF output pin can be used as a simple D/A output with limited drive capability. Due to this limited current drive capability, a buffer must be used on the voltage reference output for external connections to CVREF. Figure 34-6 shows a buffering technique example. Figure 34-6: Voltage Reference Output Buffer Example dspic33f CVREF Generator R (1) Voltage Reference Output Impedance CVREF + Voltage Reference Output Note 1: R is dependent upon the comparator voltage reference control CVRR bits (CVRCON<5>) and CVR<3:0> value bits (CVRCON<3:0>). 34.7 INITIALIZATION The initialization sequence shown in Example 34-1 configures the module as two independent comparators with outputs enabled and 1 output inverted. The Voltage Reference module is configured for output enabled and set for 0.25 * VDD. The delay used in this example is based on an 8 MHz oscillator. Example 34-1: and Voltage Reference Configuration CMCON = 0x0F10; //Initialize Module CVRCON= 0x00C0; CMCONbits.C1EVT= 0; CMCONbits.C2EVT= 0; //Initialize Voltage Reference Module //Clear 1 Event //Clear 2 Event asm volatile("repeat #40"); //Delay 10 μs Nop(); DS70212B-page 34-12 2009 Microchip Technology Inc.

2009 Microchip Technology Inc. DS70212B-page 34-13 34.8 REGISTER MAP A summary of the registers associated with the module is provided in Table 34-3. Table 34-3: Register Map File Name Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 All Resets CMCON CMIDL C2EVT C1EVT C2EN C1EN C2OUTEN C1OUTEN C2OUT C1OUT C2INV C1INV C2NEG C2POS C1NEG C1POS 0000 CVRCON CVREN CVROE CVRR CVRSS CVR<3:0> 0000 Legend: = unimplemented, read as 0. Reset values are shown in hexadecimal. Section 34. 34

dspic33f Family Reference Manual 34.9 DESIGN TIPS Question 1: Answer: Question 2: Answer: Why is not my voltage reference what I expect? Any variation of the voltage reference source will translate directly onto the CVREF pin. Also, ensure that you have correctly calculated (specified) the voltage divider which generates the voltage reference. Why is not my voltage reference at the expected level when I connect CVREF into a low-impedance circuit? The Voltage Reference module is not intended to drive large loads. A buffer must be used between the dspic DSC device s CVREF pin and the load (see Figure 34-6). DS70212B-page 34-14 2009 Microchip Technology Inc.

Section 34. 34.10 RELATED APPLICATION NOTES This section lists application notes that are related to this section of the manual. These application notes may not be written specifically for the dspic33f device family, but the concepts are pertinent and could be used with modification and possible limitations. The current application notes related to the module include the following: Title Application Note # Make a Delta-Sigma Converter Using a Microcontroller s Analog Module AN700 A Based Slope ADC AN863 Note: Please visit the Microchip web site (www.microchip.com) for additional Application Notes and code examples for the dspic33f Family of devices. 34 2009 Microchip Technology Inc. DS70212B-page 34-15

dspic33f Family Reference Manual 34.11 REVISION HISTORY Revision A (October 2007) This is the initial release of this document. Revision B (January 2009) This revision includes the following updates: Figures: - Updated the inputs to the comparator in Figure 34-1. Note: - Added a note on CVRSRC in Figure 34-1. - Added a note on reference voltage CVREFIN in 34.4.1 Input Signal Source. Sections: - Updated the incorrect description for Input offset in 34.3 Operation. - Removed the incorrect description in 34.6.1 Configuring the Voltage Reference. Tables: - Updated the incorrect table values in Table 34-1. Additional minor corrections such as language and formatting updates are incorporated throughout the document. DS70212B-page 34-16 2009 Microchip Technology Inc.