Save this video free

CE351 lec15 Play a song, multiple ISRs

Yiyan Li · 54:57 · Watch on YouTube

CE351 lec15 Play a song, multiple ISRs Watch on YouTube →

Overview

Yiyan Li connects CE351's earlier polling-based tone generation to interrupt-driven music playback, showing how timer overflow ISRs, flags, and TCNT register offsets control note pitch and duration. The lesson then builds a two-ISR state machine for a four-song music game, explaining volatile variables, enum states, note/rest transitions, and how to test ISR timing with an oscilloscope.

Key takeaways

Chapters

0:00 Reviewing Polling-Based Tone Generation and Timer Control
4:05 Why Song Playback Needs Separate Note and Duration Timers
7:00 Replacing Polling with a Timer Overflow ISR
13:00 Testing ISR Timing and Understanding Interrupt Overhead
18:00 Using One-Shot Flags to Hold a Note Index
23:40 Introducing the Four-Song Music Game
28:20 Configuring Two ISRs for Pitch and Note Duration
31:20 Declaring Volatile Variables and Enum-Based States
34:20 Advancing the State Machine on Timer Events
43:20 Switching Between Notes, Rests, and Song Completion
48:40 Recapping Timer Questions and Assigning Task 2.2

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 I've done this so many times. If there's no press skater for timer one, how do we start a timer? Okay. Yeah. TCR1BD and um what's a what's a bit are checking CS10, right? There's no crisis. So, I'm going just show you the answer here because this is not the code we are doing working on today. This is from tutorial number two or something. Okay. So by looking at this one we will um check with our new one. Okay. See this right? Okay. Remember when we did our polling?

0:50 So this was the code and today's tutorial uh the the music box will be entire totally different but we want to go back to this one see what are the differences that's that's the purpose otherwise you couldn't compare like why we are doing this so you have to remember what we did two weeks ago okay so remember what is this code doing or what was this code doing remember was that like remember the f the very first one we did was the the push button you push it it plays the notes the note you release it it stops it okay so that's why um do I need to pull it actually for this

1:39 case you are pulling Let's see. So, if the button is low, which means it's been pressed. So, while it's being pressed, I turn it on, right? And it's pulling it's pulling the overflow flag to do what? Yeah. >> Then flip it, right? So, which means it's pulling the overflow flag in order to flip it. It's basically the timer um will be turned on. After press it,

2:30 turn on and then it keep holding it. See if it's done. That's actually just half period waiting during the half period of

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Yiyan Li.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.