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

Passing a #bit into a Function

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Passing a #bit into a Function
PostPosted: Sun Oct 14, 2007 4:22 am     Reply with quote

I'm trying to figure out the best way to pass the CS pin address into a function that will control several different MAX3100 chips. Do I have to send the LAT address and the desired bit separately and then use bit_set/bit_clear. Or, is there a way that I can get the #bit into the function and twiddle it directly?

Thanks,

John
Ttelmah
Guest







PostPosted: Sun Oct 14, 2007 10:20 am     Reply with quote

First, if your compiler is recent (V4), then the standard bit set/clear functions, will accept a variable. Just hand the pin definiion, as a 16bit integer variable, and it'll work.
If not, then versions of the standard functions, that accept variables, have been posted here in the past.
Downside on both, is that the functions are larger, and a lot slower than the standard versions, working with constants. If the number of chips is small, then you will find it may be faster to write a simple 'switch' statement, to access the pins as constants, indexed by a variable to suit you.

Best Wishes
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Oct 14, 2007 1:07 pm     Reply with quote

I hadn't thought of the switch option. I was too caught up with my first approach. That will work great.

Thanks.
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