Table of Contents
MSP430 Discovery Board Guide
Reference Documents
MSP430 Documentation:
- MSP430x5xx User's Guide Main manual. Describes the setup and configuration for the whole microcontroller.
- MSPEXP430F5529LP Quick Launch Guide Useful for the pin layouts.
- MSP430F5529 LaunchPad User's Guide Contains the full pinout schematics
- MSP430F5529 Header File Contains many of the pin and register constants
Kubos Documentation:
- Main HAL API documentation - Overview of the high-level HAL. Useful for things like k_uart_write.
- MSP430F5 Specific HAL API documentation - Specifics for the MSP430 version of the HAL. Useful for things like the configuration options.
- Installing the Kubos SDK - Basics of setting up the Kubos SDK environment
- Creating your first project - Steps to create and build a Kubos SDK project
- SDK Command Reference - Overview of the common Kubos SDK commands
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.
- Word length - Does not support 9-bit mode
- Currently has all the same capabilities as the STM32F4
- 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:
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".