A/D IO pins changing function while running?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    I found this interesting so looked a bit more...
    I've done a couple of projects with analogue in that worked great

    I think your program is resetting bits in ADCON1 register and resetting ports back digital
    depending on the value read from the port that starts out analogue.

    For an 8 bit result, setting ADCON1:7 to zero sets the 10 bit result left justified so you
    only see the high 8 bits in the word which are most significant because you access the
    high byte of a word with the 10 bit result shifted into place.
    How much of this is handled by PBP I don't remember, but that's what's happening.
    Otherwise the 10 bit result is right justified, and you see a 16 bit word who's leading
    6 bits are always zero, and that's the 10 bit result.

    I'll bet that you're making PBP access a 16 bit word comprised of the ADCON1 register,
    and the lower end result register, and that's somehow enough to wreck the contents
    of ADCON1, and leave your program running with a digital port.

    I was thinking asm when doing this,
    it would be nice if someone else has any thoughts on what PBP is doing.
    I suspect the DEFINE would set the ADCON1 bit 7 without touching the other bits,
    and setting it again directly might only override it.
    Last edited by Art; - 6th June 2013 at 16:45.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    I had some issues in the past similar to this. Try putting your main001: label under your DEFINEs so it essentially reboots each time it goes there.

  3. #3
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    Thanks Art, I corrected that error but the problem persists. What I have found is that while in a tight loop reading any A/D input the input impedance becomes much lower and causes A/D readings that are way out of whack. For example; I have a 10k input resistor and there is .212 volts on the input and .108 on the processor side while continuously reading. If I comment out the line that reads the A/D I get .212 volts on both sides of the resistor.

  4. #4
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    In addition if I comment out the line that turns on PWM I get no voltage drop across the input resistor and the A/D reads the voltage correctly. It almost appears as if the PWM is affecting the A/D.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    If you connect your PWM output to a scope or even an LED, does it behave correctly?

  6. #6
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Cool Re: A/D IO pins changing function while running?

    Thanks to everyone for their help! I found the actual problem yesterday. As it turns out there was a transient coming in on an A/D pin other than the one I was using to measure the high voltage. I removed that input and the product regulates precisely. Lesson learned: transient voltages on any A/D input can effect the operation of other inputs of the A/D input multiplexer.

    TR

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: A/D IO pins changing function while running?

    It's hair pulling stuff when your programming problem was really an electronics problem,
    or vice versa.

Similar Threads

  1. 18F4550 not running
    By comwarrior in forum General
    Replies: 6
    Last Post: - 1st January 2011, 01:07
  2. Cant get my PIC running
    By Viberer in forum Off Topic
    Replies: 13
    Last Post: - 29th August 2008, 20:07
  3. Changing several o/p pins at the same time
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 1st August 2008, 21:14
  4. PIC - 8 Pins - 6 Output Pins ?
    By DanPBP in forum Off Topic
    Replies: 0
    Last Post: - 22nd October 2007, 00:23

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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