Stopwatch Lab

For this lab you are to write a program that makes the Z16 development board behave like a simple stop watch. At minimum you will need to use one timer, GPIO, interrupts and polling. Your stopwatch will need to keep time in 0.1 second increments and display it. The display will show four digits (9999 10th of seconds) and the left most digits will be blank if they are zero (so for 2.4 seconds you will see "24" 10th seconds rather than "0024"). You can write your program in C or assembly or a little of each (but there is no reason you need to use assembly), its up to you.

The buttons of your stopwatch will have the following functions:

  • sw3: Stop/Resume. Pressing sw3 (the right most button) starts the stopwatch counting sequentially (about 1/10 second per count). Pressing sw3 again, stops the counting but keeps the current count on the displayed. Continued pressing of sw3 will keep stopping/resuming counting.
  • sw2: Pause display/Resume. Pressing sw2 pauses the display but the stopwatch keeps counting (the display no longer reflects the current count). Pressing sw2 again causes the display to update to the current count and resume displaying time.
  • sw1: Reset to 0. Pressing sw1 resets the count to zero but keeps the existing display mode (counting, stopped, or paused).

You should scan the display (either vertically or horizontally) rather than drawing the digits.

You should write your program so that you can easily expand the display code to include alphabetic characters. You might want to make reusable libraries (separate source files) for the display and another for the buttons (you might need them in a future lab or your final project (hint: read the other labs and see)). You will not need to add and wires or components for this lab (in fact you should NOT add any).

Answer these questions and include with your lab submission (as a readme.txt file):

  1. How many timers did you use for the LED display portion of the lab? Why?
  2. Did you order the display characters by column or row? Does it matter?
  3. Did you find that your display blinked or flickered, or that the characters seemed dim, or that one row or column of dots was brighter than the rest?
  4. If you solved that, what was the problem? If not, what do you think the problem is?
  5. Did you use polling or interrupts to monitor the switch state? Why? 
  6. How did you de-bounce the switches?