ADC PIC18F4520! Using XLCD by Maestro!

Status
Not open for further replies.

drkidd22

Member
Hello,

I'm trying to use the files and functions generated by maestro to display voltage on LCD using the variable POT it comes with. I can display text fine, but I can't seem to be able to display the voltage on the screen as I turn the Pot. below is the code, any help will be appreciated.

Code:
#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

}

 }
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…