For this exercise you will use the development board
to build a human reaction time tester.
The pushbuttons, LEDs, and the mcu will be used to see how fast
you can push a button after a light flashes.
As in Lab 1, be sure you save the SREG when you enter the interrupt routine. In this lab, you will typically be polling a button and doing some arithmetic, so you must save SREG in a register when you enter the interrrupt routine, then restore it when you leave. The following code fragment shows one wayto do these things.
.def temp=r16 ;general use register . . ;rest of the main routine . . ;timer overflow handler Ovfl_intr: push temp ;save the general use register in temp, SREG ;now get the SREG push temp ;and save it
. ; rest of the interrupt routine
; which might use the temp register pop temp out SREG, temp pop temp reti ;back to main routine
You will need to generate a time base for measuring reaction times. Most people have a reaction time in the range of 100 mSec to 200 mSec, but this can be quite variable, up to several hundred mSec. If you use the 0.5 mSec timebase from lab 1, you will have enough time resolution, but you will need a 16 bit interrupt counter.
Make sure that the switches and LEDs are connected as they were in
Lab 1. When in doubt, ask an instructor. Remember that a switch which is
pushed reads back a logic zero. To read, for example, switch6 use:
sbic PIND, 6
to skip the next instruction if bit 6 of the PortD pins is clear.
Produce a program which:
You will demonstrate the working reaction time tester to the TA in the lab.
Your written lab report should include: