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

DIP switches and Switch/case statements

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



Joined: 20 Jul 2011
Posts: 60

View user's profile Send private message

DIP switches and Switch/case statements
PostPosted: Tue Jul 26, 2011 2:00 pm     Reply with quote

Hi Everyone -

I am probably overlooking the obvious; however, after 30 minutes of forum and manual searches, I'm coming up a bit empty. I can think of away to do this with 4 variables, but that's seems rather "clunky".

Here's what I am looking to do:

I have 4 DIP switches on my board. We will use a switch/case statement to decode the 4 bits (which will give us 16 different combinations.)

Is there a way to concatenate the bits into a single variable?

Many thanks -

RckRllRfg
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 26, 2011 2:05 pm     Reply with quote

Quote:

I have 4 DIP switches on my board.
Is there a way to concatenate the bits into a single variable?

See the read_spare_bits() function in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=18949&start=8
RckRllRfg



Joined: 20 Jul 2011
Posts: 60

View user's profile Send private message

Excellent!
PostPosted: Tue Jul 26, 2011 2:18 pm     Reply with quote

Thank you. That is exactly what I was looking for!


RckRllRfg
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