One of the most used, especially on Linux machines, is the mspgcc.
This article explain how to install one of the versions of this compiler.
What version to use ?
There are different versions of this compiler.
However, is a good starting point to use the one officially endorsed by Texas Instrument.
At the writing date, the "officially endorsed version of mspgcc" is the 3_02_03_00.
These instructions are for Linux only ! I'm not covering Windows at this time (and probably I'll never cover it).
Go to the Texas Instrument website and download this code :
Basically the first code is what we need to install the MSP430 C compiler on our machine.
In order to download the code is necessary to register to the Texas Instrument website and answer to a questionnaire.
Once downloaded the files we can proceed to install it on our machine.
At the writing time of this article the MSP430 gcc (msp430-elf-gcc) version is the 4.9.1
InstallationCopy the file msp430-gcc-full-linux-installer-188.8.131.52.run in a directory, chmod it to allow execution, then run it.
A guided installation menu will appear.
Once installed, add the path where the compiler is installed, in the system variable path.
For example under xbuntu (Ubuntu, Kubuntu, Lbuntu, ecc.) is enough to edit the file .profile in the home directory.
It is easy to create a local variable and then add it to the $PATH with export.
For example, assuming the toolchain was installed in /home/username/ti, add at the end of the .profile file :
Save the file and reboot the computer.
Opening a terminal after that operation, the path of the compiler should be available.
To test it, try to run the command msp430-elf-gcc :
msp430-elf-gcc: fatal error: no input files
Note that it will be available also the specific system variable MSP430_TI, necessary in the makefile usage.
Tuning the system
There are some differences between this version of the MSP430 GCC compiler and previous ones.
Some include files are not present, others have some basic define name differences.
Let see some differences to be addressed:
- the compiler flag mmcu requires specific component name.
Not anymore msp430xtype but msp430ftype.
So for example, instead of msp430x169, msp430f169 must be used.
- Be sure to use the correct compiler name:
- It must be used the inclusion path for the headers file and environment libraries
In the flag part :
CFLAGS=-O0 -Wall -g -mmcu=msp430f2013 -I$(MSP430_TI)/include -L$(MSP430_TI)/include
It is assumed of course that exists a system variable called MSP430_TI as described in this article.
- the header file io.h doesn't exists
- be sure to include in the source file the file msp430.h header since specific component defines are included there
- the interrupt declaration is different
To declare an interrupt, now the declaration needs to be split in two lines and changed.
For example, for the timer A interrupt, the syntax is:
void Timer_A (void)
It is possible to have other some issues on this, older versions of this line of MPS430 gcc toolchain require different syntax, TI changed some things along the way
- #include <io.h> is obsoleted, don't include it anymore
- #include <msp430legacy.h> is obsoleted, don't include it anymore
- #include <msp430.h> must be present in any source file
- #include <signal.h> need to be present for interrupt operations
Here some useful links to the documentation I found so far :