Skip to content

Commit 0fcb0ed

Browse files
author
Sean Lyons
committed
Fix undercopy bug in i2secho
Added comments to explain the h/w setup
1 parent 2aac712 commit 0fcb0ed

File tree

1 file changed

+16
-3
lines changed
  • examples/rtos/CC26X2R1_LAUNCHXL/drivers/i2secho

1 file changed

+16
-3
lines changed

examples/rtos/CC26X2R1_LAUNCHXL/drivers/i2secho/i2secho.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,23 @@
5252
#define SAMPLE_RATE 16000 // Warning: Only 16kHz supported
5353
#define INPUT_OPTION AUDIO_CODEC_MIC_LINE_IN
5454
#define OUTPUT_OPTION AUDIO_CODEC_SPEAKER_HP
55+
56+
/*
57+
* The I2S driver is setup to sample both right and left channel from the codec
58+
* however the DMA is only configured to save the samples from the left channel.
59+
* On playback the samples from the left channel will be mirrored to the left
60+
* and right channels.
61+
*
62+
* In summary the sampling is stereo, but the processing and playback is mono.
63+
*/
5564
#define NUM_CHAN 2
5665

57-
/* Configure for a 20ms frame (20ms/16kHz) */
58-
#define FRAME_SIZE 320
66+
/*
67+
* Configure for a 10ms frame @ 16kHz sample rate.
68+
* Note that the frame size variable is limited to a max size of 255.
69+
* It is an 8bit field in hardware (AIFDMACFG).
70+
*/
71+
#define FRAME_SIZE 160
5972

6073
#define I2S_TOTAL_QUEUE_MEM_SZ (I2S_BLOCK_OVERHEAD_IN_BYTES * \
6174
I2SCC26XX_QUEUE_SIZE * \
@@ -228,7 +241,7 @@ void *mainThread(void *arg0)
228241

229242
/* Copy the frame directly to the output buffer */
230243
memcpy(bufferRequest.bufferOut, bufferRequest.bufferIn,
231-
FRAME_SIZE);
244+
FRAME_SIZE*sizeof(uint16_t));
232245
}
233246

234247
/* Release the buffer back to the I2S driver */

0 commit comments

Comments
 (0)