CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

while LOOP with PIC18F4680

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
proyectanteATE



Joined: 02 Feb 2011
Posts: 4

View user's profile Send private message

while LOOP with PIC18F4680
PostPosted: Fri Jun 24, 2011 4:23 am     Reply with quote

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: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 24, 2011 5:09 am     Reply with quote

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: 19539

View user's profile Send private message

PostPosted: Fri Jun 24, 2011 8:40 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group