Getting started with MSP430 launchpad development using Code Composer Studio v7.x

Pinterest icon

code composer studio tutorial for msp430 launchpad microcontroller

Code Composer Studio (CCS) is an IDE to develop software for microcontroller's from Texas Instruments like MSP430,MSP432,Tiva/Stellaris etc.CCS is based on Eclipse platform and supports a plug and play architecture in which multiple compilers/debuggers can be used for developing and debugging software.

In this tutorial we will learn to develop software for the MSP430 family of microcontroller's using the Launchpad development board.Here we will use both the TI's proprietary compiler as well as the free and opensource mspgcc compiler for building code.

 

Downloading Code Composer Studio 

getting started with code composer studio for msp430 launchpad

Code Composer Studio can be downloaded  from Texas Instruments Website.

CCS is available for Windows,Linux and Mac OSX platforms.

CCS is available as both online and offline install.

 

Creating a MSP430 Launchpad project in Code Composer Studio(CCS)

After installing code Composer Studio on your computer,Click the desktop icon to launch the IDE.

You can use CCS to develop embedded software using both C and Assembly language.Here we will be dealing primarly with C language.

The IDE would then ask you to select a  workspace to store your current settings and preferences,Click OK to continue.Your Sourcecodes will also be stored in this location.

Selecting work space for MSP430 launchpad code composer C project

From the Menu bar,

Select Project → New CCS Project... 

creating a C project in code composer studio for msp430 development

which will bring up the New CCS Project Dialog.

Use the " Target " drop down menu to select the MSP430 family you will be using.

Since we are using Launchpad development board, select MSP430Gxxx Family. (shown below)

selecting msp430 family in code composer studio

After you have selected the Family,use the adjacent dropdown menu to select the device you will be using.Here MSP430G2553.

selecting MSP430G2553 for development in code composer studio 7

After that give a name to your project .Here " My-MSP430-Project ".

 

Selecting a Compiler for your MSP430 Project in Code Composer Studio

Code Composer Studio comes with the option to select multiple compilers for building your MSP430 project .The two commonly used compilers are  

  1. Texas Instruments Properietary Compiler (TI v16.9.7 LTS)
  2. msp430 gcc (GNU v6.2.1.16)

You can select the compilers using the "Compiler version" drop down menu in the New CCS Project Dialog as shown below. 

getting started with mspgcc in code composer studio

The default compiler in CCS is Texas Instruments Properietary Compiler (TI v16.9.7 LTS) .The TI compiler is code limited but will be sufficient for developing software for  MSP430G2553.

The opensource mspgcc compiler have to be seperately installed .

mspgcc is opensource and have no code limit compared to TI's compiler.

 

Installing MSP430 GCC on Code Composer Studio

MSP430GCC can be easily installed using Code Composer Studio App Center.

You can easily access the App Center from the "Getting Started "page

installing mspgcc on code composer studio from app center

or by going to Help  CCS App Center

msp430 development using opensource mspgcc compiler

You can then easily install the required software by clicking on the MSP430 GCC option in the App Center.

installing msp430 gcc for software development using msp430 launchpad board

Now let us go back to the CCS Project Dialog,

After You have selected the compiler you wish to use (TI's or msp430gcc),Click Finish and you will be greated by the following figure.

developing software for msp430 launchpad using ccs7

 

Building a MSP430 project in Code Composer Studio

We can now write a small program that would light up the LED's connected to pins P1.0 and P1.6 on the MSP430 launchpad.

You can type the below program into the main.c file inside the CCS IDE.

LED blink C file in code composer studio for MSP430

After you have written the program,you can build the c file by going to Project  → Build Project

building a msp430 project in code composer studio

If there is any issues with your code like a missing semi colon ,the compiler will show the errors under the Problems tab at the bottom. 

error window in ccs7

Another nifty feature of the CCS7 IDE is the Advice window which gives you useful suggestions regarding how to optimize your program for performance or low power consumption.

cc7 advice window

 

Downloading code into MSP430 Launchpad using Code Composer Studio

Connect your MSP430 Launchpad development board to your computer and make sure that it is detected by the Computer by going to Device Manager .If the launchpad is detected,it can be seen under Ports in Device Manager as shown below.

Downloading code into MSP430 Launchpad using Code Composer Studio

You can start the debugging session in the Code Composer studio by pressing F11 or by going into Run → Debug.This starts the debugger, which gains control of the target(here MSP430 Launchpad board), erases the target memory, programs the target memory with the application, and then resets the microcontroller.

 

debugging msp430 launchpad in code composer studio

After you press the debug button,a ULP Advisor Dialog will pop up.Please press Proceed button to continue.

ultra low power advisor in code composer studio

Code Composer Studio will then build your project,generate the hex file and automatically download it into your development board.

The IDE will then enter into Debug mode as shown below.

debug mode of code composer studio

 

Debugging MSP430 Launchpad using Code Composer Studio

After you have entered the Debug mode ,you can run your program continously or step, instruction by instruction.

You can now run the program loaded into the microcontroller memory by pressing F8 or Run → Resume. 

running program in code composer studio debug mode

 

After you have run the program on the microcontroller ,you can reset it by going to Run → Reset.

resetting msp430 microcontroller in code composer studio debug mode

There are two types of Resets available on Code Composer Studio

  1. Soft Reset  - This would reset the microcontroller and transfer the control to entry point of main().
  2. Hard ResetThis would reset the microcontroller and transfer the control to C Environment Entry point.

 

You can also single step through code execution using the step commands.

single stepping through msp430 code in code composer studio debug mode

 

You can put breakpoints in code composer studio by going to Run → Toggle Breakpoints.

setting break points in code composer studio debug mode

You can see the breakpoints in the below image as light blue dots on the left hand side.

In the Debug mode ,Code Composer Studio allows you to view the internal registers of the MSP430 varient you are using.

Viewing msp430 registers using Code Composer Studio in Debug mode

Below image shows the change in Registers after executing the P1DIR |= BIT0 +BIT6;  instruction.

You can see the bits that are effected by the instruction highlighted in yellow by the CCS IDE.

single stepping and viewing msp430 direction registers

 

To get out of the Debug mode you can go to Run → Terminate or Press CTRL + F2.this would  return the user to code editor view.

terminating debug mode in code composer studio