aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-14 08:17:24 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-14 08:17:24 +0000
commitfea5d085122bb386f1ec293b2e51036e29c7dc30 (patch)
tree5fda3eb3f1e251cf8fb97e763241c2075137ac3e
parentaf02b5b0c953931ce8b8925439972b1b4bd1d77e (diff)
downloadlufa-fea5d085122bb386f1ec293b2e51036e29c7dc30.tar.gz
lufa-fea5d085122bb386f1ec293b2e51036e29c7dc30.tar.bz2
lufa-fea5d085122bb386f1ec293b2e51036e29c7dc30.zip
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).
-rw-r--r--Demos/Device/AudioInput/AudioInput.c2
-rw-r--r--Demos/Device/AudioOutput/AudioOutput.c2
-rw-r--r--LUFA/ChangeLog.txt2
3 files changed, 4 insertions, 2 deletions
diff --git a/Demos/Device/AudioInput/AudioInput.c b/Demos/Device/AudioInput/AudioInput.c
index f41306f3b..b0c029573 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);
+ OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);
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 855edf68c..0554361c6 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);
+ OCR0A = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);
TCCR0A = (1 << WGM01); // CTC mode
TCCR0B = (1 << CS00); // Fcpu speed
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt
index e2d699c3e..78f1ec747 100644
--- a/LUFA/ChangeLog.txt
+++ b/LUFA/ChangeLog.txt
@@ -29,6 +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)
*
* \section Sec_ChangeLog090401 Version 090401
*