Save this video free

CE351 lec11 Timer/counter, play single notes, play a song

Yiyan Li · 39:39 · Watch on YouTube

CE351 lec11 Timer/counter, play single notes, play a song Watch on YouTube →

Overview

Yiyan Li explains AVR timer setup and polling through register masks, prescalers, overflow flags, and counter preload values, then applies the same ideas to generate notes and sequence a song. The song design separates pitch toggling with Timer3, note duration with Timer1, and the rest between notes with a delay function.

Key takeaways

Chapters

0:00 AVR Timer Setup with Bit Masks and CS Bits
6:50 Stopping Timers and Choosing an AVR Register Convention
10:49 Waiting for Timer1 Overflow with TOV1
16:40 Preloading a 16-Bit Counter and Repeating a Note
21:40 Breaking Song Playback into Three Timing Controls
26:55 Using Timer1 to Set Each Note's Duration
30:20 Using Timer3 for Pitch and Advancing Through a Song

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

Transcript excerpt

0:00 Okay. So these are the steps uh needed the steps needed to to run a timer. Okay. So these are the most important steps that you guys need to remember and even though different microller platforms may require different kind of stealth programming but for all these Arduino or AVR controllers let's just follow this pattern. This is very important. So when you guys are doing this I mean every different companies they have a different uh patterns or convention of programming but writing writing timers configuring all the bits let's just follow whatever the specific montour I usually use right as a convention so for Arduino for AVR montours the way we set up uh or configure bits is using a

0:50 number one so it's actually eight bit one it's all seven zeros with one at LSB and then we shift that one to the left for a certain number of steps in order to set or reset a certain bit and doing an end or or logic to achieve it. So that is why it looks so weird for this uh for this code for this piece of code here right this line it's actually just doing it's actually just doing u uh writing a one right writing a one to CS10 bit to that bit but it's doing it's making things looks very complicated maybe unnecessary but it's just a convention if you're looking at all the standard standard examples from AVR

1:37 mours they all use this pattern. Okay. So what's happening is they do uh one and shift left shift for this uh bit the name of the bit in the register. What is CS10 mean? What's that? What is that bit over there? Remember >> of the Chris Gator, right? The C or the the register. So that bit is one of the

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.