Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Binary numbers in MSP430?

$
0
0

Hello guys,

 

I have some experience programming ARM-based MCU's (Tiva C in particular) and over there I always declared ports using binary numbers. For example, I always declared the GPIO pins this way:

// Set pin 7 (could also be the Hex equivalent, 0x80):
GPIO_PORTC_DIR_R = 0b10000000;

// Digital enable of of Pin (needs to be 1 in order to be enabled):
GPIO_PORTC_DEN_R = 0b10000000;
        
// Turn LED ON:
// Data of the pin (a 1 or a 0):
GPIO_PORTC_DATA_R = 0b10000000;

I have noticed that all the examples of the MSP 430 use the following notation:

 P1DIR |= BIT0;                            // Set P1.0 to output direction

However, looking into the header files, I see that an equivalent would be this:

// Same as P1DIR, but low level:
 PADIR_L |= 0x0000;

Due to my crazy antiques, I prefer to program using this last mentioned notation. However, I also prefer declaring the numbers in binary instead of hex notation. Is there a way to declare the 0x0000 in binary? I tried 0b0000000000000000, to no avail. Is the 0b notation something specific to ARM MCU's? Is there a way to do this with the MSP 430 or should I stick with Hex?

 

Thank you very much!


Viewing all articles
Browse latest Browse all 2077

Trending Articles