|
|
View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Passing a #bit into a Function |
Posted: Sun Oct 14, 2007 4:22 am |
|
|
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
|
|
Posted: Sun Oct 14, 2007 10:20 am |
|
|
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
|
|
Posted: Sun Oct 14, 2007 1:07 pm |
|
|
I hadn't thought of the switch option. I was too caught up with my first approach. That will work great.
Thanks. |
|
|
|
|
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
|