Before we begin, please ensure you:
1. Download and install the latest version of Arduino IDE (1.8.13). https://www.arduino.cc/en/software/
2. Add the URL http://s3.amazonaws.com/energiaUS/packages/package_energia_index.json to your File > Preferences > Additional Board Manager URLs. Also check the box for show line numbers if you like that and adjust your font size if you would like it bigger.
3. Go to Tools > Boards > Boards Manager and scroll to the bottom of the list with Energia MSP432 and install 5.29.1
Note: this step takes a few minutes, leave time for the install between 10-20 minutes.
Setup your MSP432 LaunchPadWhile you are waiting for Arduino install to complete, we will get the LaunchPad USB drivers set up for your computer. Have your LaunchPad ready and plugged intonyour computer. You can also have the CC3100BOOST plugged in to the LaunchPad. Make sure it is oriented correctly (The TI icons and text on the board should be right side up on both boards when looking at it and the pins are fully connected). There should be LEDs on for b
Hardware Required- MSP-EXP432P401R
There are several ways to accomplish the USB driver setup. One is you can download and install the drivers manually (windows users).
http://s3.amazonaws.com/energiaUS/files/energia_drivers.zip
Unzip the folder and install the drivers. You should see the XDS110 in your Device Manager > Ports to confirm the drivers are working properly. If you don't see this while the LaunchPad is plugged in then there likely will be a driver issue. You can try to reinstall the drivers and see if that fixes it.
Alternate setup procedure
Another way you can get the drivers is through an example GUI for the LaunchPad. You can find one online (use chrome browser and set up the Chrome browser extension when prompted and download and install the TI Cloud agent when prompted).
https://dev.ti.com/gallery/view/demos/button_MSP432R_Demo/ver/1.0.0/
- a. This lets you verify if everything is working correctly. It also will help you later on if you want to make sure your robot is not damaged.
- b. Use Chrome or Firefox browser and install the browser extension + TI Cloud Agent local driver. These are critical to getting the LaunchPad working so if they don't install correctly the GUI won't work. The TI Cloud Agent is also important to have installed for when we run the Arduino stuff later.
- c. Try to unplug and replug your USB cable as this can sometimes help reset the USB drivers once they are installed. Retry the GUI.
- d. If you have any problems with the dashboard (hardware not connected, etc) try to refresh the page and try again. If you completely can't get the GUI to work you can also try to download a local copy to try. This often fixes any issues. It will take an additional 5-10 minutes to install this. Make sure to install and run the local GUI as admin.
You can also download the local version of the GUI below if you are having trouble with the cloud version:
Windows: https://dev.ti.com/gallery/dl/demos/button_MSP432R_Demo/ver/1.0.0?platform=win
Mac OS: https://dev.ti.com/gallery/dl/demos/button_MSP432R_Demo/ver/1.0.0?platform=osx
Linux 64bit: https://dev.ti.com/gallery/dl/demos/button_MSP432R_Demo/ver/1.0.0?platform=linux64
- e. It will download the test firmware each time, so make sure LaunchPad is connected to PC via USB cable when page is loading
The TI Cloud Agent will install the USB drivers for your LaunchPad board. Now the GUI should attempt to connect to the board and flash a new program. You will see the emulator LEDs blink during this process. After the new firmware is loaded you will see a rapidly blinking red LED and the GUI will say Hardware Connected. To interact with the GUI you can press the side pushbuttons of the LaunchPad.
On the lower left corner you should see some status information such as Connecting to TI Cloud Agent, Connected to target, Downloading Program, Flash Successful, and Hardware connected.
Once you see it is connected. The GUI is super basic but you can see your button presses and duration on the two side buttons of the LaunchPad. Give it a quick try to verify the data is getting passed. When you are finished with the GUI, please close it so it is not connected to the LaunchPad and does not conflict with Arduino IDE.
4. After the install completes, You need to select the board and COM port in Arduino IDE. Go to Tool > Boards and now you should see the "Energia MSP432 Red Boards" > "Red LaunchPad MSP432P401R EMT" and make sure this is selected.
5. You also should select the correct COM port. Go to Tools > COM port to chose from available options. The LaunchPad populates two COM ports. MacOS users will see Port 001 and 004 populated, please use Port 1. Windows users can verify their COM port by going to Device Manager and finding the XDS110 UART and seeing the COM port assigned by windows.
Hardware Required- MSP-EXP432P401R
- CC3100BOOST
- Arduino IDE
- Wi-Fi Library
Arduino IDE allows you to start rapid prototyping with the TI LaunchPad using Arduino style programming. This makes it really great at the beginning of a project to test out different community hardware solutions and integrate them into a custom application.
In this lab we are going to get our development environment set up. The first thing we can do is blink an LED to make sure we can program our microcontroller with our computer.
1. Open up the Arduino IDE.
2. First thing, make sure you select your board by going to Tools > Board and look for "LaunchPad with MSP432" on the menu if you have not already. If your LaunchPad board is not present, go to the Boards Manager and install your LaunchPad board package. MSP432 boards should be the last option in the list. Note: MSP432 EMT means Multitasking and has RTOS capability, but we don't need that right now.
3. If you properly installed your drivers, then you should see COM ports under Tools > Port. Select the port with UART capability if there are multiple options. You can verify the COM port in your computer's device manager.
Now we will run our code examples for the first time.
4. Go to File > Examples > WiFi > SimpleWebServerWiFi. Click on the upload button and when it completes you can hit the bump switches to test the different LEDs and verify new code can be flashed to the MSP432 LaunchPad
5. Next, change the SSID and password variables to your local network in the Arduino program. Click the upload button (arrow pointing right next to checkmark button). Your code will compile and then be loaded to the LaunchPad, this may take a minute or two. Once that says success you can navigate to the local page (it will say exactly in the serial monitor but you can try 192.168.1.1) to find the example webpage. You can also see it connect on the serial monitor if you hit the reset button on the LaunchPad.
/*
WiFi Web Server LED Blink
A simple web server that lets you blink an LED via the web.
This sketch will print the IP address of your WiFi (once connected)
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on pin 9.
If the IP address of your WiFi is yourAddress:
http://yourAddress/H turns the LED on
http://yourAddress/L turns it off
This example is written for a network using WPA encryption. For
WEP or WPA, change the Wifi.begin() call accordingly.
Circuit:
* CC3200 WiFi LaunchPad or CC3100 WiFi BoosterPack
with TM4C or MSP430 LaunchPad
created 25 Nov 2012
by Tom Igoe
modified 6 July 2014
by Noah Luskey
*/
#include <SPI.h>
#include <WiFi.h>
// your network name also called SSID
char ssid[] = "energia";
// your network password
char password[] = "supersecret";
// your network key Index number (needed only for WEP)
int keyIndex = 0;
WiFiServer server(80);
void setup() {
Serial.begin(115200); // initialize serial communication
pinMode(RED_LED, OUTPUT); // set the LED pin mode
// attempt to connect to Wifi network:
Serial.print("Attempting to connect to Network named: ");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
Serial.print(".");
delay(300);
}
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE) {
// print dots while we wait for an ip addresss
Serial.print(".");
delay(300);
}
Serial.println("\nIP Address obtained");
// you're connected now, so print out the status
printWifiStatus();
Serial.println("Starting webserver on port 80");
server.begin(); // start the web server on port 80
Serial.println("Webserver started!");
}
void loop() {
int i = 0;
WiFiClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
Serial.println("new client"); // print a message out the serial port
char buffer[150] = {0}; // make a buffer to hold incoming data
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (strlen(buffer) == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
// the content of the HTTP response follows the header:
client.println("<html><head><title>Energia CC3200 WiFi Web Server</title></head><body align=center>");
client.println("<h1 align=center><font color=\"red\">Welcome to the CC3200 WiFi Web Server</font></h1>");
client.print("RED LED <button onclick=\"location.href='/H'\">HIGH</button>");
client.println(" <button onclick=\"location.href='/L'\">LOW</button><br>");
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
}
else { // if you got a newline, then clear the buffer:
memset(buffer, 0, 150);
i = 0;
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
buffer[i++] = c; // add it to the end of the currentLine
}
// Check to see if the client request was "GET /H" or "GET /L":
if (endsWith(buffer, "GET /H")) {
digitalWrite(RED_LED, HIGH); // GET /H turns the LED on
}
if (endsWith(buffer, "GET /L")) {
digitalWrite(RED_LED, LOW); // GET /L turns the LED off
}
}
}
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
//
//a way to check if one array ends with another array
//
boolean endsWith(char* inString, const char* compString) {
int compLength = strlen(compString);
int strLength = strlen(inString);
//compare the last "compLength" values of the inString
int i;
for (i = 0; i < compLength; i++) {
char a = inString[(strLength - 1) - i];
char b = compString[(compLength - 1) - i];
if (a != b) {
return false;
}
}
return true;
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}
6. Once the code is uploaded and you can navigate to the page hosted. You can blink and toggle the LED on the LaunchPad using the buttons on the page.
7. You can look through the other examples of the WiFi library to discover more ways to use the CC3100 Wi-Fi. To start the LaunchPad in Access Point (AP) mode you will want to change WiFi.begin() to WiFi.beginNetwork() and change the name of what you want the LaunchPad SSID and password will be for devices connecting to the AP. Pasword must be at least 8 characters long. You can try this by having your phone connect to the Wi-Fi network set up by the LaunchPad.
8. Keep in mind the LaunchPad has limited memory so if you would like to store any files or images for your web page, it is best to pull that from the web (off the LauchPad server) and do the heavy lifting on the client side.
Troubleshooting
Code not uploading?
- Check for errors in Arduino debug window. The compiler will tell you what is happening. Errors are in red text.
- Sometimes your LaunchPad gets stuck or hung up on the previous code. Unplug your LaunchPad and plug it back in to perform a full reset. This is called a power on reset. Sometimes using the RESET button can work but taking away the power and letting the microcontroller fully reset is often best.
- If you have a failure to upload it could be your drivers are not properly installed. Arduino IDE will sometimes give the error “No unused FET Found” which means it can’t find a LaunchPad connected to your computer. Make sure you download the USB drivers for your operating system by running the TI Cloud Agent or installing the RSLK debug tool locally. Also make sure your USB cable is not power only. Use the one included in the box for best results.
- If you had no problem with the GUI or the first LED example, your Energia should be correctly set up. Restart your LaunchPad and restart Arduino IDE if you encounter any problems. Make sure to select the right serial port and board type under the Tools menu.
LED not lighting up?
- Make sure you properly uploaded the code and that you properly named your variables for the LED pins. There is very little chance that your LED is broken, but we can verify by blinking a different LED with the same code.
- Hit the reset button, sometimes this is needed for the LaunchPad to run the newly uploaded program.
Comments
Please log in or sign up to comment.