I've just glanced at an old 16f690 program, which was unfeasibly huge so I've hacked it down & hopefully not missed anything during the slimming process...
You don't need to worry about ADCON0 (since the ADCIN command selects the ADC channel for you) *unless* you start wanting to use 10 bits, then you need to modify ADCON0.7 to suit (LH or RH Justify)Code:'------------------------------------------------------------------------- DEFINE ADC_BITS 8 ' ADCIN resolution (Bits) DEFINE ADC_CLOCK 1 ' ADC clock source (Fosc/8) DEFINE ADC_SAMPLEUS 11 ' ADC sampling time (uSec) ADCON1 = %0100000 ' FOSC/4 ' CM1CON0 = 0 'turn the pesky comparators off CM1CON1 = 0 'turn the pesky comparators off CM2CON0 = 0 'turn the pesky comparators off CM2CON1 = 0 'turn the pesky comparators off ' ANSEL = %0000010 'RA1 (pin 18) AN1 analogue ' PotVal Var Byte ' '********program starts...... ' adcin 1, PotVal ' '[do cool stuff with contents of PotVal here, then have a cup of tea & a nap]




Bookmarks