ADC reading and configuration problem


Results 1 to 5 of 5

Threaded View

  1. #1

    Question ADC reading and configuration problem

    Hi everyone,

    I can't get my ADCs to working properly. I've tried to play with the registers, with no results.

    I have to sample 4 analog inputs.

    Only one reading is correct, it's the "tsense" refered to the ADCIN5. The others values displayed are completely crazy.

    I'm using the PIC18F4431 ( datasheet : http://ww1.microchip.com/downloads/e...Doc/39616d.pdf )

    The simple code used for the test :
    Code:
    DEFINE OSC 32      
    DEFINE LCD_DREG PORTC
    DEFINE LCD_EREG PORTD
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_EBIT 0
    DEFINE LCD_RSBIT 1
    DEFINE ADC_BITS 10
    
    TRISA=%11111111
    TRISB=%11000000   
    TRISC=%110000     
    TRISD=%11100      
    TRISE=%11111111
    
    ANSEL0=%11111111
    ADCON0=%00011111
    ADCHS=%01010101
    
    potsense var word
    tsense var word
    usense var word
    isense var word
    
    pause 2000
    LCDOUT $fe,1 
    
    lp:
    
    ADCIN 4,potsense
    ADCIN 5,tsense
    ADCIN 6,usense
    ADCIN 7,isense
    
    lcdout $fe,$2,DEC5 potsense," ",DEC5 tsense
    lcdout $fe,$c0,DEC5 usense," ",DEC5 isense
    
    pause 10
    
    goto lp
    Last edited by pxidr84; - 25th March 2011 at 18:17.

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