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/
Everything required for the workshop experience is provided on this page. This page is accessible from https://goo.gl/JzuSz3 for your convenience. Scroll down to the Schematics section for the slides and the Code section for downloads.
Pre-workThis experience is split into two distinct tracks. Track A is for setting up for the full TI-RTOS running on a local copy of Code Composer Studio IDE. Track A focuses on getting the computer set up for building the game project from source on the MSP432 LaunchPad. Track B is for setting up the TI Cloud Tools experience which is a much more lightweight and quicker procedure using the web browser. For speed, Track B is recommended to experience the game demo, but if participants would like to modify their game, then Track A is recommended so they can fully develop with TI-RTOS.
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.
http://www.ti.com/tool/ti-rtos
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, 8, or 9 is recommended with TI-RTOS for MSP432.
https://www.ti.com/tool/download/CCSTUDIO#previous-versions
Lab 1A - Setting up Code Composer StudioCCS 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. You will want to use this in CCS 9 or previous because later versions (10+) don't import the TI-RTOS for MSP432 support correctly after the install.
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.
Setup Hardware
Hardware Required
- MSP432P401R LaunchPad or MSP432P4111 LaunchPad
- BOOSTXL-EDUMKII
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. These can be found in the MSP432P SDK. Go to Project > import CCS Projects... and navigate to the SDK examples.
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.
Lab 2A - TI-RTOS based gameNow 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.
This concludes Track A. Next procedure relates to Track B.
Lab 1B - MSP432 Out of Box experience and codeHardware Required
- TI LaunchPad
To start off the workshop we will load up the out of box demo code from TI Cloud tools. 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 gallery tab under cloud tools
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 Cloud Tools will load your virtual workspace. For example in CCS Cloud or GUI composer, 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 on this page.
5. Connect your LaunchPad to the PC with the included USB cable.
6. 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.
7. After installing both pieces, the TI Cloud Tools needs to restart inside the browser. You can click the refresh button and it should reload the page.
8. 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.
9. If everything went well, you should see the code run and flash to the LaunchPad. You can confirm that your red LED will be blinking. You can also change the value for BPM to change the speed of the blink. Cool!
10. Make sure to close your connection when done, as we need to free up the serial port for later.
For the next examples you can use the BOOSTXL-EDUMKII examples below. Import those as you wish to CCS Cloud and run them to explore.
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.
Lab 2B - TI-RTOS based game using UniFlash toolHardware Required
- 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.
RTOS Concepts and TrainingTI 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:
- https://training.ti.com/ti-rtos-workshop-series
- https://training.ti.com/introduction-simplelink-sdk
- https://training.ti.com/simplelink%25C2%25A0academy-msp432-sdk
If you prefer a traditional class style experience, try out the edX course Real-Time Bluetooth Networks. This is a great course to go in-depth on RTOS and IoT topics.
https://www.edx.org/course/real-time-bluetooth-networks-shape-the-world
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.
Apply to TIInterested in applying for TI internships and Full-time opportunities? Check out what's next at careers.ti.com. Be prepared for interview season at the beginning of each semester. Review your fundamentals from circuits and other classes. Apply online to as many opportunities as you can and visit TI at the career fairs at your school.
https://careers.ti.com/working-at-texas-instruments/
https://careers.ti.com/hiring-interview-process-2/
Comments