Hi, I'm new in programming. I need help in C programming using ADC in PIC18F4520. i have a sensor and character lcd . i need to indicate the temp in lcd
#include "htc.h"
#define Value() ((((unsigned int)ADRESH)<<8)|(ADRESL))
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000 //Using a 4MHz oscillator
#endif
int result = 0x00;//Variable to store your ADC value.
int main(void)
{
//Using PORTA's bit 0 i.e.. RA0/AN0 as the ADC input
PORTA = 0x00;
TRISA = 0x01;
//Setting up the ADC
ADCON1 = 0x0E;
ADCON0 = 0x01;
ADCON2 = 0x81;
//Reading the ADC
while(1)
{
__delay_us(25);
GODONE = 1;
while(1)
{
if(GODONE == 0)
break;
}
result = Value();
//Here goes the rest of your program
}
}
Will you be using the HI-Tech C compiler in your project. If so I might have some tip for youthanks a lot
by Jake Hertz
by Jeff Child
by Jake Hertz