ADC not working - I'm a new member


Results 1 to 13 of 13

Threaded View

  1. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: ADC not working - I'm a new member

    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...

    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]
    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)
    Last edited by HankMcSpank; - 16th June 2011 at 19:31.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts