Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to...
[pub/lufa.git] / Demos / Device / AudioOutput / AudioOutput.c
index 855edf6..0554361 100644 (file)
@@ -90,7 +90,7 @@ EVENT_HANDLER(USB_Connect)
        UpdateStatus(Status_USBEnumerating);\r
        \r
        /* Sample reload timer initialization */\r
-       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY);\r
+       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);\r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
                        \r