PDA

View Full Version : Acin command on 16F876, unable to read on AN1



krapoto
- 9th April 2006, 19:55
Hello,
I try to use the Adcin function on a 16F876 device, it's work nice only on port AN0 and I can't read on Port AN1, AN2, AN3... ?
I use PBP 2.42a .

Thanks for your help or Idea.


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

'

mister_e
- 11th April 2006, 05:16
First you must write the channel numer you want to read instead of the PIN name
ADCIN 0, Avar
ADCIN 1, AnotherVar

krapoto
- 11th April 2006, 21:11
Hi Steve,
Thank you for your advice, it's work fine now !

Charles




First you must write the channel numer you want to read instead of the PIN name
ADCIN 0, Avar
ADCIN 1, AnotherVar