|Software apps and online services:|
In this tutorial we have a very special treat. Handheld game development!
Who hasn't wanted to make their own version of a gameboy and create their own games? We will show you how you can get started using TI-RTOS and the TI LaunchPad ecosystem.
Credit to Dr. Jon Valvano at University of Texas at Austin for developing this example. If you'd like to learn more from Dr. Valvano, he offers an online course and several textbooks. Dr. Valvano has taught over 100,000 students through his on campus and online embedded systems courses.
You can find links to those on his website: http://users.ece.utexas.edu/~valvano/
For this lab we will be using TI-RTOS which is a free to use real-time operating system. RTOS is a great way to manage and organize complex embedded software, such as a game.
We will also be using TI's Code Composer Studio IDE which a free to use, industry grade eclipse based IDE. CCS has many features inside to help with debugging and software development. Version 7 and above is recommended.
CCS is pretty easy to set up but takes some time to install. Go ahead and download it from TI and run through the installer. We are using the MSP432 LaunchPad for our hardware so you can install the relevant packages for MSP432.
Note: CCS is a large program so there are sometimes things that we may need to troubleshoot. If you have anything that isn't going smoothly, check out the CCS documentation and FAQs provided by TI.
We also need the relevant CCS project files. Those are available in a zip file in this hackster called Valvano_TI_RTOS.zip at the bottom of the page in the code section. Download that and extract that zip file to a convenient place. Inside of CCS you will go to File > Import. Go to the Code Composer Studio folder and select CCS Projects.
Navigate to the folder where you unzipped and CCS should discover several projects in there. Import those and they will appear in your project view on the left hand side of the IDE.
After we have successfully installed CCS, we will go to grab the right version of TI-RTOS and get that installed. You can find the installers located in this hackster at the bottom of the page in the code section or you can get them directly from TI at the link below. You will want version MSP43x2.20.00.06. Newer versions probably also work but this example is tested with this version.
The other way to get TI-RTOS for SimpleLink and MSP is directly from inside CCS Resource Explorer home page. Go to View > Resource Explorer. which will take you to the front page. You should see the icons for TI-RTOS. Download the latest version of TI-RTOS for MSP and restart CCS. Even though MSP432 is SimpleLink we want the version for MSP, version 2.20.00.06.
Go ahead and run the installer. Once it completes we then need to make sure CCS can use it. If you already have CCS open go ahead and close it and reopen it. Now CCS should tell you it has discovered new installable packages.
Go ahead and click install. It will ask you to restart again and then you should have the right version of TI-RTOS installed.
Lastly let's grab the latest MSP432 SimpleLink SDK. The easiest way is to download it from TI here:
Get the latest version for your OS. Run the installer and then restart CCS. Now you should be all set to skip to the Setup Hardware section.
The other way to get it is from the Resource Explorer. Go to Resource Explorer (View > Resource Explorer). Go to the Software folder. Select SimpleLink MSP432 SDK. Go to Demos > boostxl-edumkii_joystick_msp432p401r > NoRTOS > CCS Compiler > boostxl_edumkii_joystick_msp432p401r. If you click the import to IDE button, it will tell you to download and install dependencies. Click the "Download and install" button to install the SDK files. When completed restart CCS. Now when you go back to the folder you should be able to import into the IDE.
Now we can set up our hardware. Go ahead and put the Educational BoosterPack on top of the MSP432 LaunchPad with the joystick facing the left side and the USB connector facing upward. Connect your LaunchPad to the PC with the included USB cable.
At this point we should have any drivers we need installed as part of the CCS installation. You should see the LaunchPad populated COM ports on your device manager.
If that all went smoothly you should be good.
Load example code
First thing we will do is load up some TI sample code projects. Go to Resource explorer and under the Demos folder import and run boostxl_edumkii_joystick_msp432p401r or outofbox_msp432p401r or boostxl_edumkii_accelerometer_msp432p401r or boostxl_edumkii_lightsensor_msp432p401r or boostxl_edumkii_temperature_msp432p401r.
To run the example project, click the hammer icon at the top to build the project, then click the bug icon to enter debug mode, and finally click the green play button to run it on the hardware.
If you are successful then you are all set up.
Now all we need to do is test to make sure our sample game is working. Make sure that WorldShapers_TIRTOS_MSP432 is selected in Project Explorer. Then click on the hammer icon which will build the project. When the build is finished, click on the bug icon to enter the debug mode. When the green arrow option become available, click that icon to run the program. Your game should start! If you would like to leave the debug session you can click the red stop button.
Excellent! So we have a starting point, a working game with some graphics, sound, and inputs that are split into different threads and tasks.
To start creating your own game, you will need to analyze the code structure and see how it is implemented. From there you can start customizing WorldShapers to try out different new features. In the end you can build a game from scratch using a blank TI-RTOS project.
There are also many ways to play a game. You can add additional hardware inputs and outputs to the systems to create new player interactions. You can also add a battery source to make the game portable. Lastly, you may also want to consider adding a wireless component like Wi-Fi or Bluetooth to connect the game to the internet or other devices and data streams.
- TI LaunchPad
To start off the workshop we will load up the out of box demo code from Code Composer Studio Cloud. CCS cloud is a full development environment that you can run directly from your browser (Chrome recommended). In the demo code we will control our on board RGB LED on the MSP432 LaunchPad through a Graphical User Interface (GUI) on the PC. CCS Cloud and CCS Desktop are good options for more serious development and are integrated with many resources and documentation from TI for both the hardware and software. The objective of this first lab is to introduce you to the resources available on TI cloud tools and also help you install the MSP432 LaunchPad drivers via CCS Cloud. You can also manually install the drivers using the instructions on the Energia website or get the drivers when installing the desktop version of Code Composer Studio. For compiling your code examples you have a choice to use the open source GCC compiler or the TI CCS Compiler which gives you a bit more optimization. 1. Go to dev.ti.com. Click the CCS Cloud box listed under the Applications tab.
2. If you don't have a myTI account already, you can register for one and then sign in. If you do have one, go ahead and sign in and CCS Cloud will load your virtual workspace. Your work will be saved and you can access it whenever you log back in with your TI account. You can also download any of your work to your local machine or upload to GitHub.3. You should get a work environment to pop up similar to the image below. If so we are doing well.
4. Now we need to get our demo code. We can find demo code in the TI Resource explorer. Resource explorer contains all the released code examples and many other helpful technical resources for all TI embedded processors from microcontrollers to DSPs. Next navigate back to dev.ti.com and click on the Resource Explorer box in the Applications tab. You should arrive to a page like this.
5. We can search for our board by part number by typing "MSP432" and it should come up for us. You can also use the left hand navigation and search by device family. Select MSP-EXP432P401R - Rev 2.x (Red) from the drop down menu.
6. Double check your Package Picker is selecting the latest MSP432 SDK. You can click on the package picker in the upper right square icon next to the home icon. Make sure "SimpleLinke MSP432 SDK" is selected on latest and the related plug-ins. Now you know if you'd like to go back to a previous version of the SDK you can use the Package Picker to customize the versioning.
7. Now in the left hand navigation under the "Software" folder click the "SimpleLink MSP432 SDK..." > "Examples" > "Development Tools" > "MSP-EXP432P401R - Rev 2.x" > "Demos" and click on the "Out of Box Experience" sub folder and the "no RTOS" folder. Then the "CCS Compiler" folder and click one more level to "outOfBox_MSP432P401R" to access the project files. On the right hand side on the top line above "main.c" there is a little cloud icon that says "Import to CCS Cloud" when you hover over it. Click that and it should open the project in your CCS Cloud workspace. As you can see you have many options to use different compilers and to utilize a Real Time Operating System or not.
8. Now in CCS Cloud, make sure you have the "OutOfBox_MSP432P401R" project folder selected on the left hand navigation. You can have main.c open in your program window. Now we are going to upload this to our LaunchPad board.
9. Connect your LaunchPad to the PC with the included USB cable.
10. To run our program on the hardware we are going to click the green play button that says "Run" at the top toolbar. CCS Cloud will now help you install a few items needed to communicate with and flash your TI LaunchPad.
11. You may get a Build dialog to pop up or text may pop up in your console as the code compiles. You should see "build finished" pop up and then a dialog box asking to install the browser extension and TI Cloud Agent. Proceed with the installation of both pieces.
12. After installing both pieces, CCS Cloud needs to restart inside the browser. You can click the refresh button and it should reload the page. Make sure that OutOfBox_MSP432P401R is selected in the left hand navigation as it may have changed on the refresh. You can now click run again.
13. If everything went smoothly you should get a new dialog box indicating it's installing target support for MSP432P401R.
14. Next you may get a dialog about error connecting to the target and a firmware upgrade is required. Proceed with the update. Make sure your LaunchPad is connected to the PC via the USB cable otherwise you may get a different error without the option to update the firmware. If you do, you can refresh the page and repeat the step with the LaunchPad connected.
15. If everything went well, now when you click run you should see the code run and flash to the LaunchPad. You can confirm that the code was written in your output console. Your red LED will be blinking.
16. The out of box demo has two parts. The first part is you can change the speed of the blinking by pressing Button 1 (the left button labeled SW1 or P1.1). You can change the color by pressing Button 2 (the right button labeled SW2 or P1.4). The second part of the demo uses the GUI to control the color. To access the GUI go back to Resource Explorer and open the Out of Box Experience GUI folder.
17. With the LaunchPad still connected to the PC, Click the Connect button. Select the default COM port and click open. You will see the color wheel and sliders which you can manipulate to change the color from the PC. You can also change the value for BPM to change the speed of the blink. Cool!
Make sure to close your connection when done, as we need to free up the serial port for later.Now you have some experience with using the TI cloud tools. You can use these resources in the future if they suit your needs. As you can see there are other code examples available to explore if you want to use the official SDK, TI-RTOS, or TI provided libraries. You should also check out the SimpleLink Academy training resources. These will teach you how to use SimpleLink microcontrollers and also learn the basics of how to use Real Time Operating Systems on a SimpleLink MCU.
- TI LaunchPad
- Educational BoosterPack
1. Perform the same procedure to load in the Boostxl-edumkii-joystick example
2. Use UniFlash at dev.ti.com
3. Download the Worldshapers.out at the bottom of this page
4. If your LaunchPad is plugged in, it should be detected by UniFlash. Navigate to the .out file you downloaded and click program. Now the program should be running on your LaunchPad.
- MSP432P401R LaunchPad
Because we need to make changes to the code to support the local Wi-Fi this can be a demo at the front of the room or it can be used with desktop version of CCS.
1. Download the program at the bottom of the page.
2. Upload to the LaunchPad and open a serial connection at 115200 baud.
3. You should see the LaunchPad print out data to get the weather and time.
TI provides SimpleLink Academy to give you on demand training around RTOS and other critical topics. You can access SimpleLink Academy from the Resource Explorer inside of CCS or you can use the online resource explorer at dev.ti.com
First we will review RTOS Concepts: http://dev.ti.com/tirex/content/simplelink_academy_msp432sdk_1_13_00_29/modules/rtos_concepts/rtos_concepts.html
Next we will review TI-RTOS Basics:
On your own you can also check out the TI-RTOS and SimpleLink workshops from training.ti.com:
Hope you enjoyed this little demo of game development on the TI LaunchPad and Educational BoosterPack! Please share if you thought this was a cool project and be sure to check out Dr. Valvano's online materials if you want to dive deeper into ARM Cortex-M based embedded systems.
No preview (download only).
No preview (download only).
No preview (download only).
No preview (download only).
No preview (download only).
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!