Table of Contents

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

Hardware Configuration

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:

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:

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.