View previous topic :: View next topic |
Author |
Message |
proyectanteATE
Joined: 02 Feb 2011 Posts: 4
|
while LOOP with PIC18F4680 |
Posted: Fri Jun 24, 2011 4:23 am |
|
|
Hi everybody!!! If I have a while like this:
while(VPW_IN == level && VPW_IN == level)
{...}
the condition is the same two times, where VPW_IN is a pin D0 reading (1 or 0) in PIC 18F4680
Is it or not correct have the same condition two times??
I tried removing one of them, but it does not work well!!
What is the reason?
Thanks!!!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Jun 24, 2011 5:09 am |
|
|
It'd be interesting to see the listing for the code, to see how the compiler handles the duplicate.
However the pin might have changed state between readings...so not the same ! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Jun 24, 2011 8:40 am |
|
|
A slight 'extra' to this, might be the effect of RMW. Depending on how the pins are actually defined, and what is controlling TRIS, it does take time for pins to settle to a particular voltage, and the repeated test could be a crude way of allowing for this.....
Best Wishes |
|
|
|