diff --git a/Demos/Device/AudioInput/AudioInput.c b/Demos/Device/AudioInput/AudioInput.c index b0c029573ed678658cc29944da6fbd0cd07ae915..fca24c360e7ad7644ef3857d8a5b0d85322f26f0 100644 --- a/Demos/Device/AudioInput/AudioInput.c +++ b/Demos/Device/AudioInput/AudioInput.c @@ -95,7 +95,7 @@ EVENT_HANDLER(USB_Connect) UpdateStatus(Status_USBEnumerating); /* Sample reload timer initialization */ - OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0); + OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - 1; TCCR0A = (1 << WGM01); // CTC mode TCCR0B = (1 << CS00); // Fcpu speed } diff --git a/Demos/Device/AudioOutput/AudioOutput.c b/Demos/Device/AudioOutput/AudioOutput.c index 0554361c6785693adc2a961645e200c93d6358b5..ffeee418ee4fdf6bc92ecf03cfdc3c3fec2c47ec 100644 --- a/Demos/Device/AudioOutput/AudioOutput.c +++ b/Demos/Device/AudioOutput/AudioOutput.c @@ -90,7 +90,7 @@ EVENT_HANDLER(USB_Connect) UpdateStatus(Status_USBEnumerating); /* Sample reload timer initialization */ - OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0); + OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - 1; TCCR0A = (1 << WGM01); // CTC mode TCCR0B = (1 << CS00); // Fcpu speed diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index 80436f66a98f8f4de1516e7af157b65c0b5c06e2..e85b35cf65b27e7eabd94fc39fa745dd13f6eee3 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -29,8 +29,8 @@ * - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen) * - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan) * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint - * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to account for situations where the division results - * in a value with no remainder, requiring one to be subtracted from the result (thanks to Robin Theunis) + * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet, + * and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis) * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type * pipes can be used with the function * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes