EENG 383

Lab 3 - Music Box with Timers


Lab: 3
Status Live

InLab 3

Some self-guided activities.

Lab 3 assignment

You may work in teams of one or two.

Lab assignment

Build an embedded system which plays a song every time the upper button is pressed.

Note If you have an existing configuration (say from the inlab03) that you want to copy over to a new project (say for your lab03), then: Program Requirements
  • A whole note should take 1 second, half note 0.5 seconds, and so on,
  • Have a 32nd rest between notes,
  • Use Timer 1 with a 1:1: prescaler to generate the note frequencies,
  • Store at least two octaves worth of notes (half periods of timer 1) in an array called scale. For example, my code has the following (partial) declaration:
    uint16_t scale[NUM_OCTAVES*12] = {12864,12144,11472,10816,10208,9632,…
    Note, I used a #define to set NUM_OCTAVES to 2,
  • Use Timer 0 with a 1:256 prescaler to generate the note durations,
  • Store your song in two arrays, one for notes and one for duration,
  • Set the speaker pin to logic 0 when you are not playing a note,
  • Use the MCC functions to: Do not use the TMR1_ReadTimer or TMR0_ReadTimer functions.

    Verification:
    Play the notes of a song with at least 12 notes and that includes at least 2 different note durations.

    Turn-in

    You may work with a single partner (or alone) to complete this lab. Submit your main.c file on Canvas using the instructions posted there. You should take note of the Rubric that will be used to evaluate your assignment. Please form a group before submitting using the instructions posted on Canvas. You will demonstrate your code at the beginning of lab.