EE 476: Laboratory 3
You will construct a cricket-call generator which will produce audio output
of a simplified cricket call. A cricket call may be very complex, but we will
limit ourselves to the following form.
- A call is made up by repeating indefinitely a chirp and a silent period.
If the duration of the silence is zero, the call is refered to as a trill.
- A chirp is made up of a certain number of syllables with specific duration
and repitition interval.
- A syllable is made up of a squarewave burst at a certain frequency.
The image below summerizes the definition ( from Manfred
You will need the 8515 header file
for CodevisionC. You will probably want to review the code examples given in
the CodevisionC Tutorial.
You will use PortB of the mcu to read four switches. One bit of another port,
perhaps bit 6 (which happens to be adjacent on the connector to ground), will
be used to drive an earphone.
You will need to figure out how to generate a variety of time delays and durations.
I suggest the following scheme, but you may use any scheme you want.
- Timer 0 is used to schedule all intervals on the millSecond scale, as outlined
in the second example in the Program
Organization document. The program becomes a set of subroutines which
execute when their timer-counter is zero.
- Timer 1a is used to generate the high speed interrupts necessary for the
squarewave frequency. Since timer 1 has 16-bit resolution, it is fairly easy
to get good frequency accuracy.
- Write a C program which implements a cricket-call generator with the following
- Buttons 0-3, when individually pushed, produce four different calls,
according to the table below. Once started, the call repeats indefinitely,
until the next button push. All times are in milliSeconds. Frequencies
are in Hz.
||chirp+ silence duration
||number of syllables
- Button 4, when pressed, plays all four songs in sequence for two seconds
each with 0.5 second of silence between each song. After all four have
played once, the playback stops.
- Output from one bit of a port will be a squarewave connected to a speaker.
- Frequency accuracy should be +/-1%. Duration accuracy should be +/-1
- Demo this program to a staff member. Show that all specifications are met
by verifying times and frequencies with an oscilloscope.
- Your written lab report should include:
- The scheme you used to detect the pushbutton state. (e.g. polling loop,
- How you generated the freqencies and an measurement of how accurate
- How you generated the various time intervals required by this project.
- Other design aspects of the assignment (e.g. did you use table lookup
for the frequencies or did you hardcode them).
- A heavily commented listing of your code.
Copyright Cornell University Jan 2002