Jump to content
Sign in to follow this  
Mac

Binary number format in C (CCSv4)?

Recommended Posts

G'day Gentlemen,

 

May I impose to ask how to use a binary number format in C in CCSv4, please? I've tried a few different formats so far but no joy (0b00000001, %00000001, and 000000001b).

 

Cheerful regards, Mike McLaren

Share this post


Link to post
Share on other sites

You can define a function that will convert your "binary" input (long) and return a value.

BIN(00100010)

Or you can waste some time and create include file with 256 binary numbers as definitions :)

#define B00001111 0x0F

#define B00010000 0x10

etc.

Share this post


Link to post
Share on other sites

Thank you very much for the reply and the link. It sounds like the binary number format isn't supported which would explain why I haven't seen it in any of the 430G' example C programs.

 

May I ask if the MSP430 Optimizing C/C++ Compiler v 3.1 User Guide that was referred to in that link is the language manual for the Compiler within CCSv4? Or, is there a CCSv4 Optimizing C/C++ Compiler User Guide I should be looking for, please?

 

Thank you again for your time and kind consideration Gentlemen.

 

Cheerful regards, Mike McLaren

Share this post


Link to post
Share on other sites

Here's an interesting thread about this issue:

http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/60157.aspx

 

I guess it boils down to the fact that binary representation isn't oficially supported by the C language. A couple of solutions are offered by the thread. One is that header file with all the defines already made, the other is a macro. I'm not an expert on compilers, but I'd think the header would do the job fine without wasting cpu cycles.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...