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

How Printf data as binary?

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







How Printf data as binary?
PostPosted: Mon Apr 14, 2003 4:06 am     Reply with quote

How can I format data(integer) as binary and send to LCD or RS232?
For example I have
byte tmp;
tmp=0b00001111;
and I want to show it on LCD as 00001111 not as \%U=15 or \%X=F

Thanks for help
___________________________
This message was ported from CCS's old forum
Original Post ID: 13651
R.J.Hamlett
Guest







Re: How Printf data as binary?
PostPosted: Mon Apr 14, 2003 4:52 am     Reply with quote

:=How can I format data(integer) as binary and send to LCD or RS232?
:=For example I have
:=byte tmp;
:=tmp=0b00001111;
:=and I want to show it on LCD as 00001111 not as \%U=15 or \%X=F
:=
:=Thanks for help
DIY.
So many different possible solutions, with varying degrees of speed/ROM overheads. Something like:

printbin(byte val) {
int8 mask;
mask=128;
while (mask) {
if (mask & val) putc('1');
else putc('0');
mask /= 2;
}
}

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13652
Bieli
Guest







Re: How Printf data as binary?
PostPosted: Mon Apr 14, 2003 6:25 am     Reply with quote

I was wondering is there any procedure or statment in CCS but if I have to I'll do it.

Thanks for idea.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13653
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