Rename and change file extension. Add callbacks to timer func

This commit is contained in:
2025-12-25 22:48:06 +01:00
parent 423ba3d9ff
commit 129fd24253
3 changed files with 51 additions and 6 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
MCU = attiny85
F_CPU = 1000000UL
TARGET = main
SRCS = main.S
TARGET = clockinator
SRCS = clockinator.S
CC = avr-gcc
OBJCOPY = avr-objcopy
PORT = /dev/tty.usbmodem101
+49
View File
@@ -0,0 +1,49 @@
#define __SFR_OFFSET 0
#include <avr/io.h>
.include "timer.inc"
;.include "bpm.inc"
;.include "midi.inc"
;.include "led.inc"
.global main
main:
;cbi DDRB, PB1 ; Set EC11 clockwise on PB5 as input
;cbi DDRB, PB2 ; Set EC11 counter-clockwise on PB3 as input
;cbi DDRB, PB5 ; Set EC11 button (555 square wave) on PB4 as input
ldi r26, 60 ; Default BPM //TODO: save to eeprom not register, on runtime also ldi on r24 register
rcall timer0_ld
rcall timer1_ld
; interrupts:
; button (tap tempo loop) tap_tempo:
; encoder (increase/decrease tempo by one) incr_temp: , decr_temp:
; timer 1
;
; otherwise start from default bpm 60 (r26)
; loop: calculate tempo (high priority!) and save, led blinking, segment led writing
loop:
ldi r24, 30 ; Load current BPM to register //NOTE: hardcoded temporary
; TODO: compare two registers (current bpm and previous bpm)
rcall tempo_calc ; CHANGE: if BPM changed then rcall BPM calculation function else skip because ticks tempo is the value already in [OCR1C]
; if this BPM != previous BPM then load this to another register (will be used as the 'previous register')
; final result stored in OCR1C as ticks
; TODO: look if there are alternatives to rcall
;rcall midi_send ; Send MIDI ping
rcall blink_led
in r16, TIFR0 ; Check timer0 status
sbrc r16, OCF0A ; Skip stop_blink if clear
rcall stop_blink
;rcall segment_led ; Output current BPM to 3-digit 7-segment LED [r24]
rjmp loop ; Loopback
-4
View File
@@ -1,4 +0,0 @@
#define __SFR_OFFSET 0
#include <avr/io.h>
.global main