Table of Contents
KEY TAKEAWAYS
- The MSP430 can be programmed without an IDE using the MSP430 GCC toolchain and mspdebug
- Install the MSP430 GCC compiler, MSP Debug Stack, and mspdebug for a command-line workflow
- Write Makefiles to automate compilation, linking, and flashing of MSP430 programs
- This setup gives full control over the build process and works well with version control
Overview for setting up TI MSP430
Traditionally, we select a microcontroller and use the IDE provided along with it. In our case, we are working with an TI MSP430 from Texas Instruments (TI), and they provide Code Composer Studio (CCS) IDE for development. The usually approach would be to download and install CCS, then write, build and upload an executable onto the target device (TI MSP430) using the Flash Programmer. This form of abstraction removes a majority of underlying commands from our control for instance compile time switching. In this article we will see how knowing the build process is useful. The approach will primarily be based on Windows 10 for majority of the audience.Requirements for TI MSP430
- Install Make to automate the build process.
- Install MSP430-GCC-OPENSOURCE toolchain, and include files from Texas Instruments. The include files contain Header (msp430fxxx.h) and Linker Script (msp430xxxx.ld) files, which simplifies the build process. To write your own header and linker script files can be done. In most cases, this is not recommended.
- Install your favorite Text Editor. I happen to use Sublime Text.
PART 1:
1.1 Downloading MingGW
It contains Make that we will be using in Command Prompt on Windows 10.
1.2 Installing MinGW
Keep the Installation Directory the same as shown below.



1.3 Rename to Make
Navigate to C:MingGWbin. Rename “mingw32-make” to “make”. This will make it easier to use Make in the Command Prompt.




1.4 Testing Make
Press the “Windows Icon” on your keyboard, search and open “Command Prompt”.

PART 2:
2.1 Downloading MSP430-GCC-OPENSOURCE


2.2 Installing MSP430-GCC-OPENSOURCE
Keep the Installation Directory the same as below.




2.3 Testing MSP430
Type “msp430-elf-gcc –version” to confirm that it works. Recheck Step 2.2 – 2.3 if it doesn’t work.
PART 3:
We are ready to start coding and creating a Makefile. Enjoy!In this example, we will start with the most popular project of all time, the blinky project.3.1 TI MSP430 Blinky Project
3.1.1 Lets create a project folder on our Desktop called Msp430, and inside it we create our first project folder called Blinky. This will be our working directory for this project.


#include <msp430.h>
#define CYCLES 1000000L
int main(void){
/* Stop the watchdog timer */
WDTCTL = WDTPW | WDTHOLD;
P2DIR |= BIT3; // Set Pin 2.3 as an Output
P2OUT &= ~BIT3; // Clear Pin 2.3
while(1){
__delay_cycles(CYCLES); // Time delay
P2OUT ^= BIT3; // Toggle Pin 2.3
}
} 3.1.4 This is the format used to make comments: /* Comments are placed here */ and // Comments.- Comments just tell us why we wrote a specific line of code.
3.2 TI MSP430 Makefile Creation
3.2.1 It is essential that we great a Makefile to automate the build process. Below illustrates the command to run in Command Prompt that build’s a project without a Makefile. This manual entry method is tedious if we add or remove more header and source files from a large project over time.- msp430-elf-gcc -I “C:timsp430-gccinclude” -std=c99 -Og -Wall -g -mmcu=msp430f2416 -L “C:timsp430-gccinclude” -Wl,-Map,blinky.map,–gc-sections blinky.c -o blinky.elf


- CC is a variable which stores the compiler option msp430-elf-gcc.
- The usage of $(CC) replaces the CC value in its position, which in our case is msp430-elf-gcc.
- Define variables and values accurately, because no type-checking’s done when running the make command, causing a built failure to occur.
MSPGCCDIR=$(HOMEDRIVE)/ti/msp430-gcc
# Contains the header and linker script files needed
INCLUDES_DIRECTORY=$(MSPGCCDIR)/include
# The specific MSP430 device being used
DEVICE=msp430f2416
# Provides memory usage details
MAP=blinky.map
# Compiler options
CC=msp430-elf-gcc
GDB=msp430-elf-gdb
# FLAGS
CFLAGS = -I $(INCLUDES_DIRECTORY) -std=c99 -Og -Wall -g -mmcu=$(DEVICE)
LFLAGS = -L $(INCLUDES_DIRECTORY) -Wl,-Map,$(MAP),--gc-sections
all: blinky.elf
# Builds an 'elf' file
blinky.elf : blinky.c
$(CC) $(CFLAGS) $(LFLAGS) blinky.c -o blinky.elf
# Debug
debug:
$(GDB) blinky.elf
# Remove compiled files
clean:
del *.elf *.map
# This prevents MAKE to think of these commands as target files
.PHONY: all debug clean
3.2.4 Open Command Prompt in the working directory, type make all, and press enter.If you get this error: Makefile:17: *** missing separator. Stop. Then, Replace single spaces with Tab spaces in Line 17, 20 and 23.- This generates 2 files in your working directory, called blinky.elf and blinky.map.
- The blinky.elf is the executable file that we upload to the target.
- The blinky.map is a table of symbols, their location and size. It summarizes memory usage for static data and code space on the target.
- That’s it! You’ve installed, coded, and built your first executable without an IDE.

3.3 Upload the executable onto your TI MSP430 device
3.3.1 Navigate to C:timsp430-gccbin and start gdb_agent_gui.exe .



- Type target remote :55000 and press enter.
- Type load and press enter.
- Type continue, and press enter. Now you should see the L.E.D blinking.
- Type help to learn about more commands that are available.
- Once you are done you can type quit to exit the debugger.
- Type make clean, and press enter to remove all the files we created during the build.
- Now close the GUI agent if it was used with your TI MSP430.
3.4 Upload the executable onto TI MSP430 Simulator
3.4.1 Open Command Prompt in your working directory, type make debug and press enter.
- Type target sim, and press enter to switch to the simulator.
- Type load, and press enter to upload the code to the simulator.
- Type start, and press enter to begin executing the code on the simulator.
- Type step or next, and press enter to step through the code.
- Type quit, and press enter to exit.

- Type make clean, and press enter to remove all the files we created during the build.

Vivek Bhageria — Lead Firmware R&D Engineer, 12+ years. Ex-Bosch (automotive powertrain), MusicTribe (real-time audio), medical devices. M.Tech BITS Pilani. I write at NerdyElectronics — practical, register-level embedded systems for engineers who want to understand what’s actually happening under the hood.






