Hint

advertisement
Lab 7 Timer Functions
In our textbook, the Example 8.11 on page 394 is an example program using OC7 to control multiple outputcompare functions. The code is developed in assembly language. Please develop a C-larnguage version to realize
this function. One difference here is that intead of generating a 2-KHz signal on the PT0 pin, we will generate
this signal on PT5 pin to drive the speaker on board.
The exact function is thus:
Use OC7 and OC5 together to generate a 2-KHz digital waveform with a 40 percent duty cycle on the
PT5 pin to drive the speaker on board.
If the duty cycle is changed to 90 percent while the frequency is the same, could you hear any difference
of the sound?
Hint: Please go through Chapter 8: Section 8.1 – 8.6
1. Add “vector.c” into the Sources folder in the project
2. Add “hcs12.h” into the Includes folder in the project
3. The project configuration should be similar to:
4. You need to change the “vector.c” corresponding to the interrupt functions in the main.c code
Here is an example (your code may be different):
Declare all the interrupt
functions appearing in main.c
You may need this (depends on your code)
List the sequence of interrupt functions here
5. Please note the OC7 and OC5 are used in the assignment instead of OC7 and OC0 in Example 8.11.
6. Show the waveform (both 40% and 90% duty cycle) on oscilloscope for demonstration.
References on Textbook:
Download