#include <p18f4520.h>
#include <delays.h>
#include <adc.h>
#include <math.h>
#include "xlcd.h"
// Fosc = 22.1184MHz
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config BOREN = OFF
#pragma config PBADEN = OFF
rom const char volttxtstrng[]="PRES ::";
rom const char temptxtstrng[]="TEMP ::";
void main (void)
{
int result;
ADCON1 = 0b00001110;
XLCDInit();
XLCDClear();
XLCDPutRomString(volttxtstrng);
XLCDL2home();
XLCDPutRomString(temptxtstrng);
while (1)
{
OpenADC(ADC_FOSC_16 & ADC_RIGHT_JUST & ADC_4_TAD, ADC_CH0 & ADC_INT_OFF, ADC_1ANA);
ConvertADC(); // Start conversion
while( BusyADC() ); // Wait for completion
result = ReadADC(); // Read result
result = ((result/(1023))*5*1000);
XLCDPut(result);
CloseADC(); // Disable A/D converter
}
}