E15 Laboratory 5
Introduction to Assembly Language
Useful references for
- Start Code Composer Studio and pick a workspace in a folder you have
created on the desktop (or other appropriate place). All projects will
be folders within this folder.
- Start a new assembly language project:
File→New→Project→Code Composer Studio→CCS Project
then next. Choose a project name,
pick MSP430 as the Device Family, MSP430G2553 as the device variant, and
Empty Projects→Empty Assembly-only Project
as the template (see below).
- Make sure you are in the "Edit" perspective. At the left of the
top window bar it should say "CCS Edit." If not, there should be a
"CCS Edit" button at the upper right of the window, or you can go to
Window→Open Perspective→CCS Edit.
- At the left of the window should be the "Project Explorer" (or go to
- If there is a file called "main.asm" open it. If not create one
(go to File→New→Source File and create a source file called "main.asm")
and open it.
- Replace the contents of your "main.asm" with the one listed below (link
- Connect your launchpad and build the program (hit the debug button,
. There should be no errors and
your program will be downloaded to the LaunchPad.
- When the debug perspective open click on
View→Disassembly. If the Debug Perspective is not active
go to Window→Open Perspective→CCS Debug.
- Now step through the code using the "Step-Over" button (),
or F6 (Run→Step Over) . You
should see the cursor step through your code. Every time you
execute the "xor" instruction, the LED on your LaunchPad board should
Replace the code in "main.asm" with the code listed below (link
The LED should now blink if you run the program (Run→Resume
(F8) or the "Resume" button, ).
Make sure you understand how the code works. You will turn in a version to
which you have added comments as part of your write-up.
Take the code from task 1 and add a function that allows for a variable
delay by putting a number in R13 before calling. Call this function "myVarDel."
For example, the code below:
mov.w #3, R13
should generate a delay 3 times longer than the original task 2 code.
Write a program that lights the LED on Port 1 bit 0 when you press the
button on Port 1 bit 3. Remember the switch connects Port 1 bit 3 to
ground when you press it, so you need to activate the pull up resistor on
that pin so that the pin will be high when the button is not pushed.
Implement the traffic light with the busy street scenario with timing as
lab 2. To make life a little easier you can use just the right two
columns of LED's (these are all on port 2 - see below). Use the work you did in
Tasks 3 and 4 in the completion of Task 5. Make use of the ".set"
directive to define constants. This should not require a lot of code
(you don't need to code rigidly as a state machine - think a little before you start). You can assume the function "myDelay"
is a 1 second delay.
|at least 6
(wait for button
Turning in your code
- You should include comments (either as part of the code, or as part of
the text of your report) so that a student in E15 who has not done this lab
could fully understand what you did and could quickly reproduce it.
- Comments should not wrap around. If this happens, print in landscape
mode or split comments to multiple lines.
- Line up different parts of code as much as possible:
- Labels start in leftmost column.
- Assembler instructions should all be lined up.
- First arguments to instructions (e.g., src) should be lined up (you might
also want to line up dst).
- Comments should be lined up (at least in each block of code).
- If cutting and pasting code into your report creates lots of extra blank
lines, remove them.
Please turn in the following (in order) in a single pdf to moodle.
- Task 1: Well commented code. 10 pts.
- Task 2: Well commented code. 25 pts
- Task 3: Well commented code. 25 pts
- Task 4: Well commented code. 40 pts