Datasheet
PIC16(L)F1782/3
DS41579D-page 152 Preliminary 2011-2012 Microchip Technology Inc.
17.1.5 INTERRUPTS
The ADC module allows for the ability to generate an
interrupt upon completion of an Analog-to-Digital
conversion. The ADC Interrupt Flag is the ADIF bit in
the PIR1 register. The ADC Interrupt Enable is the
ADIE bit in the PIE1 register. The ADIF bit must be
cleared in software.
This interrupt can be generated while the device is
operating or while in Sleep. If the device is in Sleep, the
interrupt will wake-up the device. Upon waking from
Sleep, the next instruction following the SLEEP
instruction is always executed. If the user is attempting
to wake-up from Sleep and resume in-line code
execution, the GIE and PEIE bits of the INTCON
register must be disabled. If the GIE and PEIE bits of
the INTCON register are enabled, execution will switch
to the Interrupt Service Routine.
17.1.6 RESULT FORMATTING
The 10-bit and 12-bit ADC conversion results can be
supplied in two formats: 2’s complement or
sign-magnitude. The ADFM bit of the ADCON1 register
controls the output format.
Figure 17-3 shows the two output formats.
FIGURE 17-3: ADC CONVERSION RESULT FORMAT
Note 1: The ADIF bit is set at the completion of
every conversion, regardless of whether
or not the ADC interrupt is enabled.
2: The ADC operates during Sleep only
when the F
RC oscillator is selected.
12-bit sign and magnitude
Bit 11Bit 10Bit 9Bit 8Bit 7Bit 6Bit 5Bit 4 Bit 3Bit 2Bit 1Bit 0 ‘0’‘0’‘0’Sign
ADFM = 0
ADRMD = 0
bit 7bit 0bit 7bit 0
12-bit ADC Result Loaded with ‘0’
12-bit 2’s compliment
Bit 12 Bit 12 Bit 12 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
ADFM = 1
ADRMD = 0
bit 7bit 0bit 7bit 0
Loaded with Sign bits’ 12-bit ADC Result
10-bit sign and magnitude
Bit 9Bit 8Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0 ‘0’‘0’‘0’‘0’‘0’Sign
ADFM = 0
ADRMD = 1
bit 7bit 0bit 7bit 0
10-bit ADC Result Loaded with ‘
0’
10-bit 2’s compliment
Bit 10 Bit 10 Bit 10 Bit 10 Bit 10 Bit 10 Bit 9 Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
ADFM = 1
ADRMD = 1
bit 7bit 0bit 7bit 0
Loaded with Sign bits’ 10-bit ADC Result