summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-10-31 00:49:34 -0700
committerKeith Packard <keithp@keithp.com>2010-10-31 00:49:34 -0700
commit6b17b75ed5dc4e4fcc7278c715479bb921b644d5 (patch)
treea548a6e1555f799db4353b602d7c0ca69915b054
parent3493b456399bcc0ea43d28fd4105928bd8793cff (diff)
teleterra: comment the audio output implementation a bit better
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/ao_audio.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ao_audio.c b/src/ao_audio.c
index 70157557..0d521973 100644
--- a/src/ao_audio.c
+++ b/src/ao_audio.c
@@ -586,7 +586,9 @@ ao_audio_send(__xdata uint8_t *samples, uint16_t nsamples) __reentrant
/*
* Turn on timer 4. Free running from 0 to 0xff, with P2_0
- * on interval controlled by data written to T4CC0
+ * 'on' interval controlled by the value in T4CC0. Run this
+ * timer as fast as possible, resulting in a frequency of
+ * 24e6/256 or 93750Hz.
*/
T4CCTL0 = TxCCTLy_CMP_SET_UP_CLEAR_DOWN | TxCCTLy_CMP_MODE_ENABLE;
T4CC0 = 0x7f;
@@ -595,7 +597,11 @@ ao_audio_send(__xdata uint8_t *samples, uint16_t nsamples) __reentrant
P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_PERIPHERAL;
/*
- * Turn on timer 3 to clock data to the PWM output
+ * Turn on timer 3 to clock data to the PWM output. This
+ * runs at 24e6/(17 * 128) or 11029Hz, almost exactly the
+ * desired 11025Hz. Each cycle of the counter, a DMA transfer
+ * reads a sample and writes to the T4CC0 register, which
+ * controls the pulse width of the final audio signal
*/
T3CCTL0 = TxCCTLy_CMP_SET_UP_CLEAR_DOWN|TxCCTLy_CMP_MODE_ENABLE;
T3CC0 = 17;
@@ -603,10 +609,11 @@ ao_audio_send(__xdata uint8_t *samples, uint16_t nsamples) __reentrant
while (nsamples) {
uint16_t this_samples;
+ /* Sigh. The DMA engine has only 13 bits of length */
if ((this_samples = nsamples) > 0x1fff)
this_samples = 0x1fff;
/*
- * Set up DMA from the samples to T4CC0, triggered by T3 CH0
+ * Set up DMA to write samples to T4CC0, triggered by T3 CH0
*/
ao_dma_set_transfer(ao_audio_dma,
samples,