How do hardware timers work?

preview_player
Показать описание
In this video, learn how a CPU uses hardware timers to control execution timing.

------------------

Social media:

Special thanks to these supporters for making this video possible:
Aleksey Smolenchuk, Anders Carlsson, Andrew C. Young, Anson VanDoren, Anthanasius, anula, Armin Brauns, Ben, Ben Cochran, Ben Kamens, Ben Williams, Benny Olsson, Bill Cooksey, Binh Tran, Bouke Groenescheij, Bradley Pirtle, Bradley Stach, Bryan Brickman, Burt Humburg, Carlos Ambrozak, Chris, Christian Carter, Christopher Blackmon, Dale Andrew Darling, Daniel Jeppsson, Daniel Tang, Dave Burley, Dave Walter, David Clark, David Cox, David Dawkins, David House, David Sastre Medina, David Turner, David Worsham, Dean Bevan, Dean Winger, Dilip Gowda, Dissy, dko, Dmitry Guyvoronsky, Dušan Dželebdžić, Dzevad Trumic, Emilio Mendoza, Eric Dynowski, Erik Broeders, Eugene Bulkin, Evan Thayer, Eveli László, fisksvett, fxshlein, George Miroshnykov, Harry McDow, hotwire33, Ingo Eble, Ivan Sorokin, James Capuder, james schaefer, Jared Dziedzic, Jason DeStefano, JavaXP, Jaxon Ketterman, Jay Binks, Jayne Gabriele, Jeremy, Jeremy Cole, Jesse Miller, Jim Kelly, Jim Knowler, Jim Van Meggelen, Joe Beda, Joe OConnor, Joe Pregracke, Joel Miller, John Fenwick, John Hamberger jn., John Meade, Jon Dugan, Jonn Miller, Joseph Portaro, Joshua King, Jurģis Brigmanis, Kai Wells, Kefen, Kenneth Christensen, Kitick, Koreo, Lambda GPU Workstations, Larry, László Bácsi, Lucky Resistor, Lukasz Pacholik, Marcos Fujisawa, Marcus Classon, Mark Day, Marko Clemente, Martin Noble, Martin Roth, Mats Fredriksson, Matt Krueger, Matthäus Pawelczyk, Matthew Duphily, Max Gawletta, Maxim Hansen, melvin2001, Michael Tedder, Michael Timbrook, Michael Weitman, Miguel Ríos, mikebad, Mikel Lindsaar, Miles Macchiaroli, Muqeet Mujahid, My Yiddishe Mama, Nicholas Counts, Nicholas Moresco, Nick Chapman, Not Yet Wise, Örn Arnarson, Paul Pluzhnikov, Paul Randal, Pete Dietl, Phil Dennis, Philip Hofstetter, Phillip Glau, PixelSergey, Porus, ProgrammerDor, Randal Masutani, Randy True, raoulvp, Renaldas Zioma, Ric King, Richard Butler-Malone, Richard Ertel, Rick Hennigan, Robert Comyn, Robert Diaz, Robey Pointer, §çīŤøşHï ŇåĶąýŐbŕÔ, Scott Holmes, Sean Patrick O’Brien, Sergey Kruk, SonOfSofaman, Stefan Nesinger, Stefanus Du Toit, Stephen, Stephen Kovalcik, Stephen Riley, Stephen Smithstone, Steve Jones, Tayler Porter, TheWebMachine, Thomas Bruggink, Thomas Eriksen, Thomas Rolfs, Tim Walkowski, Tom, Tom Yedwab, Tommaso Palmieri, Tyler Latham, Vincent Bernat, Walter Montalvo, Warren Miller, William, Wim Coekaerts, Wraithan McCarroll, xisente, Yee Lam Wan
Рекомендации по теме
Комментарии
Автор

Given the lack of activity from Ben there are two explanations:
1. Off camera events have taken priority.
2. Ben set a sleep timer on himself and misplaced the decimal.
Either way it may be a while before an update.

hashtagPoundsign
Автор

This is why breadboard computers should be more common in colleges. The simple questions are overlooked with the abstraction we have added.

XenoTravis
Автор

I love everything about this series. I'm eagerly awaiting the point where Ben eventually builds a C compiler for the breadboard 6502.

RandallStephens
Автор

I was literally just learning about AVR Timers. This video is perfect timing.

inventr
Автор

If Armageddon happens, we will only need Ben to bring us back to the future.

GuildOfCalamity
Автор

As a software engineer I really appreciate these videos. It makes things make so much more sense.

dngd
Автор

Sometimes, when I don't have an o-scope at hand, and I'm testing stuff like this, I like to use a speaker (with a resistor in line). After a while you can make pretty good guesses on order of magnitude of frequencies. In this case, it would sound a B on the far right end of a piano.

JiffyJames
Автор

When he said you can write a 'delay' subroutine with a bunch of nop's in it, I was like, "Please tell me that isn't how hardware timers work."

Jarikraider
Автор

Busy-Loop Delay 0:41
One-Shot Timer Mode 7:31
Free-Run Timer Mode 14:57

deltakid
Автор

These vids are just amazing. Youtube doesnt have enough high quality highly technical videos that are relatively easy to understand for the average joe

joiscode
Автор

The first method, depending on the processor speed, reminds me a lot of those games in the 80s that became impossible to play when you upgraded your computer to the latest 386 dx-33.

TheKhalamar
Автор

Man if only every teacher in the world had this amazing ability to teach and keep you interested.

xalpha
Автор

After watching a trillion youtube videos on various subjects, I believe this is my first post. I felt it necessary to let you know that you inspire me. Thank you for the information you give, and the way that you present it. I find it very easy to digest and grow my confidence and intuition, and let me know that things I once thought too hard or impossible, are actually quite achievable!!

tobygrover
Автор

Just woke up on a Sunday morning, made a coffee, turned on my computer and I saw a new video from Ben... awesome!

garydunken
Автор

I would literally kill to have had this Ben as a professor! It's a crying shame academia is full of people who can't teach worth a damn.

bobweiram
Автор

Note: in both the software timer at the beginning and the hardware timer (probably, depending on the datasheet, but most hardware timers are like this), you can set the counter value to 0 to loop 256 (software) or 65536 (hardware) times. This means you get one more counting value to use! This works because the loop checks for 0 _after_ decrementing, at which point it will already have overflowed.

fghsgh
Автор

How does this guy know all these stuff? I mean, I studied electrical engineering and this is beyond what they teach you in just few years. He's software- as well as hardware-competent. My biggest idol, wish I can be this good one day in this field as you are

danny_racho
Автор

As a computer engineer, I love your videos. You've managed to condense a couple semesters into something I can watch in a day or two.

bobthecomputerguy
Автор

Ben, I was waiting for the next logical step on this, and then you didn't! Investigating, I realized with some shock that the 6502 doesn't have an instruction I expected. I cut my teeth not on the 6502, but the 6809, which had the SYNC instruction. SYNC on the 6809 would put the CPU into a low power sleep state to synchronize with an external interrupt. It first pushes a limited state to stack (as if an interrupt was happening), then waits for an interrupt to come in. Once the interrupt came in, it would service that interrupt, then resume (via RTI) at the instruction after the SYNC. Such and instruction would be ideal to put in the head of the loop here. It would mean you're only running the subroutines once per 10ms, and are doing so just as the interrupt returns, limiting collision. That would also mean the CPU is using less power (and making less heat) while running this task.

The 6809 system I used often (the TRS80-CoCo) would use this trick to presync with hardware for everything from loading data from tape, to doing frame rendering for video output. Lots of neat tricks one can do when one can synchronize with a hardware event.

TvistoProPro
Автор

everyone who writes any type of code really owes Dennis Ritchie a lot of gratitude. This syntax and how loops are written with it really makes one appreciate the for() and while() loops that came with the C language.

MatkatMusic