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 support@ccsinfo.com

Conditional statements

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



Joined: 11 Dec 2007
Posts: 2

View user's profile Send private message

Conditional statements
PostPosted: Mon Jan 07, 2008 10:31 am     Reply with quote

Dear all,

I have little experience in CCS-C so I apologise for the newbie question!

I have some code that runs an infinite loop (while(true)) and has inside it a further statement, they look a little like this:
Code:
main()
{
 startup inc interrupts and timer1 setup
 print startup output
 while(true)
  {
   if ((input(PIN_B0) == 0) && connected == _OFF)
      {
      Print Debug statement
      CODE
      }
    other code
   }
}

I've monitored "connected" and it never changes, unless instructed to do so, from _OFF.
PIN_B0 sits at 5v(1) indefinitely, unless I drag it low, and so the CODE should not be executed. At powerup I get the startup output and then nothing - which seems ideal. As soon as I hit transmit a character to the device via serial connection the debug and CODE statements are executed, despite PIB_B0 apparently never going to 0 (hardware holds it high).

Have I missed something? Is there any condition where these inputs can change?
coyoteboy



Joined: 11 Dec 2007
Posts: 2

View user's profile Send private message

PostPosted: Mon Jan 07, 2008 11:00 am     Reply with quote

I've cured this by repeatedly sampling the pin and averaging, as the HIN232 that feeds the B0 pin seems to be falling low when it should not - possibly a power rail problem.
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