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 to convert the code in PBP "shiftout" into C?

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



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

How to convert the code in PBP "shiftout" into C?
PostPosted: Wed Oct 12, 2005 9:58 am     Reply with quote

Hi everybody,
I would like to know how to convert the code in PBP as "shiftout SI,SCK,1,[%1100\4]" into C. I have read some topic about converting "shiftout" command as follow:


Code:
void ShiftOut (int8 data)
   {
     output_low(OUT_CLOCK);

     if((data&0x80)==0) 
       output_low(OUT_DO);
     else
       output_high(OUT_DO);
     data <<= 1;
     output_high(OUT_CLOCK);
     output_low(OUT_CLOCK);
   }


I want to add the variable like "OUT_CLOCK", "OUT_DO" as follow:
Code:
 void ShiftOut(int16 OUT_CLOCK, int16 OUT_DO, int8 data)


Is it possible to do this code? Any idea? or suggestion? Question

Thanks,
ako
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 12, 2005 11:12 am     Reply with quote

output_high and output_low take constants as a parameter. Short answer to you question, NO you can't use a parameter as a constant. You could write you own function that accepts a variable though. This has been discussed here before.

http://www.ccsinfo.com/forum/viewtopic.php?t=24315&highlight=outputhigh+variable+parameter
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

port variable
PostPosted: Wed Oct 12, 2005 6:40 pm     Reply with quote

Hi,
Thank for your response, Mark. I agree with you. But the following topic has been shown about port variable. I am not sure this method is indirect method or may be CCS style.

http://www.ccsinfo.com/forum/viewtopic.php?t=23837&highlight=button

Thanks,
ako
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 12, 2005 8:53 pm     Reply with quote

The pin numbers are CCS specific but do have some meaning. Basically the port address multiplied by 8 then the bit number added to it. If you read PCM's response in the link I posted, he shows you how to do what you want with port pins.
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