portb.0 is an4 usemy wish is to set port B.0 to be the analog input (pin 8)
ADCIN 4, adval ' Read channel 0 to adval
and set adcon1 to %00010000
there is no need to use tris to set the pin to an input just use adcon1 to make it analogue
portb.0 is an4 usemy wish is to set port B.0 to be the analog input (pin 8)
ADCIN 4, adval ' Read channel 0 to adval
and set adcon1 to %00010000
there is no need to use tris to set the pin to an input just use adcon1 to make it analogue
Hi,
Hmm.... I think you've got that backwards...and set adcon1 to %00010000
Looking at the 18F1320 datasheet, ADCON1 defaults to 0 which means that AN0-AN6 are all analog. If AN4 is the ONLY pin to be used as analog you need ADCON1 = %11101111
/Henrik.
From the datasheet
.17.6 Configuring Analog Port Pins
The ADCON1, TRISA and TRISB registers all configure
the A/D port pins. The port pins needed as analog inputs
must have their corresponding TRIS bits set (input). If
the TRIS bit is cleared (output), the digital output level
(VOH or VOL) will be converted
Which I read as saying tris has to be set along with adcon1 to make it analogue?
Steve Earl www.datageo.co.uk
Bookmarks