Hi Mark,
I have setup channel 4 for A/D reading as follows:
void fnConfigureADC(void)
{
ADC_SETUP adc_setup; // interrupt configuration parameters
adc_setup.int_type = ADC_INTERRUPT; // identifier when configuring
adc_setup.int_adc_bit = 4; // ADC channel 0
adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_CONFIGURE_CHANNEL | ADC_SEQUENTIAL_MODE | ADC_SINGLE_ENDED | ADC_LOOP_MODE | ADC_START_OPERATION); // single ended configuration in loop mode
adc_setup.int_adc_speed = (unsigned char)(BUS_CLOCK/5000000); // 5MHz sampling (must be between 100kHz and 5MHz)
adc_setup.int_adc_int_type = 0; // no interrupt
fnConfigureInterrupt((void *)&adc_setup); // configure and start operation
}
And read the channel every second as follows:
void fnReadVoltageMonitor(void)
{
char Res[20];
int result;
while (!(ADC_ADSTAT & RDY_CHANNEL4)) //wait until conversion
;
result=ADC_ADRSLT4; //get result
result>>=3; //move result
sprintf(Res,"A/D=%d\r\n",result);
fnDebugMsg(Res);
}
When checking the pin directly I have 0.74v ( I have a variable resistor, so I can adjust the input). I get an a/d value of 1222. If I am correct this calculates to 0.984v, which is not right. If I vary the voltage I do get the result following.
I tried changing to ADC_PARALLEL_MODE but the reading were like it was floating.
Neil