PDA

View Full Version : Adcin on a 16F876



krapoto
- 10th April 2006, 09:22
Hello,
I try to read AD value with the Adcin function on a 16F876 device.
It's very strange, I can read values with success only on port AN0.
If I try to get values on Port AN1 or AN2, I receive some random value...
I use PBP 2.42a .

Thanks for any idea or suggestion.

Charles


My code :
'
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 10

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000000 ' Right justify

ADIN VAR PORTA.1 ' work nice with PORTA.0 !!!
ADVAL VAR WORD

ADCIN ADIN,ADVAL
adval = (adval */ 500)>>2

BigWumpus
- 10th April 2006, 21:15
Just read the documentation of the adc-section.
You must set the right clockrate in ADCON0 for working at 20MHz !
There is a little table with useable settings !