EE 308
Homework #7
Due Mar. 1, 1998

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

  2. What setup do you need to do to have the HC11 toggle bit 6 of Port A on a successful output compare? Write some C code to do this.

  3. You want to generate a 250~Hz square wave using Output Compare 2. What value should you add to TOC2 in your toc2_isr()? (Assume that the prescaler bits PR1:0 = 11.) What else should you do in your toc2_isr()? Write the interrupt service routine toc2_isr() to do this.

  4. You want to generate a 500~Hz pulse width modulated signal with a 30% duty cycle on bit 6 of Port A using OC1 and OC2. (Again, assume PR1:0 = 11.)
    1. What setup is necessary to have the HC11 bring PA6 high when TCNT = TOC1? Write the necessary C code to do this.
    2. What setup is necessary to have the HC11 bring PA6 low when TCNT = TOC2? Write the necessary C code to do this.
    3. In your toc1_isr() how should you update TOC1 and TOC2 to produce the required PWM signal? Write a TOC1 interrupt service routing in C which will do this.

  5. Write the program for Lab 7.