ADCIN on 18F8722


Results 1 to 5 of 5

Threaded View

  1. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: ADCIN on 18F8722

    Quote Originally Posted by nobner View Post
    Hello together,
    i want to use the AD-Converter on the 18F8722 for the first time.
    I want to use the AN0 and the AN1 channel.
    So I looked in the Data-Sheet and wrote this out:

    DEFINE ADC_BITS 10 'trying with 10 bits resolution
    DEFINE ADC_CLOCK 3 'Is this clock the same as my system clock (external
    '8MHz crystal)?
    DEFINE ADC_SAMPLEUS 50 'Took it from the manual, is it correct?

    TRISA=%00001111 'Setting RA0 to RA3 to inputs
    ADCON0=%00000111 'using AN0 and AN1
    ADCON1=%00001101 'using supply voltage as vref, setting AN0 and AN1 to
    'analog inputs
    ADCON2.7=1 'result is right justified

    ...and then the ADCIN 0, variable....?

    Do I have to do other settings for ADCON2, when i'm using ADCIN?
    Are these settings above correct, or is something missing?

    Thanks in advance!!
    I could be wrong (if so, someone please correct me!), but the adcon0 register can be disregarded if using the picbasic adcin command...it sets the adcon0 register 'behind the scenes' for you (this area confused the hell outta me when I came to try & suss it). FWIW, your extract here...

    ADCON0=%00000111 'using AN0 and AN1

    wouldn't be as you've outlined, bit 0 turns the ADC module on, bit 1 is the ADC conversion status bit, bit 3 selects AN0. So to select AN0 would be

    ADCON0=%00000101

    selecting AN1 would be...

    ADCON0=%000001001


    ...and so on - ie you can only have on ADC channel selected at any one time....but the ADCIN command sorts the channel selection for you.
    Last edited by HankMcSpank; - 27th May 2011 at 21:13.

Members who have read this thread : 0

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

Posting Permissions

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