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

Setting LATCH outputs with 8 bit binary
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 2:51 pm     Reply with quote

Quote:
int8 j[8] = {10001000,01110001,01010001,01100001,01111001,01110101,01110011,01110000};

What's the correct way to specify a number in binary format in C ?
spark



Joined: 03 Jan 2012
Posts: 17

View user's profile Send private message MSN Messenger

PostPosted: Wed Jan 04, 2012 3:11 pm     Reply with quote

Thanks for pointing it out. I had a look at the reference Manual (around page 40), but I still don't know it. Do I need to use const? Sorry for that, but I have no idea. Please tell me.... Crying or Very sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 3:51 pm     Reply with quote

No, you don't need to use 'const'. Without it, the array will be placed in
RAM, which is perfectly OK.

It just occurred to me that you mean you don't how to specify binary
format. Just put '0b' in front of each of the numbers in your array.
(Without the single quotes).
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jan 04, 2012 4:13 pm     Reply with quote

d'jou look at your LST file to see what this signed int8 compiles to??

Code:

int8 j[8] = {10001000,01110001,01010001,01100001,01111001,01110101,01110011,01110000};

IMHO - VERY odd notation you use there - so
after you read the .LST -- -is it REALLY what you were after??? [/b]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 4:18 pm     Reply with quote

It is all shown in the CCS manual. It gives the prefix to use:
Quote:

Expressions

Constants:
123 Decimal
0123 Octal
0x123 Hex
0b010010 Binary


Enough on bonehead programming. We don't need a huge thread on
basic bonehead stuff.
spark



Joined: 03 Jan 2012
Posts: 17

View user's profile Send private message MSN Messenger

PostPosted: Wed Jan 04, 2012 4:35 pm     Reply with quote

Thanks. It's working now.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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