EE 308 -- LAB 6
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_to_serial function to your program.
When you call this function with the time you calculated in Part 1, it
will print the time on the terminal. Call the function in your program
to display the time.
int write_to_serial(unsigned short n)
/* Routine to write an integer to the serial port */
{
char i;
unsigned char t,c[6];
for (i=3;i>=0;i--)
{
t = (n&0x0f);
if (t < 10)
c[i] = t + 48;
else
c[i] = t + 55;
n = n >> 4;
}
c[4] = 0x0d;
c[5] = 0x0a;
for (i=0;i<6;i++)
{
while (!(SCSR&0x80)) ;
SCDR = c[i];
}
}