diff --git a/firmware/main.c b/firmware/main.c index 2983152..74d57b2 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -5,7 +5,8 @@ #include #include "main.h" - +#include "synth.h" +#include "usart.h" uint16_t sw_v = 0; @@ -14,64 +15,110 @@ uint16_t darkval = 0; uint16_t last_darkval = 0; - - -void __attribute__((noreturn)) -main(void) +static void init_sampletimer(void) { + /* + * Timer 0 + */ - /* here the show begins:*/ - - DDRC = 0b00100011; - PORTC = 0b00000001; - PORTC = 0b00000000; - DDRD = 0x00; - PORTD = 0b00000011; //enable pullups - DDRB = 0xFF; - PORTB=0xFF; + /* set timer0 to CTC & prescaler 64 → 125kHz increment */ + TCCR0A = (1 << WGM01); + TCCR0B = (1 << CS00) | (1 << CS01); + + OCR0A = 6; /* TOP */ + TCNT0 = 0; + /*enable interrupt*/ + TIMSK0 |= (1<