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

Array in CCS

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



Joined: 04 Feb 2009
Posts: 83
Location: PA

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

Array in CCS
PostPosted: Fri Mar 13, 2009 2:04 pm     Reply with quote

I would like to take an 8 bit binary number, and separate the 8 bits into an array of size 8.
Can anyone help me with this?
I do know C a bit, but am not familiar with CCS.
Thank you!

Here is what I had started:
Code:
BYTE array[8]

...

void main(void){

int mynum = 0b00010101;
...
for int i =0; i<8; i++){
array[i] =
}
}

I just wasn't sure if I should somehow truncate mynum of if there is an easier way to separate this BYTE.

Thanks for any help with this fairly simple C question...
deperkin



Joined: 04 Feb 2009
Posts: 83
Location: PA

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

Array in CCS cont.
PostPosted: Fri Mar 13, 2009 2:18 pm     Reply with quote

maybe to clarify...

what i really would like to do is take in an analog signal...

seperate it, then send have of the lower byte to a nibble on one port and the other half of the lower byte to a nibble on another port.

THanks!!
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Fri Mar 13, 2009 2:19 pm     Reply with quote

Code:
BYTE array[8]

...

void main(void){

int mynum = 0b00010101;
...
for int i =0; i<8; i++){
array[i] = mynum & 1;
mynum >>= 1;
}
}


Would be a destructive way.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 13, 2009 2:25 pm     Reply with quote

See the integer to binary conversion routine in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=1523&start=1

Two more routines:
http://www.ccsinfo.com/forum/viewtopic.php?t=37877
deperkin



Joined: 04 Feb 2009
Posts: 83
Location: PA

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

Thanks
PostPosted: Fri Mar 13, 2009 2:36 pm     Reply with quote

Kudos to you both!

this is a big help.

BR
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