diff --git a/firmware/Makefile b/firmware/Makefile index be5b4b0..f0bdf36 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -4,8 +4,8 @@ #curl http://seb.exse.net/ledtest.hex > ledtest.hex && avrflash.sh m168 -F -v -v -U flash:w:ledtest.hex -MCU = atmega88 -#MCU = atmega168p +#MCU = atmega88 +MCU = atmega328p #MCU = atmega644 F_CPU = 8000000 diff --git a/firmware/main.c b/firmware/main.c index 2e7d684..b2b0c68 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -11,6 +11,7 @@ volatile uint8_t sample_pending; // sample rate is 8M / (5 * 64) = 25000 + enum { synth_channel_count = 2 }; @@ -28,6 +29,11 @@ typedef struct { static synth_t synth; +uint8_t counter = 0; +uint8_t pulsewidth = 0; +uint8_t maxcounter = 0xFF; +uint16_t pulsecounter = 0; + static void synth_init(void) { // some test values @@ -58,9 +64,10 @@ static void init_sampletimer(void) TCCR0A = (1 << WGM01); TCCR0B = (1 << CS00) | (1 << CS01); //count up to 5 : - OCR0A = 5; + OCR0A = 3; + TCNT0=0; //enable interrupt - TIMSK0 |= (1 << TOIE0); + TIMSK0 |= (1< maxcounter){ + counter = 0; + }; + + + pulsecounter++; + if (pulsecounter > 0x0200){ + pulsecounter = 0; + pulsewidth++; + if (pulsewidth > maxcounter){ + pulsewidth = 0; + } + } + + + + OCR1B = ((counter > pulsewidth) ? maxcounter : 0x00); + + + //OCR1B = counter; + //OCR1B = OCR1B + 4; + if (OCR1B > 0x007F) { + // OCR1B = 0x00F; + } + PORTC ^= 0b01; + + //ICR1 = synth.output; + //sample_pending = 1; + } + +