/*
* File: ADC_DEMO.c
* Author: My Pc
*
* Created on May 30, 2013, 12:54 PM
*/
#include <p32xxxx.h>
#include <stdio.h>
#include <stdlib.h>
#include "ADC.h"
// DEVCFG2
#pragma config FPLLIDIV = DIV_2 // PLL Input Divider (8MHz / 2 = 4MHz)
#pragma config FPLLMUL = MUL_20 // PLL Multiplier (4MHz X 20 = 80MHz)
#pragma config FPLLODIV = DIV_2 // System PLL Output Clock Divider (80MHz / 2 = 40MHz)
// DEVCFG1
#pragma config FPBDIV = DIV_2 // Peripheral Clock Divisor (40MHz / 2 = 20MHz)
#pragma config FNOSC = PRIPLL // Oscillator Selection Bits (Primary Oscillator with PLL)
#pragma config POSCMOD = XT // Primary Oscillator Configuration (External Oscillator - 4 - 10 MHz)
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled)
#pragma config IESO = OFF // Internal/External Switch Over (Disabled)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled)
// DEVCFG0
#pragma config DEBUG = OFF // Background Debugger Enable (Debugger is disabled)
#pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF // Code Protect (Protection Disable
int a;
float TEMP;
main()
{
// initializations
initADC( AINPUTS); // initialize the ADC
while(1)
{
a = readADC(TSENS); // select the POT input and convert
//TEMP = ((a*3.22))/10;
}
}