MSP430 Discovery Board Guide

MSP430 Discovery Board Guide

Reference Documents

MSP430 Documentation:

Kubos Documentation:

Pin Definitions

Unlike the STM32F4, there is only a single set of pin definitions for each communication bus.

Note: There are two UART buses present in the launchpad. However, UART2 is piped through to the micro-USB port and is reserved for console output.

Finding the pin definitions for a board

Quick Launch Guide:

The first page has the pins. The primary I2C, SPI, and UART buses are color-coded.

  • I2C pins - UCB_n__{SCL|SDA}
  • SPI pins - UC_cn__{SIMO|SOMI|CLK}
  • UART pins - UCA0_{TXD|RXD}

Launchpad User's Guide:

The full pinout schematic of the processor can be found in section 2.2.1 of the launchpad's user's guide.

Startup Code


SUPER IMPORTANT


The MSP430's watchdog is on by default. It must be manually turned off at the start of your program or you must create a task to feed the watchdog. If you don't, the watchdog will continually be starved and reboot your board.


You should also make a call to enable interrupts at startup.

Your main() should look something like this:

int main(void) {

    /* Stop the watchdog. */
    WDTCTL = WDTPW + WDTHOLD;

    __enable_interrupt();

    xTaskCreate(task_blink, "blink", configMINIMAL_STACK_SIZE * 4, NULL, 2, NULL);

    vTaskStartScheduler();

    return 0;
}

Configuration Notes

The MSP430's inter-device communication methods do not support all of the same options as the STM32F4. For example, the MSP430 does not support 1-wire half-duplex SPI communication. Please refer to the User's Guide or the MSP430's HAL Documentation for all of the supported options.

UART

  • Word length - Does not support 9-bit mode

I2C

  • Currently has all the same capabilities as the STM32F4

SPI

  • Direction - Does not support 1-line mode
  • Data Size - Does not support 16-bit mode

Flashing the board

You'll flash the firmware onto your board through the micro-USB port. You might need to install drivers in order for the board to be properly detected by your computer. If you're using Windows, the drivers can be found here.

If you have a Kubos vagrant image running, the USB connection should be automatically passed through to the VM. The board should appear as the "Texas Instruments" device if you issue the lsusb command. Run 'kubos flash' in order to start the flash process.

If you see a "*No unused FET found*" message, the board either isn't plugged into your computer or some other VM has control of the USB (only one VM can have control of the USB at a time).

If you see any other error messages, like "*device initialization failed*" re-run the flash command.

Note: The MSP430 flasher can be finicky. It may take several attempts to successfully flash the board. If you reach a state where you've run the flash commands many times and it still won't complete successfully, try restarting your machine/VM.

The output of a successful flash should look like this:

MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer <[email protected]>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: ttyACM0
MSP430_Initialize: ttyACM0
Firmware version is 30403004
MSP430_VCC: 3000 mV
MSP430_OpenDevice
MSP430_GetFoundDevice
Device: MSP430F5529 (id = 0x0030)
8 breakpoints available
MSP430_EEM_Init
Chip ID data: 55 29 19
Erasing...
Programming...
Writing 4096 bytes at 4400 [section: .text]...
Writing 4096 bytes at 5400 [section: .text]...
Writing 4096 bytes at 6400 [section: .text]...
Writing 4096 bytes at 7400 [section: .text]...
Writing 4096 bytes at 8400 [section: .text]...
Writing 2044 bytes at 9400 [section: .text]...
Writing 1200 bytes at 9bfc [section: .rodata]...
Writing   12 bytes at a0ac [section: .data]...
Writing  128 bytes at ff80 [section: .vectors]...
Done, 23864 bytes total
MSP430_Run
MSP430_Close

If something happens to the board's flashing firmware

It's possible for the version of the board's internal firmware to be out-of-date from what the flash application is looking for. In this case, the 'kubos flash' command will automatically kick off the firmware updater.

(This is guaranteed to happen if you change the OS of the computer that the board is connected to.)

It will look something like this:

MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer <[email protected]>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: ttyACM0
MSP430_Initialize: ttyACM0
FET firmware update is required.
Starting firmware update (this may take some time)...
Initializing bootloader...
Programming new firmware...
    75 percent done
    84 percent done
    [...]
    84 percent done
    91 percent done
   100 percent done
tilib: MSP430\_FET\_FwUpdate: MSP-FET / eZ-FET core(communication layer) update failed (error = 74)
tilib: device initialization failed

If you're using a VM, the "Texas Instruments MSP Tools Driver" device name might no longer be present after running the command.

If that occurs, try selecting the "Unknown device" devices and re-running the 'kubos flash' command. The command should cause some additional firmware to be loaded and the usual device name should appear once it completes.

Select the "Texas Instruments MSP Tools Driver" device again and rerun the flash command one more time. You should see firmware upload messages, followed by your program being flashed to the board.

MSPDebug version 0.22 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2013 Daniel Beer <[email protected]>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: ttyACM0
MSP430_Initialize: ttyACM0
FET firmware update is required.
Starting firmware update (this may take some time)...
Initializing bootloader...
Programming new firmware...
     4 percent done
     [...]
    84 percent done
    84 percent done
   100 percent done
Update complete
Done, finishing...
MSP430_VCC: 3000 mV
MSP430_OpenDevice
MSP430_GetFoundDevice
Device: MSP430F5529 (id = 0x0030)
8 breakpoints available
MSP430_EEM_Init
Chip ID data: 55 29 19
Erasing...
Programming...
Writing 4096 bytes at 4400 [section: .text]...
Writing 4096 bytes at 5400 [section: .text]...
Writing 4096 bytes at 6400 [section: .text]...
Writing 4096 bytes at 7400 [section: .text]...
Writing 4096 bytes at 8400 [section: .text]...
Writing 2044 bytes at 9400 [section: .text]...
Writing 1200 bytes at 9bfc [section: .rodata]...
Writing   12 bytes at a0ac [section: .data]...
Writing  128 bytes at ff80 [section: .vectors]...
Done, 23864 bytes total
MSP430_Run
MSP430_Close

Debug Console

You can view the MSP430's console output by creating a serial connection to the micro-USB port. If you're using Windows, the connection will appear in Device Manager as "MSP Application UART1". The default connection speed is 115200.

All of your program's printf statements will be routed through here. You can change the settings of the console with the hardware:console section of the config.json file.

NOTE: If your MSP430 board loses power while you have a debug console connection open, you might need to close the current console and turn the board off and back on again in order to create a new successful console session.

Example Program

Let's create a basic MSP430 program.

The goal is to create a program that will output a message once a second. Additionally, a message should be issued when button 0 (P2.1) is pressed.

Note: This is more simple than the STM32F4 example program because there are no inter-device pins that can be connected to each other. UART2 is dedicated to the debug console and slave mode hasn't been implemented for I2C or SPI.

The Walkthrough:

Create the project

$ kubos init msp-test

Create the program in main.c:

/*
* KubOS RT
* Copyright (C) 2016 Kubos Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kubos-hal/gpio.h"
#include "kubos-hal/uart.h"
/*
* Flash specified LED for 100 milliseconds
*/
static inline void blink(int pin) {
k_gpio_write(pin, 1);
vTaskDelay(100 / portTICK_RATE_MS);
k_gpio_write(pin, 0);
}
/*
* Print out a message when button 0 (P2.1) is pushed
* and blink the red LED
*/
void task_button_press(void *p) {
int signal = 1;
while (1) {
if (k_gpio_read(K_BUTTON_0)) {
printf("Button_0 pressed\r\n");
blink(K_LED_RED);
}
vTaskDelay(100 / portTICK_RATE_MS);
}
}
/*
* Print out a basic message every 2 seconds
* and blink the green LED
*/
void task_echo(void *p) {
static int x = 0;
while (1) {
printf("echo, x=%d\r\n", x);
x++;
blink(K_LED_GREEN);
vTaskDelay(2000 / portTICK_RATE_MS);
}
}
int main(void)
{
//Initialize the debug console (by default, UART2 @ 115200)
k_uart_console_init();
//Initialize the LEDs and button
k_gpio_init(K_LED_GREEN, K_GPIO_OUTPUT, K_GPIO_PULL_NONE);
k_gpio_init(K_LED_RED, K_GPIO_OUTPUT, K_GPIO_PULL_NONE);
k_gpio_init(K_BUTTON_0, K_GPIO_INPUT, K_GPIO_PULL_UP);
// Stop the watchdog
WDTCTL = WDTPW + WDTHOLD;
//Create the subtasks
xTaskCreate(task_button_press, "BUTTON", configMINIMAL_STACK_SIZE, NULL, 3, NULL);
xTaskCreate(task_echo, "ECHO", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
//Start the task scheduler
vTaskStartScheduler();
while (1);
return 0;
}

Set the target

$ kubos target msp430f5529-gcc

Build the program

$ kubos build

Flash the program

$ kubos flash

Connect to the debug console. Should see an "echo, x=_n_" message every second. If you press the P2.1 button, you should see "Button_0 pressed".