; Registers TODO: use .def for these!!!! ; r16: ISR setup (vct) -> timer0_set (main) -> START_BLINK (loop) ; r17: timer1_set (main) -> timer1_cnt low byte (loop) ; r18: timer1_set (main) -> timer1_cnt high byte (loop) ; r19: ; r20: .org 0x0000 ; RESET Vector rjmp main .org 0x0002 ; INT0 button interrupt (tap tempo) ;rjump tap_tempo --> should have timer0_start --> if timer0_overflow_count=0 start timer (?) .org 0x0004 ; TIMER0 overflow rjmp timer0_isr .org 0x0006 ; TIMER1_COMPA rjmp timer1_isr .data .global timer0_overflow_count timer0_overflow_count: .byte 1 .text .global main #define __SFR_OFFSET 0 #include #include "timer.inc" #include "tap-tempo.inc" ;#include "midi.inc" main: ldi r16, lo8(RAMEND) out SPL, r0 ; Setup stack pointer LOW ldi r16, hi8(RAMEND) out SPH, r0 ; Setup stack pointer HIGH ; PB0 is also second button to use as start stop continue with int0 interrupt ; when playing one press is pause, another press is continue, a long press is always stop cbi DDRB, PB1 ; Set EC11 clockwise on PB5 as input cbi DDRB, PB5 ; Set EC11 counter-clockwise on PB3 as input cbi DDRB, PB2 ; Set EC11 button (555 square wave) on PB2 as input sbi PORTB, PB2 ; Enable pull-up on PB2 ;ldi r26, 60 ; Default BPM //TODO: save to eeprom not register, on runtime also ldi on r24 register ; Setup general registers ; 0 clr r0 sts timer0_overflow_count, r0 ; 1 ldi r16, 1 mov r1, r16 rcall timer0_set rcall timer1_set sei ; Enable global interrupt loop: ; led in parallel with midi_out_pin (on a 555 monostable) SET_BPM 0x51, 0x29 ; for ex: use two sram addresses for bpm->lookup table for division ; sleep when BPM is stabilized (whenever BPM calculation are not being done) and outside of midi send ; to do this explore MCUCR register, it can do a lot of stuff rjmp loop