|
Re: ADC problems with C library and new code
It turns out there is a bug with SetChanADC() - you need to right shift the channel one bit. This is clearly a bug in the C library since the OpenADC() function works correctly with the standard channels.
So, do the ADCopen once in your init code, then you can write a lean:
unsigned int GetADC(unsigned char chan)
{
SetChanADC(chan>>1);
Delay10TCYx(5);
ConvertADC();
while(BusyADC());
return ReadADC();
}
|