You will construct a one-octave, single voice,
square-wave output, keyboard synthesizer.
The keyboard
will produce the musical notes corresponding to:
C4 262 Hz (middle C)
D4 294
E4 330
F4 349
G4 392
A4 440
B4 494
C5 523
Procedure:
You will need to read a port (perhaps port0) to get key presses. Remember to use a 47k resistor pack with the switches as shown in Lab 2.
HSO.0 output can be programmed in a fashion similar to the code fragment given in Lab 2, but changing the variables "period" and "clear_t" for each different note. Unlike Lab 2, you will not be using timer2 as a time base in this lab.
HSO.0 can drive the earphone directly, but is somewhat loaded by the earphone. You can make it louder by using a 74xx driver or an op-amp.
Write a program which implements a one-octave keyboard synthesizer using eight switches connected to an input port and an earphone connected to HSO.0. HSO.0 should be programmed to produce a squarewave with a 50% dutycycle. The frequency of the notes should be accurate to better than 0.1%.
When you demonstrate the keyboard to a staff member, you will play a scale and a short melody of your choice. You may use the melody shown below. The keyboard needs to produce only one note at a time (single voice).
Notes: E E E F F G F E D E F G C F E D C C Play the hollow notes twice as long as the filled notes.Play the melody.
For extra credit do one of the following:
Your written lab report should include: