PDA

View Full Version : Setting up ADC....



robertmark68
- 11th August 2006, 16:09
OK

I've been at this a while now and I don't seem to be getting anywhere...

Time to ask the gurus

I'm trying to set up a 16F877A to read AN0...

This is what I have so far:

DEFINE ADC_BITS 8 'Set # of bits
DEFINE ADC_CLOCK 3 'Set clock source (rc=3)
DEFINE ADC_SAMPLEUS 50 'Set sampling time in usec

I want to use an external +VREF, so i set ADCON1 like this (per the pic manual)

ADCON1 %00000001 'sets ADC to use AN3 as +VREF & GND as -VREF

The problem I am running into is there is a voltage approx 3V coming out of the pin that I want to input my +VREF on! This is not good.

Anyone have any ideas?

Robert

Darrel Taylor
- 11th August 2006, 18:08
Hi Robert,

I'm guessing that you are using an O-scope to see that voltage.

With the pin "Floating", and a High impeadance scope probe, it will balance out somewhere around midway between 0 and VDD just from the leakage currents.

A simple test is to put a 1k resistor from the pin to ground. The voltage should go away. You don't need that resistor for normal operation though.

With the ADCON1 setting you gave you should be OK to put a voltage on AN3. But if you are only using AN0, you might want to change it to %00000101 to open up some more digital pins.
<br>