Due Mar. 8, 2000
- 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 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.
- What it the length of time between the two rising edges?
- How long does it take the motor to make one revolution?
- What is the motor speed in RPM?
- 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.
- Write some C code to set up Channel 3 of the HC12 PWM to generate a PWM
signal with 40% duty cycle and 1 kHz frequency.
- 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.
- Write the program for Part 6 of
Lab 7. Note that this includes the
code for Part 5, which reads Port B, sets the duty cycle of a 1 kHz PWM signal
based on the switches connected to Prot B, and measures the speed of the motor
with an input capture interrupt.