As an Amazon Associate we earn from qualifying purchases.
The MSP-EXP430G2 LaunchPad is an easy-to-use flash programmer and debugging tool for the MSP430G2xx and also for msp430f20x3 microcontrollers. It has on-board emulation for programming and debugging, so you can connect it to your computer over USB and start running code without buying a separate programmer.
This page collects MSP430G2 LaunchPad examples in three styles: assembly language with the naken_asm assembler, C-style sketches with Energia, and plain C with GCC. Each link below goes to a step-by-step walkthrough, and you can work through them in order or jump to the topic you need.
What you need to get started
The examples assume a basic setup. You do not need much hardware to follow them:
- An MSP-EXP430G2 LaunchPad board and the USB cable that comes with it.
- A computer with the toolchain you want to try (naken_asm, Energia or MSP430 GCC).
- A few common parts for some projects, such as jumper wires, a push button, resistors and an LED.
- For the sensor projects, an LM35 temperature sensor or an ultrasonic distance sensor.
The board has a socket for the microcontroller, two user LEDs, a user push button, a reset button and header pins that break out the I/O lines. That is enough for most beginner experiments with outputs, inputs, interrupts and timers.
Which programming approach should you choose?
All three approaches target the same chip, so the choice depends on what you want to learn.
- Assembly with naken_asm: best if you want to understand registers, the instruction set and exactly how the processor handles ports, interrupts and timers.
- Energia: an Arduino-like environment for the MSP430. It is the fastest way to get a sensor reading or a simple project working.
- GCC: a command-line C workflow for people who want full control of the build process without a heavy IDE.
Many people start with Energia to get quick results, then move to C or assembly when they need tighter control over timing and power use.
Assembly language programming using naken_asm compiler
naken_asm is a free assembler that supports the MSP430 among other processors. Working in assembly is slower than using C, but it teaches how the hardware really works. The examples below start with simple port control and build up to timers and arithmetic.
Digital I/O and interrupts
Start with digital output, which turns a pin high or low to drive an LED. Then move on to digital input, which reads a button. The internal pull-down example shows how to use the chip’s built-in resistor so an input pin does not float. The external interrupt example then shows how to react to a button press on Port 1 without constantly polling the pin.
Timers and arithmetic
Timer A is the main general-purpose timer on these chips. It is used for delays, periodic events and PWM output. The arithmetic example covers how to add, subtract and move data between registers, which you need for almost any real program.
If you are new to Timer A, read the basic TIMER A article first and then the continuation, since the second one builds on the first.
MSP430G2 LAUNCH PAD programming using ENERGIA
Energia brings the Arduino programming style to Texas Instruments LaunchPad boards. You write short sketches with setup and loop functions and call familiar functions to read and write pins. This makes it a good fit for projects that use sensors.
- Interfacing With Temperature Sensor LM35
- SCADA for MSP430 LAUNCHPAD
- Interfacing with ultra sonic sensor
The LM35 example reads an analog voltage from a temperature sensor using the chip’s ADC and converts it to a temperature value. The SCADA example shows how to send data from the LaunchPad to a monitoring application over a serial link. The ultrasonic sensor example measures distance by timing an echo pulse.
When working with analog sensors, keep the LaunchPad’s supply voltage in mind. The MSP430G2 chips run at a low voltage, so check that a sensor’s output stays within the range the ADC input can accept.
MSP430G2 LAUNCH PAD programming using GCC
The MSP430 GCC toolchain compiles standard C code from the command line. It suits people who prefer makefiles and a text editor over a graphical IDE. The BLINKY example is the usual first project: it sets up a pin as an output and toggles an LED on a delay.
Once the blinky program runs, you can reuse the same build setup for larger projects such as timers, interrupts and serial communication.
Tips for working with the LaunchPad
- Start with the blinky. It confirms that your toolchain, USB connection and board all work before you add anything else.
- Turn off the watchdog. The watchdog timer is active at reset and restarts the chip if you do not stop or service it. Many beginners are surprised by a program that keeps resetting for this reason.
- Check which pins the LEDs and button use. The onboard parts share pins with the header, so a wire on the same pin can change how they behave.
- Change one thing at a time. With interrupts and timers, small changes can have big effects, so test after each step.
Where to go next
After the basics, try combining examples. For instance, use a timer interrupt to sample a sensor at regular intervals, or use a button interrupt to start a measurement. If you want to compare the MSP430 with another low-cost 8-bit platform, our STM8S examples follow a similar path from simple I/O to timers. For general circuit simulation practice, see our Proteus examples. If you are curious about industrial control, the PLC ladder logic examples show a different way of programming a PIC16F877 for automation tasks.
Frequently asked questions
Which microcontrollers does the MSP-EXP430G2 LaunchPad support?
It is designed for the MSP430G2xx series and also supports the msp430f20x3 devices. The on-board emulation lets you program and debug them directly from your computer.
Do I need a separate programmer for the MSP430G2 LaunchPad?
No. The board includes on-board emulation for flashing and debugging, so a USB cable is enough to load your program.
Is Energia or assembly better for beginners?
Energia is easier for a first project because the code is short and familiar to anyone who has used Arduino. Assembly takes longer but gives you a clear picture of how the MSP430 handles ports, interrupts and timers.
Can I use GCC instead of an IDE?
Yes. The MSP430 GCC toolchain works from the command line, and the BLINKY example above shows a simple starting point.