EE 308
Homework #7
Due Mar. 7, 2001

  1. What setup do you need to do to have the HC12 generate an interrupt on the falling edge of Input Capture 2? Write some C code to do this.

  2. An engineer is using the HC12 to determine the speed of a motor in RPM. A pulse is generated on Bit 1 of Port T 320 times every revolution of the motor. Bit 1 of Port T is set up for input capture mode, and captures the time of the rising edge. The prescaler bits PR2:0 are set to 010. It is known that the time between pulses is less than the timer overflow time. When the first edge is captured, the TC1 register has a value of 0xD87A. When the second rising edge is captured, the TC1 register has a value of 0x2A5F.
    1. What it the length of time between the two rising edges?
    2. How long does it take the motor to make one revolution?
    3. What is the motor speed in RPM?

  3. What setup do you need to do to have the HC12 toggle bit 3 of Port T on a successful output compare? Write some C code to do this.

  4. You want to generate a 250 Hz square wave using Output Compare 3. What value should you add to TC3 in your toc3_isr()? (Assume that the prescaler bits PR2:0 = 101.) What else should you do in your toc3_isr()? Write the interrupt service routine toc3_isr() to do this.

  5. Write the program for Part 7 of Lab 7.