trigger LED on timer

This commit is contained in:
2025-07-18 20:31:23 +01:00
parent 8c27acbf50
commit 7b524aaae2
2 changed files with 33 additions and 3 deletions

12
src/timer.rs Normal file
View File

@@ -0,0 +1,12 @@
use arduino_hal::pac::TC0;
pub fn segment_timer_init(tc0: TC0, counts: u8) {
// Use CTC mode: reset counter when matches compare value
tc0.tccr0a.write(|w| w.wgm0().ctc());
// Set the compare value
tc0.ocr0a.write(|w| w.bits(counts));
// Slow down the timer (CLK / prescale)
tc0.tccr0b.write(|w| w.cs0().prescale_1024());
// Raise interrupt on reset
tc0.timsk0.write(|w| w.ocie0a().set_bit());
}