E15 Laboratory 5
Introduction to Assembly Language

Useful references for E15 labs

Task 0

  1. 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.
  2. 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).

    Hit "Finish."
  3. 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 left of the window, or you can go to Window→Open Perspective→CCS Edit.
  4. At the left of the window should be the "Project Explorer" (or go to View→Project Explorer).
  5. 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.
  6. Replace the contents of your "main.asm" with the one listed below (link to file).
  7. 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.
  8. When the debug perspective open click on View→Disassembly.  If the Debug Perspective is not active go to Window→Open Perspective→CCS Debug.
  9. 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 toggle.

Task 1

Replace the code in "main.asm" with the code listed below (link to file).

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.

Task 2

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
            call    #myVarDel
should generate a delay 3 times longer than the original task 2 code.

Task 3

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.

Task 4

Implement the traffic light with the busy street scenario with timing as in 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.

Time
(Seconds)
Light Setting
North-South East-West
at least 6
(wait for button
to continue)
Red Green
2 Red Yellow
1 Red Red
4 Green Red
2 Yellow Red
1 Red Red

Turning in your code

Grading

Please turn in the following (in order) in a single pdf to moodle.