10bit ADC = 65536 ????


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Posts
    13

    Question 10bit ADC = 65536 ????

    I've set up a little program to try out adcin on 16f873A:

    Code:
    DEFINE LCD_DREG PORTB     ' LCD data port 
    DEFINE LCD_DBIT 4         ' LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTB    ' LCD register select port 
    DEFINE LCD_RSBIT 0        ' LCD register select bit 
    DEFINE LCD_EREG PORTB     ' LCD enable port 
    DEFINE LCD_EBIT 2         ' LCD enable bit 
    DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
    DEFINE LCD_LINES 4        ' Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
    DEFINE LCD_DATAUS 50      ' Data delay time in us
    
    DEFINE ADC_BITS 10 
    DEFINE ADC_CLOCK 3 
    DEFINE ADC_SAMPLEUS 50 
    
    input PORTA.0
    ADCON1 = ADCON1= %10001111
    
    DEFINE OSC 12
    
    Acquisition     var word
    Clr             CON 1
    Comm            Con $FE
    
    
    Main:
        ADCIN 0, Acquisition
        lcdout comm, clr, dec acquisition
        PAUSE 100
    goto Main
    Why it gives me a range of values from 0 to 65535 (5V)?? Shouldn't be 1024?

    PS. Setting 8bit gives me 256 values as it should be.
    Last edited by erpalma; - 13th January 2007 at 00:56.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    ?????
    Code:
    ADCON1 = ADCON1= %10001111
    i think you just trick the compiler with this one, try
    Code:
    ADCON1 = %10001111
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    and... mmm if you're using the internal Vref, you must use
    Code:
    ADCON1=%10001110
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    and... mmm if you're using the internal Vref, you must use
    Code:
    ADCON1=%10001110
    Really stupid error!

    Thanks!

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  3. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  4. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  5. Working with indivividual bytes of an array
    By J_norrie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd January 2007, 19:16

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