CE-2800 Embedded Systems Software
Lab 3: Bouncing Light

Objectives

Assignment

In this lab, you will create a "bouncing LED" program (did you ever see the "Knight Rider" TV series? It's OK if you didn't - it was stupid). Specifically, your program must:

  1. Begin by lighting LED 0.
  2. After waiting for exactly X ms, light LED 1 and turn LED 0 off. X is the number of 10*(number of chars in your MSOE email name) milliseconds. Thus, if your email name has 7 chars, the delay must be 70ms.
  3. Continue "moving" the lighted LED every X milliseconds. After LED 7 is on, start moving the lighted LED position in the opposite direction in the next step.
  4. When LED 0 is reached, start moving back in the other direction once again.
  5. Repeat this forever.

Here is a flowchart to help you visualize the logical structure of the preceding sequence:

Design constraints:

Hints:

You can use the DelayLoop sample from the course website as a starting point; however, you will have to incorporate the delay code as a subroutine from the "main" body of code.

Use the LSR instruction to move the LED position to the "right" (for example, from LED 7 to LED 6). After each shift, use a branch instruction that tests to see if the bit you shifted was shifted into the Carry bit. (Note: the DelayLoop sample code uses a branch instruction that tests the Zero bit, not the Carry bit, so you cannot use that code directly) Similarly, to move to the left, use the LSL instruction, each time testing to see if the bit was shifted into the Carry bit.

As an option, you may implement and use additional, separate subroutines to handle moving the LEDs to the right and left. You must however, still implement a single delay subroutine.

Demonstration

You must demonstrate your working program on your board, with the oscilloscope measuring the period of either LED 1 or LED 6.  Develop and debug your program in AVRStudio first (its' easier that way). It may be helpful to set the AVRStudio Simulator clock speed to 8MHz, and adjust your timing loop to result in a delay that is twice that required when it runs on your 16MHz board.

Lab Submission (due 11:00pm, Tuesday, January 3)

For your submission, prepare a report in Microsoft Word format.

Be sure that you answer the following question in your report.

Copy/paste your program's instructions from the .lst file generated by the Assembler into your report.

Include both the Word report and your program (.asm file) in your submission.

Upload your submission through Blackboard (assignment "Lab 3").

Be sure to keep copies of all your files, in case something gets lost.

Grading

Your lab grade will be determined by the following factors:

Report - content, spelling, and grammar (use the built-in spell checker)

Program - comments and formatting are important aspects of assembly language programming! And it has to work correctly.

Timeliness of submission as stated in the course policies.