10.3.5 A/D conversion procedure
The following steps give an example of using ADC for analog-to-digital conversion:
1. port configuration:
⚫ Disable pin output driver (see TRIS register);
⚫ Configure pin as analog input pin.
2. configuration ADC mod:
⚫ Select ADC reference voltage (AD conversion must be wait for up to 100us if the reference voltage
switches from VDD to internal LDO);
⚫ Select ADC conversion clock;
⚫ Select ADC input channel;
⚫ Choose the format of the result;
⚫ Start the ADC mod.
3. configuration ADC interrupt (optional):
⚫ Clear ADC interrupt flag bit;
⚫ Allow ADC interrupt;
⚫ Allow peripherals interrupt;
⚫ Allow global interrupt.
4. Wait for the required acquisition time.
5. Set GO/
DONE
”) bit
⚫ Wait for ADC interrupt (allow interrupt).
7. Read ADC results.
8. Clear the ADC interrupt flag bit (if interrupt is allowed, this operation is required).
9. At least wait for 2 TAD times to start AD conversion again When GO/ ("
DONE
Note: If the user tries to resume sequential code execution after waking the device from sleep mode,
the global interrupt must be disabled.