Pic16f188xx ADC with fvr
#include <xc.h> // Configuration bits #pragma config FOSC = INTOSC // Internal Oscillator #pragma config WDTE = OFF // Watchdog Timer Disable #pragma config PWRTE = OFF // Power-up Timer Disable #pragma config MCLRE = ON // MCLR Pin Function Select #pragma config CP = OFF // Flash Program Memory Code Protection #pragma config BOREN = ON // Brown-out Reset Enable #pragma config CLKOUTEN = OFF // Clock Out Disable #pragma config IESO = OFF // Internal/External Switchover #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Disable // Define system frequency #define _XTAL_FREQ 32000000 // 32 MHz internal oscillator void setup(void) { // Initialize oscillator OSCCON1 = 0x60; // Set OSCCON1 - HFINTOSC with 1x divider OSCFRQ = 0x06; // Set OSCFRQ - 32MHz HFINTOSC // Initialize FVR to 2.048V for ADC FVRCON = 0b11000010; // FVREN enabled, ADC FVR Buffer Gain is 2x (2.048V) // Set RA0/AN0 as analog input TRI