Searching \ for '[PIC] Reading AN5 but getting AN2' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Reading AN5 but getting AN2'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Reading AN5 but getting AN2'
2008\07\03@113305 by Martin

face
flavicon
face
For some reason I read AN5 I get the value on AN2.

As it turns out I was setting the GO and ADON bits at the same time.
Don't do that!

-
Martin

2008\07\03@124317 by Mark Scoville

flavicon
face
I've always avoided setting ADON and GO/DONE in the same instruction - I'm
pretty sure this is pointed out in some of the datasheets. Now I know why!

-- Mark

{Quote hidden}

> -

2008\07\03@130331 by Martin

face
flavicon
face
Mark Scoville wrote:
> I've always avoided setting ADON and GO/DONE in the same instruction - I'm
> pretty sure this is pointed out in some of the datasheets. Now I know why!
>
> -- Mark
>

It worked for everything except AN5. I'm using AN0-AN5 which get read
sequentially by a state machine in the ISR. Because it worked for the
rest I assumed it should have worked in this case.

-
Martin

2008\07\03@144451 by olin piclist

face picon face
Mark Scoville wrote:
> I've always avoided setting ADON and GO/DONE in the same instruction
> - I'm pretty sure this is pointed out in some of the datasheets. Now
> I know why!

Even if it wasn't, it clearly doesn't allow any acquisition time.

********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2008\07\03@144607 by olin piclist

face picon face
Martin wrote:
> It worked for everything except AN5. I'm using AN0-AN5 which get read
> sequentially by a state machine in the ISR. Because it worked for the
> rest I assumed it should have worked in this case.

Unless there is a long time between readings, you don't want to turn off the
A/D anyway.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2008\07\03@192237 by Martin K

face
flavicon
face
Olin Lathrop wrote:
> Mark Scoville wrote:
>  
>> I've always avoided setting ADON and GO/DONE in the same instruction
>> - I'm pretty sure this is pointed out in some of the datasheets. Now
>> I know why!
>>    
>
> Even if it wasn't, it clearly doesn't allow any acquisition time.
>
> ********************************************************************
> Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
> (978) 742-9014.  Gold level PIC consultants since 2000.
>  
The part I am using (18F4321) automatically waits the programmed
acquisition time after the GO bit is set before conversion commences.
This is assuming the A/D is already on, which it should be anyway after
initialization. I'm just making sure the A/D remains on by setting the
ON bit at every instance of the A/D interrupt. Perhaps not necessary.

-
Martin

2008\07\04@065148 by olin piclist

face picon face
Martin K wrote:
> I'm just making sure the A/D remains on by
> setting the ON bit at every instance of the A/D interrupt. Perhaps
> not necessary.

Once the A/D is on, it will remain on until explicity turned off.  The
hardware never turns off the A/D on its own, like it does the GO/DONE bit
for example.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2008\07\06@223843 by Jinx

face picon face
> For some reason I read AN5 I get the value on AN2.
>
> As it turns out I was setting the GO and ADON bits at
> the same time. Don't do that!

Just flicking through AN546

http://ww1.microchip.com/downloads/en/AppNotes/00546e.pdf

to check something and saw, page 4

Additional tips:

a) Do not set bits GO/DONE and ADON in the
same instruction. First, turn the A/D is on by setting
bit ADON. Then allow at least 5us before
conversion begins (setting the GO/DONE bit),
longer if sampling time requirement is not met
within 5us

b) Aborting a conversion: A conversion can be
aborted by clearing bit GO/DONE. The A/D
converter will stop conversion and revert back to
sampling state

c) Using the ADRES register as a normal register:
The A/D only writes to the ADRES register at the
end of a conversion. Therefore, it is possible to
use the ADRES register as a normal file register
between conversions and when A/D is off

2008\07\07@085641 by Martin

face
flavicon
face
Jinx wrote:
{Quote hidden}

AN546 references the pretty-old 16C71. The 18F parts have an acquisition
timer that doesn't require you to wait.

-
Martin

2008\07\07@091613 by Jinx

face picon face
> AN546 references the pretty-old 16C71. The 18F parts have an
> acquisition timer that doesn't require you to wait

That's true, but there is a manual option also, ACQT2:ACQT0 = 000

2008\07\07@092112 by Jan-Erik Soderholm

face picon face
Martin wrote:

> AN546 references the pretty-old 16C71.
> The 18F parts have an acquisition
> timer that doesn't require you to wait.

Some of the *newer* PIC18's...

And they still say that you should not set
ON and GO in the same instruction, even if you
do not have to wait between them...

Jan-Erik.

2008\07\07@094457 by Martin

face
flavicon
face
Jan-Erik Soderholm wrote:
> Martin wrote:
>
>> AN546 references the pretty-old 16C71.
>  > The 18F parts have an acquisition
>> timer that doesn't require you to wait.
>
> Some of the *newer* PIC18's...
>
> And they still say that you should not set
> ON and GO in the same instruction, even if you
> do not have to wait between them...
>
> Jan-Erik.

Yes, this has been established if you read the rest of the thread.

-
Martin

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...