Let's Get Started - v015
Let's Get Started - v015
This handout will walk you through the steps to create your first program on the Texas Instruments
MSP430FR6989 Microcontroller Launchpad.
Note, we go through a lot of details in these lab manuals, and at times, some students have thought we
included too many steps. However, it is our intent to err on the side of caution and provide as much
support for our students as possible. Thanks for understanding.
1. Open the Launchpad development kit box and the plastic bag that contains the Launchpad board.
2. Connect the Launchpad development board to the PC with the enclosed USB cable.
The bottom part contains the MSP430FR6989 that we will be using in this class. In addition, the
bottom part has the LCD screen, push-buttons, and a number of metal pins that can be used to
connect the microcontroller to the outside world. Each of these will be discussed in more detail
later in the course.
Note, the font type for LED102. Periodically, you will see words and phrases using a similar
format throughout our documentation. This will be your sign that this is either an important
reference from the Texas Instruments documentation or hardware / software tools.
http://processors.wiki.ti.com/index.php/Download_CCS#Code_Composer_Studio_Version_6_Downloads
6. Note, we have had many questions from students about which version of Code Composer
Studio to use. The version that we use on our campus and in all of our classes is version 6.1.0.
Many Udemy students have reported problems with newer versions of Code Composer
Studio. Therefore, we strongly recommend downloading and using only version 6.1.0 for this
class. We will be unable to help with any questions not related to version 6.1.0.
Scroll down the page a little and you will see a link to download CCS version 6.1.0. We will be
using the Windows version of the program. Go ahead and click the Windows button.
8. After logging in, you will need to complete the U.S. Government export approval form. Enter
your information, and click Submit at the bottom of the form.
10. When complete, you will have a 7.3MB file entitled ccs_setup_win32.exe. Go ahead and
open the file.
12. You will be asked to specify the location for installation. Browse to your preferred location or
accept the default and click Next.
14. The next window asks you to Select Debug Probes. Select the options shown below and
click Next.
16. Windows will show you the progress of the download. Note, the download and installation may
take a couple minutes.
18. In the future, you can open CCS from the start menu.
http://processors.wiki.ti.com/index.php/Download_CCS
20. When CCS opens, you will first be greeted by a splash screen.
Note, make sure you do NOT check the Use this as the default… option.
22. When opened, the CCS program may have a Getting Started window open like this. If it
does, go ahead and close the tab.
a) In the box to the right of Target, select MSP430FR6989 from the pull-down menu.
(Note, it is very close to the bottom of the list. This is the microcontroller in the
MSP430FRxxx Family that we will be using in this class.
b) For Connection, you should accept the default, TI MSP430 USB1 [Default].
c) For Project name, enter Blink.
d) Under Project name, check the Use Default Location box.
e) Use the default Compiler version.
f) Finally, toward the bottom of the window, under Project Templates and examples,
select the Empty Project (with main.c).
After double-checking everything, click Finish when you are ready to go on.
27. If you the main.c tab does not open automatically, you can open it anytime you want. First, if the
Blink folder is collapsed like this, click on the small icon in front of its name.
29. Make sure your CCS window looks like this before proceeding to the next step. If not, please go
back and double-check your work.
Please note that the C programming language and CCS tools are case dependent. Therefore,
words like long will need to be lower case, and using LONG will generate an error.
32. The #include <msp430.h> command is used to tell CCS you want to use, or include, another
file when your program is ready. The msp430.h file contains various names of parts of the
microcontroller (that is, registers like P1DIR and P1OUT) which can be used to make your
program more readable.
Lines like this are not part of the actual program and are often called “preprocessor statements”.
They are used strictly by the user to specify to CCS how the program should be used.
33. The next lines are the #define statements. These allow you to associate numerical values with
names that you can use later inside of your program. Again, this will make your code easier to
read.
34. The next line signifies the beginning of your actual program. Every C program has a main()
function. When you run your program, the microcontroller will first look for main() and
perform everything contained inside of its curly braces { } .
main()
35. In the next line, our program puts the microcontroller into a development or “practice” mode by
disabling a security system called the watchdog timer. Essentially, the watchdog timer can be
used to restart your program if something goes wrong. This is very important in some more
critical programs, but not in simple ones like this.
We will learn more about watchdog timers later, but for now, it simplifies our program to disable
it.
Notice also that semicolon (;) at the end of the instruction. You will quickly learn that the C
programming language needs to see these semicolons appropriately or your program will not
work.
WDTCTL = DEVELOPMENT;
For now, just remember that including this line of code in our program allows us to connect the
microcontroller to the “outside” world, or in this case, the red LED light.
PM5CTL0 = ENABLE_RED;
37. The next instruction tells the microcontroller to use its pin connected to the red LED light as an
output that it can turn on and off.
P1DIR = RED;
38. The next line creates a variable called x. This variable will be used to implement a delay so the
red LED light will turn on and off slowly enough that you can see it.
Later in the class, we will introduce the term long and explain how similar terms can be used to
designate how much memory a variable uses in a microcontroller. For now, just recognize that x
can hold values up to about 2,000,000,000.
long x = 0;
while(1)
Loops will be discussed in more detail in a later section, but for now know that this loop will keep
executing the instructions inside of its curly braces { } indefinitely. Without this loop, the
program would only turn the red LED light on and off one time.
40. Next we have our first delay implemented with another loop called a for loop.
For loops will also be discussed in more detail in a later section. For our purposes, it creates a
delay in our program (set by the 30,000 number). Later in this handout, you can play with
increasing/decreasing the length of the delay by changing this number. (But, do not do it yet!)
P1OUT = RED;
43. After the second delay, we turn the red LED light off.
P1OUT = RED_OFF;
44. At this point in the program, the while loop returns us back to the previous delay statement to turn
the red LED light on and then off again indefinitely.
45. Now that we have looked at the program in more detail, let’s get it running on your
microcontroller. In CCS, highlight the program presently displayed in the main.c tab. After
highlighting it, hit the [Backspace] key to delete it. CCS should then look like this:
Your window will probably look like this. Adobe Acrobat and CCS do not always play nicely
together, so for many users, the indentation will not copy.
This looks a little better, but we still recommend you going in and adding spaces to make your
program easier to read.
This is not an issue for when you create your own programs, just when you copy them over from
Acrobat.
48. To Save your changes, you can select Save from the File menu.
For most of this class, we will only be using a single main.c file, so you can use either short-
cut.
50. After saving your program, you need to Build your project by clicking the hammer icon on the
top of your screen. (Get it? You can build things with a hammer?)
If there are any errors, you may have accidentally changed some of the instructions in the
program. Go back and correct the errors. If CCS reports and warnings, you can disregard them
at this time.
54. Sometimes when you click the Debug button, you’ll get an error like this.
If this occurs, make sure your Launchpad is plugged in properly and click Retry.
If the error persists try unplugging and then replugging your Launchpad USB cable and then
rebuilding your program.
For now, check the Do not show this message again box and click Proceed.
56. The CCS Debug interface (or Debugger) will begin loading.
As you might expect, you create and edit your programs from the CCS Edit interface, and you
run your programs from the CCS Debug interface.
58. The Console panel at the bottom will tell you how big your program is. In this example, the
program was 300 + 16 = 316 bytes long.
60. Your red LED light should now be blinking! Congratulations, you have completed your first
microcontroller program.
61. Let’s leave the CCS Debugger and go back to the Editor. To do this, click on the
Terminate short-cut button.
63. However, if you look at your Launchpad, you will see that the red LED is still blinking.
Terminate refers to terminating (ending) the Debugger. Your program will continue to run
on the Launchpad.
65. Save and Build your program. When complete, launch the Debugger.
66. Click Resume to start your new program. Notice that the red LED is blinking faster (3 times
faster).
67. After trying out the 10000 value, you can Terminate the Debugger and try different values
with the Editor. Just remember to Save and Build your program after you make any
changes before launching the Debugger.
In no event shall the owner or contributors to the tutorials and software be liable
for any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services; loss of
use, data, or profits; or business interruption) however caused and on any theory
of liability, whether in contract, strict liability, or tort (including negligence or
otherwise) arising in any way out of the use of this software, even if advised of
the possibility of such damage.