Intro to Embedded Rust Part 10: Interrupts | DigiKey @digikey
Intro to Embedded Rust Part 10: Interrupts | DigiKey  @digikey
Uploaded March 2026 | Updated November 2026, 13 hours ago
In this tutorial, we demonstrate how to use hardware interrupts in embedded Rust on the Raspberry Pi 2.
The written guide for this episode can be found here: digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-10-interrupts
The GitHub repository containing the Docker image and example code for this series can be found here: github.com/ShawnHymel/introduction-to-embedded-rust
Interrupts are a fundamental mechanism in embedded systems that allow the processor to pause normal execution to handle time-critical events, then automatically resume where it left off. Without interrupts, programs must constantly poll peripherals to detect events, which is often a wasteful approach that keeps the processor busy and prevents power-saving sleep modes.
We demonstrate interrupt-driven programming by creating a blinking LED application where a timer alarm triggers interrupts every 500 milliseconds while the main program sleeps, showcasing how interrupts enable responsive, power-efficient embedded applications. You'll learn how to configure timer alarms, write interrupt service routines (ISRs), manage the Nested Vectored Interrupt Controller (NVIC), and safely share data between main code and interrupt handlers using Rust's type system.
We’ll show how interrupts work: when an event occurs, the processor saves its state, jumps to an interrupt service routine to handle the event quickly, then returns to normal execution. We demonstrate a critical challenge in concurrent programming in embedded systems: safely accessing shared data between interrupt handlers and main code. We introduce the Mutex‹RefCell‹Option‹T››› pattern, which combines critical sections (disabling interrupts temporarily), interior mutability (RefCell for runtime borrow checking), and optional values to safely share peripherals like timer alarms and GPIO pins between different execution contexts.
We show how to configure timer interrupts on the RP2350 using the rp235x-hal crate. You'll learn to create timer alarms with hal::Timer::new_timer0() and schedule them using the fugit crate's convenient duration types like MicrosDurationU32::millis(500). We demonstrate enabling interrupt sources, unmasking interrupts in the NVIC with NVIC::unmask(), and writing ISRs with the #[interrupt] attribute that automatically registers them in the interrupt vector table. The tutorial covers ISR best practices: clearing interrupt flags to acknowledge events, keeping handlers short and fast, rescheduling repeating events, and using wfi() (wait for interrupt) in the main loop for power efficiency. You'll see how proper interrupt-driven design allows the processor to sleep 99% of the time while still maintaining precise timing, dramatically reducing power consumption compared to polling approaches.
At the end of the episode, we issue you a challenge to implement an external interrupt (based on a button press) based on what you’ve learned in the video.

Related Link:
digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-10-interrupts

Links:
Getting Started with STM32 and Nucleo: youtube.com/watch?v=hyZS2p1tW-g&list=PLEBQazB0HUyRYuzfi4clXsKUSgorErmBv
Introduction to Real-Time Operating Systems (RTOS): youtube.com/watch?v=F321087yYy4&list=PLEBQazB0HUyQ4hAPU1cJED6t3DU0h34bz
Raspberry Pi Pico 2: digikey.com/en/products/detail/raspberry-pi/SC1631/24627142

Learn more:
Maker.io - digikey.com/en/maker
DigiKey’s Blog – TheCircuit digikey.com/en/blog
Connect with DigiKey on Facebook facebook.com/digikey.electronics
And follow us on X: https://x.com/digikey

Product:
digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
digikey.com/en/products/detail/raspberry-pi/SC1632/26241102
digikey.com/en/products/detail/raspberry-pi/SC1633/25862735
digikey.com/en/products/detail/raspberry-pi/SC1634/26241087
digikey.com/en/products/detail/sparkfun-electronics/13314/6797646
digikey.com/en/products/detail/lite-on-inc/LTL-4224/217584
digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT220R/1830334
digikey.com/en/products/detail/te-connectivity-alcoswitch-switches/1825910-6/1632536
digikey.com/en/products/detail/dfrobot/FIT0096/7597069
digikey.com/en/products/detail/adafruit-industries-llc/1957/6827090
digikey.com/en/products/detail/cvilux-usa/DH-20M50055/13175849

Chapters:
0:00 Intro
0:42 Protecting Global Variables with Mutexes and RefCells
8:33 Configure Timer Interrupt
14:43 Interrupt Service Routine
18:47 Build and Flash
20:19 Challenge: External Pin Change Interrupt
21:51 Conclusion
Intro to Embedded Rust Part 10: Interrupts | DigiKeyPiezo vs Speaker - #BeckyStern #short | DigiKeyIntelligence That Drives Efficiency - Sustainable Futures S2E1 | DigiKeyWhite LEDs Are Actually Blue  - Electronics with Becky Stern | ShortDesigning for Flex, Feel, and Feedback #lasercut #tip #opensource #makerupdateAutonomous Navigation - #thebytesizedengineer | DigiKeyThis Arduino Uno Q can automatically analyze my resistors - The Byte Sized Engineer | DigiKeyChop Chop [Maker Update] | Maker.ioHex On Your Door [Maker Update] | Maker.ioGetting more transparency from my electricity bill - #thebytesizedengineer | Short3D Printed Screw Hole Quick Fix #3dprinting #tip #hack #MakerUpdate3D Printing and intro to FreeCAD #ShawnHymel #electronics #engineering #maker
DigiKey |

Intro to Embedded Rust Part 10: Interrupts | DigiKey

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER