Searching \ for '[PIC]:rmw problem with a/d port?' 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/ios.htm?key=a%2Fd
Search entire site for: 'rmw problem with a/d port?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:rmw problem with a/d port?'
2001\04\30@144040 by Mike Mansheim

flavicon
face
I think I've just run into a rwm effect, but not because I'm changing
port directions.
F876 portA configured as follows (set once, doesn't change):
RA0, RA3:       analog in
RA1, RA2, RA5:  out
RA4:            digital in
ADCON1:  RA0,1,3 as analog in, RA2,5 as digital i/o.
Whenever RA2 or RA5 are changed, RA1 goes low unexpectedly.
According to the data sheet:
"When reading the port register, any pin configured as an analog input
channel will read as cleared (a low level)."
I assumed this referred to the ADCON1 setup AND the tris direction, i.e
it was analog IF it was an input, so I figured I was ok using RA1 as an
output.  RA1 was an analog in, but was last minute changed to an output.
There are only certain allowable combinations of analog & digital pins,
so I can't just independently declare RA1 as digital i/o.
Obviously RA1 is behaving as though it is getting read as a low
as part of changing one of the other bits in the port (classic rmw).
My questions are:
- have I diagnosed the problem correctly?
- I can fix this by simply refreshing RA1 to it's correct state after
 any operation on the rest of the port.  Is this ok, or is there some
 bigger problem with using an analog input pin as a digital output?

Thanks for any help.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\30@153644 by Dipperstein, Michael

face picon face
If ADCON sets RA1 to be an analog input, then it doesn't matter what TRISA is
set to, RA1 will be an analog input.

You might want to make RA3 your digital output and use RA1 as an analog input.

-Mike
{Original Message removed}

2001\04\30@162929 by Jeff DeMaagd

flavicon
face
----- Original Message -----
From: Dipperstein, Michael <.....mdippersKILLspamspam@spam@HARRIS.COM>


> If ADCON sets RA1 to be an analog input, then it doesn't matter what TRISA
is
> set to, RA1 will be an analog input.

Sorry, I believe that the appropriate TRISA bit has to be set as an input, I
have actually run across a situation where the digital circuitry of the pin
forced the pin high or low, and made the midrance highly non-linear on
analog readin.

"The analog input channels must have their corresponding TRIS bits selected
as inputs."
PIC16F872 data sheet, p87

Maybe some chips aren't like this but there is actually a case for it.  Read
the appropriate data sheet for the chip in question.  I've found that it's
very easy to overlook critical information in Microchip's data sheets.

Jeff
demaagd.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\30@191057 by Tony Nixon

flavicon
picon face
Mike Mansheim wrote:
>
> I think I've just run into a rwm effect, but not because I'm changing
> port directions.
> F876 portA configured as follows (set once, doesn't change):
> RA0, RA3:       analog in
> RA1, RA2, RA5:  out
> RA4:            digital in
> ADCON1:  RA0,1,3 as analog in, RA2,5 as digital i/o.
> Whenever RA2 or RA5 are changed, RA1 goes low unexpectedly.
> According to the data sheet:

If you use BSF PORTA,RA2 or BCF PORTA,RA2 or BSF PORTA,RA5 or BCF
PORTA,RA5, then the PORT will be read, but RA1 being analog, will always
read as 0 as you have stated. That 0 value will be written back to RA1.
Also, all the other output latch bits get set the same as they were
read, and RA2 or RA5 will be set according to the instruction.

Try using a shadow register for PORTA, and do the BSF BCF etc on it, and
then write the 8 bit value to PORTA.

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
.....salesKILLspamspam.....picnpoke.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body



'[PIC]:rmw problem with a/d port?'
2001\05\01@125034 by Dwayne Reid
flavicon
face
At 01:28 PM 4/30/01 -0500, Mike Mansheim wrote:
>I think I've just run into a rwm effect, but not because I'm changing
>port directions.
>F876 portA configured as follows (set once, doesn't change):
>RA0, RA3:       analog in
>RA1, RA2, RA5:  out
>RA4:            digital in
>ADCON1:  RA0,1,3 as analog in, RA2,5 as digital i/o.
>Whenever RA2 or RA5 are changed, RA1 goes low unexpectedly.
>My questions are:
>- have I diagnosed the problem correctly?
>- I can fix this by simply refreshing RA1 to it's correct state after
>   any operation on the rest of the port.  Is this ok, or is there some
>   bigger problem with using an analog input pin as a digital output?

Yes to both.  Hopefully, whatever is being fed by pin RA1 won't get upset
by the glitch.

You can avoid the problem by not using R-M-W operations on that port.  Use
a separate register (often called a "shadow register") for your bit
manipulations.  Then write that register to the port.

dwayne



Dwayne Reid   <dwaynerspamspam_OUTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


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