trigger LED on timer
This commit is contained in:
12
src/timer.rs
Normal file
12
src/timer.rs
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user