This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220S-LAUNCHXL: How to setup I2S driver for single channel (mono) audio playback

Part Number: CC3220S-LAUNCHXL

Hi!

I was able to setup the i2secho example to play a short audio sample from a buffer. The issue I'm having is that the sample data is for a single channel (mono) while the I2S driver is configured for 2 channels (stereo). I tried changing that configuration with the following addition:

i2sParams.numChannels          = 1;
i2sHandle = I2S_open(Board_I2S0, &i2sParams);

But there is no change in how the data comes out of the I2S bus. I'm expecting channel 1 to have data while channel 2 should be at 0, but instead the data stream is constant and the frame selection keeps toggling, meaning only every other sample is getting to each one of the channels. I'm using a constant 800Hz pulse so it's easy to follow the signal. Here is what I get with any of both settings:

Thanks in advance!

Dan

  • My buffer is currently a int16_t array, so an easy way to get the signal close to what I want is to make it a int32_t array and leave unused the MSB half. But this solution is wasteful as the buffer doubles in size with half of it being unused. See below the signal I get with this workaround:

    (Also channel 2 will toggle between 0 and -1, but that's negligible)

    Any better solution for this problem?

  • Hi Dan,

    As you have noticed, the setting i2sParams.numChannels only affects the bit clock of the I2S interface.

    Unfortunately, it seems like the way to implement your desired behavior only exists through low-level driverlib functions, which have the possibility of conflicting with the use of TI Drivers in your project.

    The driverlib calls of interest are I2STxActiveSlotSet() and I2SRxActiveSlotSet(). What they do is they set which TDM slots/frames are active for Tx and Rx respectively. The exact details can be found in sections 12.5.11 and 12.5.22 of the CC3220 TRM.

    Try putting in the following code right after your I2S_open() call and see if you get the correct 1-channel behavior:

        I2STxActiveSlotSet(I2S_BASE, I2S_ACT_SLOT_EVEN);
        I2SRxActiveSlotSet(I2S_BASE, I2S_ACT_SLOT_EVEN);

    Be sure to also include the following files:

    #include <ti/devices/cc32xx/driverlib/i2s.h>
    #include <ti/devices/cc32xx/inc/hw_mcasp.h>
    #include <ti/devices/cc32xx/inc/hw_memmap.h>

    Regards,

    Michael

  • Thanks Michael. I will give this a shot.
    Dan