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

getting individual bits out of a variable

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



Joined: 23 Apr 2009
Posts: 32

View user's profile Send private message

getting individual bits out of a variable
PostPosted: Wed May 27, 2020 10:09 am     Reply with quote

Here is what I need to do....

I read the serial stream (UART1)... I then want to pass to a function that I "bitbang" out to an oddball serial like device that does not fit the standard RS232 format.

Reading the port is not a problem, but I can't place my finger on how to extract out the bit pattern that I need to send. Input data is standard RS232 framed data.


Last edited by Frozen01 on Wed May 27, 2020 10:48 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 27, 2020 10:28 am     Reply with quote

Quick comment..
CCS has a 'bit test' function you can use ! Check the manual for the correct syntax, but a simple 'loop' from 0 to 7, or 7 to 0, will 'extract' the bit from the byte, then you can do 'whatever' to send to the other device.
0 to 7 will get lsb to msb, 7 to 0 gets high bit first...

There may be an example in the code library, it's been used to send '1' or '0' to an LCD to 'show' the binary equal to a byte.

jay
Frozen01



Joined: 23 Apr 2009
Posts: 32

View user's profile Send private message

PostPosted: Wed May 27, 2020 11:40 am     Reply with quote

I got something working, ended up just using a for loop...
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun May 31, 2020 10:37 am     Reply with quote

Right...

With a loop, you can either use the bit_tes() function and/or roll the bits using >> or << operators.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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