MSP430 Tutorial - Getting Started

This series of tutorials is in response to a request for a very low power timer with selectable time delays from 1 hour to 24 hours.

These tutorials are based on the Texas Instruments MSP430LaunchPad.

Some useful links

Texas Instruments product page:
http://www.ti.com/product/msp430g2553

Data sheet for the MSP430G2553:
http://www.ti.com/lit/gpn/msp430g2553

This next document explains the operation of the MSP430 family in more detail:
http://www.ti.com/lit/ug/slau144j/slau144j.pdf

There are many other useful sites that you may want to peruse. Here is one place to start:
http://e2e.ti.com/support/microcontrollers/msp430/default.aspx

Here is the link to download the free version of IAR Embedded Workbench:
http://www.ti.com/tool/iar-kickstart

You may be asked to select between the 30-day version or the code-limited version. Choose the code-limited version. You will be asked to register the product. Simply follow the instructions. A license will be sent to you via email.

Getting Started

When you start IAR-EW, select

Project->Options...->General Options
Under the tab
Target->Device
select MSP430Gxxx Family->MSP430G2553



Under the same dialog, select
Debugger->Setup->Driver->FET Debugger



Creating your first program

Project->Create New Project-> +C-> main






You will be prompted to save a workspace. It might be useful to create your new workspace in a new folder so as to keep your projects organized.

A window for main.c will appear:




We will modify this as follows:

Code:
// Getting Started Example
// 2013.04.19 - MrChips
// Toggle LED1 (red)

#include "io430.h"

void init(void)
{
    P1OUT = 0;    // reset PORT1 bits
    P2OUT = 0;    // reset PORT2 bits
    P1DIR = 0xFF; // setup PORT1 as output
}

void main( void )
{
    // Stop watchdog timer to prevent time out reset
    WDTCTL = WDTPW + WDTHOLD;
    init();

    while (1)
    {
       P1OUT_bit.P0 = 1;  // turn on LED
       P1OUT_bit.P0 = 0;  // turn off LED
    }

}
Connect your MSP-EXP430G2 board to your computer with the USB cable supplied.

To compile the code:


click on the GREEN ARROW (Make & Restart Debugger) at the right side of the toolbar.


To run the code:


click on the GO button (three little blue arrows).

This program will toggle the red LED at a very fast rate, too fast for the eye to catch. The LED will appear to be on constantly. The purpose of this test is to check that your software is working correctly.

The next program I will present will add a delay so that we can observe the LED flash.

NEXT
  • Like
Reactions: cmartinez

Blog entry information

Author
MrChips
Views
3,450
Last update

More entries in General

More entries from MrChips

Share this entry

Top