This is not a current assignment. If you are currently enrolled in CE2810, do not do this assignment expecting to receive credit for it.

Lab 6: Music with Pointers

Lab activity

In this lab you will turn your ATmega32 into a song playing machine. You will build upon the work from lab 5.

You must develop a string format for specifying a songs. Your format must allow any note within three octaves of middle C to be specified. (Note: In order to generate frequencies as low as 33 Hz (C three octaves below), you'll need to modify the prescaler on the Timer/Counter1 subsystem.) In addition, you must be able to specify the length of time the note should be played. You may specify this either in milliseconds or in terms of whole, half, quarter, eighth, and sixteenth notes. You may also find it useful to introduce the concept of a rest. Your string format may look something like this (but you have complete freedom to specify it as you choose… you will be graded on this):

“Hot Crossed Buns.0e02.0d02.0c01.0e02.0d02.0c01.0c04.0c04.0c04.0c04.0d04.0d04.0d04.0d04.0e02.0d02.0c01”

where

  • The characters preceding the first period are the title of the song.
  • the first digit (between -3 and 3) specifies the octave, e.g., 0 for middle octave, -3 for three octaves below, 3 for three octaves higher.
  • the letter specifies the note (same as lab 5).
  • the two digits after the letter specify the fractional length of the note (between 01 and 16), e.g., 01 for a whole note, 04 for a quarter note, 16 for a sixteenth note.

Hardware Configuration

  • Connect LCD panel to PORTB (do something smart here)
  • Connect keypad to PORTC (optional)
  • Connect the piezoelectric speaker to OC1A

Project Configuration

Be sure to configure your GCC project correctly. For example, make sure that you adjust the stack pointer location, specify that the C99 standard should be used, etc…

Implementation Details

You may choose to implement all or part of this program in C. You may reuse any code from earlier in the quarter. You must decide what functions to write and what each function should do. You are limited by the following constraints:

  • You must make use of interrupts and Timer/Counter0 to control the length of each note.1)
  • You must make use of a pointer to specify the position within the string that specifies a song.
  • You must clearly document the format for your string.
  • You must demonstrate your program using the song shown above (Hot Crossed Buns) and at least one other song of your choosing.
    • It's fine to have them play in sequence, or you may wish to select from a number of different songs using the keypad.

Demonstration

Each student must demonstrate the successful implementation of their program on their SunRom hardware. This demonstration is due by the end of the laboratory session.

FAST Data

You should indicate how much time (in minutes) you spend on this assignment in the FAST database. You are encouraged to log your activity as you work on the project. At a minimum, you should log all of the time spent on this assignment before the due date given above. All time spent on this assignment should be entered into the week 6 column (even if you worked on it in week 5 or 7).

Lab Deliverables

You should follow your instructor's instructions for your lab submission.

Hornick Taylor

If you have any questions, consult your instructor.

Grading

Your grade will depend on the following:

  • Software design, documentation and implementation.
  • String specification and documentation regarding it.
  • Successful demonstration.
  • FAST submission.
  • Timeliness of submission.
1) As some of you have already discovered, it is not possible to get a long enough delay with the Timer/Counter0 subsystem since it is only an 8-bit counter. This is easily rectified by placing a counter within the ISR. For example, suppose the T/C0 interrupt length is 2ms and you want a 20ms delay. You counter within the ISR starts at zero and gets incremented each time the ISR is fired. When the counter reaches 20 (the ISR has fired 20 times) the counter is reset and the code for reading and playing the next note is executed. Hint: You may find that it is easier to decrement the counter instead of incrementing it.
ce2810labs/lab6.txt · Last modified: 2009/06/03 11:22 (external edit)
 

This website is not owned or managed by the Milwaukee School of Engineering.

© 2003-2010 Dr. Christopher C. Taylor, et. al. • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ • -> RSS <-