TI MSP430 & Visual Studio Code development environment installation#
Many students tend to struggle with environment installation. I prepared this document for the course Measurement and control using microprocessors.
Windows#
Install Visual Studio Code (VSCode) using Microsoft Store. The version with Insiders is the beta (pre-release) version – the release version should work.
Open VSCode and pin it to your taskbar using 🖱️ right click and selecting
Pin to taskbar
.If you install it for the first time, feel free to follow the tutorial advertised on the first page.
Click
File
,Open Folder
. The folder you will select will house your workspace. I recommend putting all the projects related to a course to a workspace. So create a folder with your course name and select it as your workspace.You may get a pop up asking
Do you trust the authors of the files in this folder?
. This is an important question because executable programs from untrusted sources may damage your computer. In this case the folder is empty and we trust course-related files. So confirm it.You will see on the left your new workspace in
EXPLORER
bar.On the left-most bar called Activity bar, click on
Extensions
. It has the icon with four squares where one is about the fill the gap.Install
PlatformIO
IDE. This extension eases projects with microcontrollers and FPGAs. In my case it took about one minute to install it. It requires a restart of VSCode.When you open VSCode it should open your workspace automatically. Moreover, the PlatformIO should appear on the left side will see the PlatformIO icon similar to 👽. Click on it.
Click on
Create New Project
. A new tab calledPIO Home
should open up.Click on
Project Examples
. A small window will pop up.You probably won’t see any examples. Click on
Install Embedded Platform
. A new page with a search bar will show up.Search for
msp
. Click onTI MSP430
. A new page with a search bar will show up.You don’t have to search for anything. Click on the 🟦 button
Install
. In my case the installation took about one minute. After the installation a window with the titlePlatform has been ... installed
will pop up.Click
OK
on the pop up window.Now we will try an example project. Click on the
Examples
tab, which is on the right ofBoards
and left ofPackages
. You may see that you first have to install platform files. We already installed it, so try refreshing the page by clicking on another tab or window and coming back toExamples
.We will use the Arduino framework. You should already see the
arduino-blink
example. It shows two files, (1)platformio.ini
and (2)src\main.cpp
. Click on the light 🟦Import
button on the right of the drop-down menu, where other examples can be found. Probably it will error out. I filed an issue on their bugtracker.We will try another approach. On the
PIO Home
tab, click onHome
.Click on
New Project
.Project Wizard
window should pop up.-
On the window:
Name your project
blink
.You probably have the Launchpad MSP-EXP430F5529LP. So, search for
f5529
.Leave
Arduino
selected.Leave
Location
as it is.
A installation process status window will pop up. It took about 30 seconds to create the project. In
Explorer
, you will see the new project folderblink
with many folders andplatformio.ini
file inside. Click on
src
folder andmain.cpp
. We will compile and flash this program.-
Click on the ✔️ icon on the right, on the same level with the tabs
PIO Home
,main.cpp
etc.You will see
TERMINAL
at the lower bottom of your screen filled up with messages. PlatformIO will probably install the Energia framework (Arduino framework adapted to MSP43x microcontrollers) and the MSP43x toolchain (e.g., compiler, utility to convert an elf executable to a hex file etc). At the end of this process, you will getfirmware.hex
. Now let us program the microcontroller. Connect your board. In my case Windows did not ask for anything, so I believe the drivers are installed automatically.
-
Click on the ⬇️ on the right of the previous ✔️ icon and select
Upload
.PlatformIO will download and install
tool-dslite
. Then it will try to initialize the MSP430 debugger. In this process you may get the error:Failed: MSP430: Error initializing emulator: No USB FET was found
. This means that your operating system cannot find the MSP debug stack (MSPDS) probably because it does not have the drivers. -
Go to TI MSPDS page. Click on
View all
and scroll to the very bottom. Click onDownload options
forMSPDS-USB-DRIVERS
. There click on the file corresponding to your operating system and install it. You have to create an account because of US export controls 😕.In Windows
Device Manager
, after installation the two serial ports exposed by the board (COM*
) will become:MSP Application UART1
MSP Debug Interface
In VSCode, click on the
Upload
button again. InTerminal
you will seeConnecting...
and after some linesSuccess
. However your board will do nothing interesting 😐. So let us try a Hello world program on microcontrollers: blinking an LED.-
Copy and paste the following program from the
Examples
that we saw previously and replace the contents ofmain.cpp
./* * Blink * Turns on an LED on for one second, * then off for one second, repeatedly. */ #include <Arduino.h> void setup() { // initialize LED digital pin as an output. pinMode(RED_LED, OUTPUT); } void loop() { // turn the LED on (HIGH is the voltage level) digitalWrite(RED_LED, HIGH); // wait for a second delay(1000); // turn the LED off by making the voltage LOW digitalWrite(RED_LED, LOW); // wait for a second delay(1000); }
After using the
Upload
function the button on the right side of your code windows should have turned to a ➡️, which stands forUpload
.Click on
Upload
. It will automatically build your project if needed. During programming the redLED101
beside the USB connector will be active. ThenLED101
will turn off and the redLED1
will start blinking. 🎉🥳
Troubleshooting#
MSP430: Error initializing emulator: No USB FET was found
#
TL;DR: Plug your board off, then push the BSL button, plug in again while pressing the BSL button. Then release it. Then plug the board out and in again.
You tried the usual turn it off and on again tool, but you still get this error? This means the programmer cannot find the eZ-FET Onboard Emulator which is used to program the flash of the microcontroller. There are two MSP430 microcontrollers on the board: the target ..5529 and the debugger ..5528, where the latter is also used for programming the target microcontroller. In our case the ..5528 is not responsive and The action above gives the control ..5529 to the internal bootloader which in turn enables programming. I have experienced that the action above made the ..5528 responsive again, however it did not work in another board failure situation.
If above did not help, then it may be still possible to reprogram the ..5528 using ..5529, which is described here.