EE 308 -- LAB 7
More on the HC11 Timer Subsystem
Connect one of your debounced switches to Input Capture 2 (Port A, Bit
1), as shown below:
Figure 1: Circuit to measure speed of button pushing.
The right part of Figure 1 is what
the signal to IC2 will look like if you push the pushbutton twice.
-
Write a program to use the HC11 to measure the time TR between
the two falling edges of the signal in Figure 1.
Set the prescaler so you can measure time differences up to 500 ms.
In your program, TR should be a sixteen-bit unsigned number.
You can use BUFFALO to print the hexadecimal representation of a sixteen-bit
number to the terminal with the following function:
void out2bytes(unsigned int n)
{
asm(" jsr 0xffc1");
asm(" jsr 0xffc4");
}
-
Test your program on your EVBU. See how fast you can push the switch twice.
-
Add a TOC1 interrupt routine to generate a 500 Hz pulse width modulated
signal on the OC2 pin. The duty cycle of the signal should be determined
from the three least significant bits of Port C, according to this table:
PC2:0 |
Duty Cycle |
PC2:0 |
Duty Cycle |
000 |
20% |
100 |
60% |
001 |
30% |
101 |
70% |
010 |
40% |
011 |
80% |
011 |
50% |
111 |
90% |
(Note: You can use floating point (i.e., numbers with a decimal point)
with the HC11 C compiler, but you should not do so for this program. Programs
which use floating point numbers are too large to fit in the small amount
of memory in your HC11 chip.)
Show that your works by displaying the output of the OC2 pin on the
logic analyzer. While the 500 Hz signal is being generated, you should
be able to measure your push-button time.
-
Add to your program a routine for incrementing Port B using the real time
interrupt as you did in Lab 5. You should simultaneously display the Port
B output on LEDs and the OC2 pin output on the logic analyzer. You should
still be able to measure you push-button time.
Bill Rison,
<rison@ee.nmt.edu
>
Wed Feb 25 1998
© 1998, New Mexico Tech