Translate

Saturday, March 14, 2015

MSP430 GCC compiler

For the MSP430 family there are many different compiler out there.
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 :

MSP430-GCC Product Downloads
TitleDescriptionSize
Unlockedmsp430-gcc-full-linux-installer-3.2.3.0.runRedhat GCC Linux installer incl. support files and debug stack and USB drivers - apply chmod x before executing the package77640K




msp430-gcc-support-files.zipHeader Files18044K
msp430-gcc-source.tar.bz2Redhat GCC source filesK
md5sum.txtMD5 Checksums4K

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

Installation

Copy the file msp430-gcc-full-linux-installer-3.2.3.0.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 :

export MSP430_TI="/home/username/ti/gcc"
export PATH="$PATH:$MSP430_TI/bin"

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
msp430-elf-gcc: fatal error: no input files
compilation terminated.


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:

Makefile
  • 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:

    CC=msp430-elf-gcc
  • 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.
Source file
  • 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:

    __attribute__((__interrupt__(TIMERA0_VECTOR)))
    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 file
  • #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

Links


Here some useful links to the documentation I found so far :


2 comments:

  1. Thanks!

    One comment:
    Are export PATH="$PATH=$PATH:$MSP430_TI/bin" correct or did you mean export PATH="$PATH:$MSP430_TI/bin"

    ReplyDelete