Analog port newbie questions


Results 1 to 10 of 10

Threaded View

  1. #3
    Join Date
    Feb 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Hi jumper, these are my settings for ADC

    define OSC 20
    define adc_bits 10 'define number of bits in result
    define adc_clock 3 'clock source3=RC
    define adc_sampleus 50 'set sampling time in microsec

    adc1 var word 'store adc input values, adc1=AN0/RA0
    adc2 var word 'AN1/RA1
    adc3 var word 'AN2/RA2
    adc4 var word 'AN4/RA5

    trisa = %11111111 'port A all input

    adcon1 = %10000011 '1 for Result Format Selection Bit because using 10 bits
    '0011 for AN4, AN2, AN1, AN0 analog port. AN3 is
    'Vref+ reference voltage
    pause 500 'wait .5 second


    Im using the 16F877A. This is my main program and it is supposed to input 4 analog values, do some comparison and then high some ports.

    Ive tried a simpler version to test out the port also,


    define osc 20

    define adc_bits 10 'define number of bits in result
    define adc_clock 3 'clock source3=RC
    define adc_sampleus 50 'set sampling time in microsec

    trisa = %11111111
    trisd=0
    adcon1 = %10000010

    pause 500

    adc var word

    start:

    adcin 0, adc

    if adc > 10 then
    high portd.0

    else
    low portd.0

    endif

    pause 500

    goto start



    When I input 2.5V into porta.0 the LED does not turn on. If I leave the pin floating (5V) then it turns on. If I change the code to 'adc>0', it turns on.
    edit: I think the port A of my PIC is fried. When power is on but nothing is connected, the port A pins are at 5V. Is this normal ? Help pls !
    Last edited by rngd; - 8th March 2008 at 18:02.

Similar Threads

  1. pic18f analog comparator problem
    By david.silaghi in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th May 2009, 09:38
  2. Pic getting part power from Analog Port
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 22nd April 2009, 10:34
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Hi Everyone! Some newbie questions :-)
    By guest_05 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th October 2006, 22:24
  5. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59

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