Summary: This is Lab 3 of the Colorado State University Microprocessors course using the eZ430-F2012 development tool. This introductory lab will walk you through the process of creating an assembly project, assembling a program, downloading it to the EZ430 (the development kit for the TI-MSP430F2012) and executing / debugging the program. When you complete this lab, you should be able to: - Understand the IAR Embedded Workbench IDE. - Assemble (build) a program using the IAR Embedded Workbench. - Download a program onto your EZ430. - Run a program and examine memory registers. - Use stepping and breakpoints to debug the program. Because you will perform all of these procedures in every lab you do after this, a complete understanding of the material in this lab is necessary.
This introductory lab will walk you through the process of creating an assembly project, assembling a program, downloading it to the EZ430 (the development kit for the TI-MSP430F2012) and executing / debugging the program. When you complete this lab, you should be able to:
Because you will perform all of these procedures in every lab you do after this, a complete understanding of the material in this lab is necessary.
You will need to read the following introduction material prior to completing this lab, all are available on the ECE 251 website.
The eZ430 debugger/emulator should install its drivers automatically. To install IAR Embedded Workbench Kickstart Version, please visit www.ti.com or www.iar.com for the latest version of the software with installation instructions.
Invoke the IAR Embedded Workbench in one of the following two ways:
To create the shortcut on your desktop, right click the mouse on IarIdePm.exe and then left click on create shortcut. Then click on this shortcut to invoke the IAR Embedded Workbench application.
The first thing you will see is the Embedded Workbench Startup screen. This screen will be a good shortcut to open existing workspaces and create new projects in the future, but for now, click the Cancel button. Note that a workspace can hold one or more projects, each which can hold groups of source files (the files that contain your assembly code).
Click on File -> New -> Workspace. This opens a new workspace in which to place your projects. You must always open a workspace before you can create a new project. To create a new project, click Project -> Create New Project… The Create New Project box will appear. IAR lets you choose whether you want to create an assembly (asm), C, or C++ project. Expand the asm tab and click OK once you have selected the asm option.
| New Project Window |
|---|
![]() |
IAR will ask you to specify where you would like to save your .ewp project file. It is recommended you create a folder for your workspaces on your u: drive such as u:\ee251\Labs\ in which you can store all your future labs. Create a folder called Lab 3, name your project Lab 3, and click Save. At this point, you should also download the add_primes.s43 file provided on the class webpage into the same folder.
Look at the left of your screen. You will see the workspace window where your projects and source files are organized.
| Workspace Window |
|---|
![]() |
On the right is the project window. The project window shows the assembly file template discussed in Introduction To Assembly Programming from the pre-lab material. You will not be using this file for this tutorial. Before anything else, click on File -> Save Workspace and save your workspace in the same folder as the project.
Now add the file we are going to examine in the tutorial. In your workspace window, right click on the project name and select Add -> Add Files… At the bottom of the page, change the Files of type tab to the Assembler Files option. If you downloaded the file from the class webpage, go ahead and select the add_primes.s43 file and click Open. You should see the file added to your workspace window. Right click on the asm.s43 template and remove it from the project then take a look at the add_primes.s43 code. This assembly program has stored the first six prime numbers in an array in memory and adds them up into register six. See if you understand what is going on by referencing the pre-lab material.
Before we can compile our code into an executable object file, we need to set the project options. Using the Project pull-down menu select Options or simply right click on the project and select Options… This will bring you to the Options for node “<project_name>” screen.
| Project Options Screen |
|---|
![]() |
Before we compile the project, make sure to save your project to preserve its settings. Select the add_primes.s43 file in the workspace window and click Project -> Compile. Alternatively, you can right click on the source file and select Compile. When the workbench is finished compiling your source code, you will see a new window at the bottom of the screen called your Build Messages Window. It should say that there are 0 errors and 0 warnings.
| The "build message" window |
|---|
![]() |
To see what happens when your code contains an error, erase one of the semicolons preceding a comment in the add_primes.s43 code and re-compile. The build message window displays:
Double click the line that says “Error[0]: Invalid syntax.” In the file, your cursor will be placed close to the location of the error. Fix the error, and then re-compile.
Now make sure that your EZ430 is plugged in and click Project -> Debug. This will run your code on the EZ430 and put you in debugging mode.
A new window has been added to the screen in debugging mode. It is called the Disassembly Window. After the assembler compiles your code into machine code, a disassembler program does the opposite and creates the contents of the disassembly window. You can apply the debugging commands to either the coded assembly file or the disassembly window. Generally, this tool is more useful when the developer has written his/her application using the C programming language and wants to see how the machine interpreted his/her code in assembly.
The workbench allows users to move and dock windows as they wish. To see this, click View -> Memory and View -> Registers. Click on the window labels to drag and dock them in the same tab group as the Debug Log and Build windows. These windows are updated as the program executes, giving the user extremely useful insight to the inner workings of his/her program.
NOTE: If the contents of the window selected in each tab group ever change, the changed contents will be highlighted red to show the change.
The memory window allows the user to navigate the entire memory map of the MSP430. Since we used assembler directives to load the array of prime numbers starting at memory location 0200h, type 0x0200 into the Go to box. You will see the array stored in consecutive words in memory.
| Memory Window |
|---|
![]() |
Instead of Memory, IAR also gives you the option to looking at:
NOTE_01: You can use the information and main memories just the same. The only difference is how the memory is physically segmented and the address.
NOTE_02: If you look at the FLASH memory, notice that this is where the main program is stored. The numbers you see are the instructions of the program that have been stored for program execution.
The register window shows the user any of the important registers whether they be peripheral control registers, special function registers, or just the basic CPU registers. For the most part, you will only be interested in the CPU Registers, but know that the other registers are available for viewing. Also note that the Status Register (SR) containing the status bits can be expanded to see each individually labeled bit.
While stepping through the program, periodically check the Memory and Register windows to see how they change according to your code.
Run your mouse over these buttons in the top left corner of your debugging session and read their function in the bottom left corner of the IAR workbench frame.
| The Debug Buttons | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Sometimes it is beneficial, if you want to know how your program is executing at a certain point in its execution, to use breakpoints. To place a breakpoint in the program, double click on the margin next to the line at which you wish to set a breakpoint (or right click on the line and select toggle breakpoint (conditional)).
For example, the initial operators in every assembly code project that initialize the controller after a Power Up Clear can often be assumed to work properly. If you would like to run the program starting immediately after this section of code, add a breakpoint at the line labeled main. Since we have two clear operators in the beginning of our code that we know will work, place a breakpoint at the first mov.w instruction line of the main program. Press the Program Reset button to restart program execution and then press the Run to execute until the breakpoint. From here on, play with the other buttons to gain some intuition as to their function.
NOTE: Debugging can also be done in the disassembly window. Try it out and see if you can follow what all the numbers mean in regards to the CPU registers and memory.
For more information on debugging, reference the EZ430_UserGuide. An in-depth understanding of the debugging module is a truly powerful tool for future programming.
After completing this tutorial, you should feel comfortable working with the IAR Embedded Workbench. If you do not, you may want to go back and do it again. Also, make sure you have read and understand the material from lab section 3.2. It will be critical to the execution of future labs.
1. Set up the EZ430, IAR Embedded Workbench, and all necessary hardware.
2. Complete the tutorial.
Call the lab TA and repeat the tutorial in their presence, without reading the directions. When you can do this without looking at the instructions, the TA will check you off. Review any part of this lab you are not sure about.
The lab report is due at the beginning of the next lab. For the lab write up, include the following:
"Msp430x2xx Family User's Guide." Dallas, Texas: Texas Instruments Incorporated, 2005.
.
"This introductory lab will walk you through the process of creating an assembly project, assembling a program, downloading it to the EZ430 (the development kit for the TI-MSP430F2012) and […]"