Hardware Reference
In-Depth Information
E8.12 Write a program to generate an interrupt to the HCS12 20 ms after the rising edge on the
pin PT2 has been detected.
E8.13 Suppose that the contents of the TCTL1 and TCTL2 registers are $79 and $9B, respec-
tively. The content of the TFLG1 register is $00. What would occur on pins PT7 to PT0 on the
next clock cycle if the value $7F is written into the CFORC register?
E8.14 Write an instruction sequence to confi gure the modulus down counter so that it gener-
ates periodic interrupts to the microcontroller every 40 ms.
E8.15 Modify the programs in Example 8.8 to avoid the drawback in the generated song.
E8.16 Find the score of the song “Home, Sweet Home” and modify the program in Example 8.8
to play it.
E8.17 Write an instruction sequence to generate a 160-kHz digital waveform with 80 percent
duty cycle from the PWM2 pin output. Use left-aligned mode.
E8.18 Write an instruction sequence to generate a 120-kHz digital waveform with 40 percent
duty cycle from the PWM2 pin output. Use center-aligned mode.
E8.19 Write an instruction sequence to generate a 10-kHz digital waveform with 60 percent
duty cycle from the PWM2 pin output. Use left-aligned mode.
E8.20 Write an instruction sequence to generate a 5-kHz digital waveform with 70 percent duty
cycle from the PWM2 pin output. Use center-aligned mode.
E8.21 Write an instruction sequence to generate a 20-Hz digital waveform with 50 percent duty
cycle using the 16-bit mode from the PWM1 pin output. Use left-aligned mode.
E8.22 Write an instruction sequence to generate a 10-Hz digital waveform with 60 percent duty
cycle using the 16-bit mode from the PWM3 pin output. Use center-aligned mode.
E8.23 What is the slowest clock signal that can be generated from the PWM output?
8.14 Lab Exercises and Assignments
L8.1 Frequency measurement . Use the pulse-accumulator function to measure the frequency
of an unknown signal. The procedure is as follows:
Step 1
Set the function generator output to square wave and adjust the output to between 0 and 5 V.
Connect the signal to the PAI (PT7) pin.
Step 2
Also connect the signal to an oscilloscope or a frequency counter. This is for verification
purposes.
Step 3
Output the message “Do you want to continue to measure the frequency? (y/n)”.
Step 4
Set up the frequency of the signal to be measured and enter y or n to inform the microcontroller
if you want to continue the measurement.
Step 5
Your program would read in the answer from the user. If the character read in is n, then
stop. If the answer is y, then repeat the measurement. If the character is something else,
then repeat the same question.
Step 6
Perform the measurement and display the frequency in Hz in decimal format on the screen
and go back to step 3. Use as many digits as necessary. The output format should look like
 
Search WWH ::




Custom Search