Adcin on a 16F876


Closed Thread
Results 1 to 2 of 2
  1. #1
    krapoto's Avatar
    krapoto Guest

    Default Adcin on a 16F876

    Hello,
    I try to read AD value with the Adcin function on a 16F876 device.
    It's very strange, I can read values with success only on port AN0.
    If I try to get values on Port AN1 or AN2, I receive some random value...
    I use PBP 2.42a .

    Thanks for any idea or suggestion.

    Charles


    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

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Just read the documentation of the adc-section.
    You must set the right clockrate in ADCON0 for working at 20MHz !
    There is a little table with useable settings !
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

Similar Threads

  1. ADCIN and PIC18F4331 Arghhhhh !
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2010, 20:27
  2. How to make adcin stable?
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th January 2009, 07:41
  3. ADCIN Problem
    By JavPar in forum General
    Replies: 33
    Last Post: - 20th January 2009, 03:36
  4. ADCIN problems with PIC16F73
    By passion1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 26th July 2007, 11:38
  5. help using adcin
    By harryweb in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st January 2006, 07:46

Members who have read this thread : 1

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