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

How set parameter input(pin) command

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



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

How set parameter input(pin) command
PostPosted: Tue Feb 19, 2008 12:49 am     Reply with quote

#define INPUT_A PIN_B0
#define INPUT_B PIN_B1
#define INPUT_C PIN_B2
#define OUTPUT_A PIN_A0
#define DATA_1 0 // or 1

My code is now this, two while-loop.

void program()
{
output_high(OUTPUT_A);
if(DATA_1 == 0)
{
while((input(INPUT_A) == 1) && (INPUT_C == 0))
{
...
...
}
}
else
{
output_low(OUTPUT_A);
while((input(INPUT_B) == 1) && (INPUT_C == 0))
{
...
...
}
}
return;
}

I want write code one while-loop, but how?

void program()
{
output_high(OUTPUT_A);
data_x = ??; // How i do this?
if(DATA_1 == 1)
{
data_x = ???; // How i do this;
output_low(OUTPUT_A);
}

while((input(data_x) == 1) && (INPUT_C == 0)) // How i do this?
{
...
...
}

return;
}

SORRY BAD ENGLISH.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 12:55 am     Reply with quote

Post your compiler version.
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 1:17 am     Reply with quote

PCM programmer wrote:
Post your compiler version.

4.066 (PCW)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 1:46 am     Reply with quote

I don't completely understand your problem. Your code has many
strange things in it.

Quote:

#define DATA_1 0 // or 1

if(DATA_1 == 1)
{

Because DATA_1 is defined as 0, the code above is the same
thing as this code:
Quote:
if(0 == 1)
{

The if() statement will not execute. Is that what you want to happen ?


Then you have this code:
Quote:

#define INPUT_C PIN_B2

while((input(INPUT_A) == 1) && (INPUT_C == 0))
{

But INPUT_C is defined as PIN_B2, so the code is the same as this:
Quote:
while((input(INPUT_A) == 1) && (PIN_B2 == 0))
{

(PIN_B2 == 0) will always be False. So the while() statement will
never execute.

Your code has too many problems. Please fix all the problems
so I can understand it.
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