Writing MSP430 C Code
Device Specific Files (.h and .cmd)
TI has created a device-specific header file (.h) and linker command file (.cmd) for each specific
MSP430 device. With the MSP430F5529 device as an example, if you look through the files
installed with the MSP430 compiler, you’ll find: msp430f5529.h and msp430f5529.cmd
Example: Device Specific ‘Header’ Files
1. Device header file ( msp430f5529.h )
Register bit-field symbols are found in ‘header’ file
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
2. Device linker command file ( msp430f5529.cmd )
Symbols that represent register locations – which are effectively
addresses – are found in the ‘linker’ command file
Below is an example of using the MSP430 ‘header’ files.
This example will be used in the upcoming lab exercise. It turns off the
Watchdog Timer (WDT). We have to setup the WDT in every MSP430 program.
(We explain why in Chapter 4 of the workshop.)
Notice how “address” values (i.e. register locations) are found in the .cmd
file, while all other symbol definitions are found in the .h file.
As described in the above diagram, these two files provide symbolic definitions for all registers
and bitfields found in each CPU and its peripherals.
What’s the simple key to figure out which file contains a given symbol?
• If the symbol relates to an address, such as the symbol for a memory-mapped register (e.g.
WDTCTL), you’ll find it defined in the .CMD file. This is because the linker (and its associated
linker command file) specifies memory allocations and addresses.
• All the other device-specific symbols are described in the header (.h) file, as is common
practice for the C language.
2 - 24 MSP430 Workshop - Programming C with CCS