Data types and memory handling

MSP430 architecture processors use a single address space to map data and code. The registers and memory are 16 bits wide, and the CPU can only read and write 16 bit data at even addresses. If you attempt to read or write a 16 bit value at an odd address, the CPU behaves as if the LSB is not set. The processor has no exception handling. The MSP430 can read and write 8 bit data at any address.

The C compiler supports the following basic data types

All the integer types are supported in signed and unsigned forms. Pointers are always 2 bytes wide.

All global variables with the "const" attribute are allocated in the main ROM space. They are normally placed in the .text section. Accessing "const" variable is no different than accessing to any other type of variable. If the device uses flash memory and the flash memory is enabled for writing, you can write to the flash. You can place "const" variables to RAM, using the attribute "section(".data"))" as follows:

const char __attribute__ ((section(".data"))) foo = 1;
Please note that if you declare variables r0 - r15, the assembler will prepend '_' in order to allow the assembler to distinguish them from the registers names.

Variables larger than one byte are always located at an even address. Single byte variables can be located at any address.