From 8205c7892a291c5bffa7b32fcb434d74c568454c Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Fri, 9 Jan 2026 11:40:14 +0100 Subject: [PATCH] Update timer0 logic for tap tempo with overflow counter. Update timer1 setup --- src/timer.inc | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/timer.inc b/src/timer.inc index db45f4f..0f65ac3 100644 --- a/src/timer.inc +++ b/src/timer.inc @@ -2,16 +2,52 @@ ; r16: timer0 setup (can reuse after ret) ; r17: timer1 dynamic setup (always needed) -; Timer0 (static, low precision) timer0_set: - ldi r16, (1 << WGM01) ; Write CTC (Clear Timer on Compare) to 1 - out TCCR0A, r16 ; On T/C Control Register A enable CTC waveform + out TCCR0A, r0 ; T/C Control Register A enable normal mode - ldi r16, 244 ; Load counter target limit value (ticks) - out OCR0A, r16 ; Load target for compatison with TCNT0 + ldi r16, (1 << TOIE0) + out TIMSK, r16 ; Enable Timer0 overflow - ldi r16, (1 << OCIE0A) ; Write Compare Match A Interrupt Enable to 1 - out TIMSK, r16 ; Allow Timer0 to interrupt + ret + +timer0_start: + ldi r16, (1<