Due Mar. 11, 1998
- What setup do you need to do to have the HC12 generate an interrupt
on either a rising or falling edge of Input Capture 1? Write some C code
to do this.
- An engineer is using the HC12 to determine how long it takes a
wheel to make one revolution. A pulse is generated on Bit 1 of Port T
once every revolution of the wheel. 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 101. It is known that the period of revolution of
the wheel 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.
What it the length of time between the two rising edges?
- What setup do you need to do to have the HC12 toggle bit 2 of Port
T on a successful output compare? Write some C code to do this.
- You want to generate a 250~Hz square wave using Output Compare
2. What value should you add to TC2 in your toc2_isr()?
(Assume that the prescaler bits PR2:0 = 011.) What else should you do
in your toc2_isr()? Write the interrupt service routine
toc2_isr() to do this.
- You want to generate a 500~Hz pulse width modulated signal with a 30%
duty cycle on bit 6 of
Port T using OC7 and OC6. (Again, assume PR2:0 = 011.)
- What setup is necessary to have the HC12 bring PT6 high when
TCNT = TC7? Write the necessary C code to do this.
- What setup is necessary to have the HC12 bring PT6 low when TCNT =
TC6? Write the necessary C code to do this.
- In your toc7_isr() how should you update TC7 and
TC6 to produce the required PWM signal? Write a toc7_isr()
interrupt service routing in C which will do this.
- Write the program for