Skip to content
Home » Embedded Systems » TI MSP430: Setup without an IDE on Windows 10

TI MSP430: Setup without an IDE on Windows 10

Texas Instruments MSP430 LaunchPad development board close-up photo showing the red PCB with MSP430 microcontroller, GPIO pin headers, LEDs, push buttons, and USB connector

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.8-bit variable used as individual flags diagram showing bits 7 through 0 with bit 2 as threshold_crossed_flag, bit 1 as data_transmitted_flag, and bit 0 as data_received_flag

1.2 Installing MinGW

Keep the Installation Directory the same as shown below.Operational amplifier open-loop gain frequency response Bode plot showing flat 100dB gain up to the minus 3dB point then rolling off at minus 20dB per decade slope down to unity gain at 1MHz 1.2.1 Navigate to your Desktop Open MinGW Installer. Select Basic Setup, navigate to Packages and Right click on “mingw-developer-toolkit-bin”, “mingw32-base-bin” and “msys-base-bin” Packages and select Mark for Installation.Negative feedback control system block diagram showing input summing junction with positive and negative paths, forward gain block A, output node, and feedback path with transfer function beta 1.2.2 Navigate to the Top left corner and Left click on Installation then click Apply Changes.MinGW Installation Manager with Installation menu open showing Apply Changes option to install selected packages including mingw-developer-toolkit-bin and msys-base-bin 1.2.3 The packages should now be Green (if not, just repeat the process), if they are successfully installed then close the Installation Manager. MinGW Installation Manager after installation showing all selected packages with installed versions including mingw32-gcc-g++-bin version 9.2.0-2 for C++ compilation

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.Windows File Explorer showing C:MinGWbin directory contents with mingw32-make application highlighted among compiler tools like gcc, gdb, and autoconf utilities 1.3.1 Let’s add Make for usage in Command Prompt.Press the “Windows Icon” on your keyboard, search and open “Edit the system environment variables”.

Windows 10 Start menu search results for Edit the system environment variables showing the Control Panel option to access PATH configuration for MSP430 toolchain setup

 1.3.2 Click on “Environment Variables”

Windows System Properties Advanced tab with Environment Variables button circled at the bottom, showing how to access PATH settings for adding MinGW and MSP430 compiler paths

 1.3.2 Under “System variables”, scroll down to “Path” and double-click.

Windows Environment Variables dialog showing user and system variables with the system Path variable selected, containing paths for MinGW, MSP430-gcc, and other development tools

 1.3.3 Click on “New” and add the location “C:MingGWbin” to environment variable and press “OK”.

Edit environment variable dialog showing the system PATH entries list with C:MinGWbin and C:Timsp430-gccbin paths added, and New button circled for adding more paths

1.4 Testing Make

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

Windows 10 Start menu search for cmd showing Command Prompt as best match with options to Open, Run as administrator, and Pin to Start for verifying MSP430 toolchain installation

 1.4.1 Type “make –version” to confirm that it works. Recheck Step 1.3 – 1.4 if it doesn’t work.

Command Prompt showing make --version output confirming GNU Make 3.82.90 built for i686-pc-mingw32 is successfully installed and accessible from the system PATH

 

PART 2: 

2.1 Downloading MSP430-GCC-OPENSOURCE

Texas Instruments website downloads page for MSP430-GCC-OPENSOURCE showing the GCC Open Source Compiler for MSP Microcontrollers with Download options button 2.1.1 Under GCC ALL-IN-ONE INSTALLER Install Mitto Systems GCC Windows installer incl. support filesMSP430-GCC-OPENSOURCE download options dialog showing version 9.3.1.1 with GCC all-in-one installer links for Windows, macOS, and Linux plus toolchain-only downloads 

2.2 Installing MSP430-GCC-OPENSOURCE

Keep the Installation Directory the same as below.MSP430 GCC compiler setup wizard showing Installation Directory field set to C:timsp430-gcc with Back, Next, and Cancel buttons 2.2.1 Let’s add MSP430-GCC for usage in Command Prompt.Press the “Windows Icon” on your keyboard, search and open “Edit the system environment variables”.Windows 10 Start menu search results for Edit the system environment variables showing the Control Panel option to access PATH configuration for MSP430 toolchain setup 2.2.2 Click on “Environment Variables”.Windows System Properties Advanced tab with Environment Variables button circled at the bottom, showing how to access PATH settings for adding MinGW and MSP430 compiler paths 2.2.3 Under “System variables”, scroll down to “Path” and double-click.Windows Environment Variables dialog showing user and system variables with the system Path variable selected, containing paths for MinGW, MSP430-gcc, and other development tools 2.2.4 Click on “New” and add the location “C:timsp430-gccbin” to environment variable and press “OK”.Windows Edit environment variable dialog showing system PATH entries with C:timsp430-gccbin path highlighted at the bottom of the list for MSP430 compiler access

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.Command Prompt showing msp430-elf-gcc --version output confirming Mitto Systems Limited msp430-gcc version 9.3.1 is successfully installed and accessible 

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.Windows File Explorer showing Msp430 folder on Desktop containing the Blinky project folder for organizing MSP430 development files without an IDE 3.1.2 Open up your favorite Text Editor, create a New File and save it as blinky.c .Sublime Text editor with File menu open showing New File option highlighted, used as the text editor for writing MSP430 C code without a full IDE Windows Save As dialog saving blinky.c file to C:UsersLoganDesktopMsp430Blinky folder as the first step in creating an MSP430 project without an IDE 3.1.3 Here, I assume you know the basics of setting up a Pin as an output and toggling it on a TI MSP430.
#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
Command Prompt showing msp430-elf-gcc compilation command with include paths, C99 standard flag, optimization, Wall warnings, and msp430f2416 MCU target to compile blinky.c into blinky.elf 3.2.2 Now, let’s create the Makefile to automate the process for our single source file.Save As dialog in Sublime Text saving a Makefile with no extension to the Blinky project folder alongside the blinky.c source file for automating MSP430 builds 3.2.3 Copy the code below and read the comments in grey to understand what each line means.
  • 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.
Command Prompt running make all command which executes the msp430-elf-gcc compilation command from the Makefile, successfully building the MSP430 blinky project  

3.3 Upload the executable onto your TI MSP430 device

3.3.1 Navigate to C:timsp430-gccbin and start gdb_agent_gui.exe .Windows File Explorer showing C:timsp430-gccbin directory contents with 34 MSP430 toolchain executables including gdb_agent_gui, msp430-elf-gcc, msp430-elf-gdb, and other cross-compiler tools 3.3.2 Click on Configure, navigate to C:timsp430-gcc and open the msp430.dat file.XDS GDB Agent GUI application window showing Connection settings with Configure button, Targets dropdown, Port and Status fields, and Start Stop controls for MSP430 debuggingSelect board configuration file dialog browsing C:timsp430-gcc directory showing msp430.dat file needed to configure the GDB agent for MSP430 LaunchPad debugging 3.3.3 Plug your TI MSP430 into your computer, click on Targets and select your specific TI MSP430. Press start and in the log section you should see Waiting for client.3.3.4 Open Command Prompt in your working directory, type make debug and press enter.Command Prompt running make debug command which launches msp430-elf-gdb loading blinky.elf with symbols, showing GNU gdb version 9.1 configured for msp430-elf target ready for debugging3.3.5 Lets connect the TI MSP430 to the GDB agent:
  • Type target remote :55000 and press enter. 
3.3.6 Let’s load the executable onto the TI MSP430:
  • Type load and press enter.
3.3.7 Lets run the program now on the TI MSP430!
  • 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.
3.3.8 Now lets clean up our working directory:
  • 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.
That’s all the basics out of the way for setting up, building and running an executable on a TI MSP430 on Windows 10 without an IDE. 

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.Command Prompt running make debug command which launches msp430-elf-gdb loading blinky.elf with symbols, showing GNU gdb version 9.1 configured for msp430-elf target ready for debugging 3.4.2 Let’s use the simulator to run the executable.
  • 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.
GDB debugger session showing MSP430 blinky.elf program loaded into simulator with target sim, load, and start commands executing, stepping through watchdog timer and GPIO pin configuration code3.4.3 Now lets clean up our working directory.
  • Type make clean, and press enter to remove all the files we created during the build.
That’s all the basics out of the way for setting up, building and running an executable on a simulator for TI MSP430 on Windows 10 without an IDE. 

Leave a Reply

Your email address will not be published. Required fields are marked *