Hello,
I'm using a PIC18F4480 and attempting to setup one ADC channel for now, AN0.
my input circuit consists of a pot voltage divider into a voltage follower opamp as a buffer. The buffer should take care of any input impedance issues, right? i have a multimeter on the input pin and can see my voltage vary nicely from 0-5Vish.
I'm writing in C and and using this config:
When i run the program and call this function continuously from a while(1) loop in main i basicaly get either '1023' or '0023'. i sometimes see other number flicker on the LCD but those are it 99.9% of the time.
Does this give you guys any sort of clue as to whats wrong? Could it be a twos compliments number flopping pos/neg around zero? it behaves as if my input is binary.. about halfway around the pot it flips to the other value.
Is there any harm is setting all channels to analog in the ADCconfig? I've tried just one (AN0) and also all of them w/ no change in results.
As you can see i'm using a TAD of 12 and an freq of OSC/32 .. i'm running at 20MHz and this is the recommended freq. I'm a bit unclear on figuring TAD.
Thanks a lot
I'm using a PIC18F4480 and attempting to setup one ADC channel for now, AN0.
my input circuit consists of a pot voltage divider into a voltage follower opamp as a buffer. The buffer should take care of any input impedance issues, right? i have a multimeter on the input pin and can see my voltage vary nicely from 0-5Vish.
I'm writing in C and and using this config:
Code:
int getADC (unsigned int channel){
int adcResult = 0;
OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH0 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS, ADC_16ANA);
msDelay(10);
ConvertADC(); // Start conversion
while( BusyADC() ); // Wait for conversion to complete
adcResult = ReadADC(); // Get value
CloseADC();
msDelay(10);
return adcResult;
}
When i run the program and call this function continuously from a while(1) loop in main i basicaly get either '1023' or '0023'. i sometimes see other number flicker on the LCD but those are it 99.9% of the time.
Does this give you guys any sort of clue as to whats wrong? Could it be a twos compliments number flopping pos/neg around zero? it behaves as if my input is binary.. about halfway around the pot it flips to the other value.
Is there any harm is setting all channels to analog in the ADCconfig? I've tried just one (AN0) and also all of them w/ no change in results.
As you can see i'm using a TAD of 12 and an freq of OSC/32 .. i'm running at 20MHz and this is the recommended freq. I'm a bit unclear on figuring TAD.
Thanks a lot