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.

RTOS/CC3200MOD: TIDrivers CC3200 I2S, issue playing sound from FS

Part Number: CC3200MOD
Other Parts Discussed in Thread: TLV320AIC3254, CC3200, CC3200SDK, SYSBIOS

Tool/software: TI-RTOS

Hello,
 We are having issues with I2S on the CC3200. We are trying to play a sound file(16-bit, stereo, 16Khz sampling) from the SimpleLink file system. The file seems to read in fine from the filesystem, but no sound comes out of the TLV320AIC3254 DAC and we encounter a DMAERR interrupt after finishing. We have had it working prior when doing testing with out the TIDriver library. I know the DAC is setting up correctly as we are using the same register configuration and code from our original test bed(using I2C_Open, I2C_transfer, etc). I attached the code below

TIRTOS: 2.16.00.08
TIDrivers CC32xx: 2.16.00.08
CC3200SDK: 1.2.0
SysBios version: v6.45.01.29
CC3200 SDK version: 1.2.0
CC3200 Service Pack: 1.0.1.6-2.7.0.0
unsigned short fileBuffer[30*1024];
_u8            tBuffer[3072];

int playSound(char * fileName)
{
	int 			offset= 0;
    long            DeviceFileHandle;
    long            lRetVal = -1;        //negative retval is an error
    SlFsFileInfo_t  pFsFileInfo;
	I2S_BufDesc     bufDesc[3];
	I2S_BufDesc    *pDesc = NULL;
    char fil[] =    "ding.wav";

	Semaphore_pend(slSemaphore, BIOS_WAIT_FOREVER); // Wait for NWP to access FS
	Semaphore_pend(semWaterMarkHandle, BIOS_WAIT_FOREVER); // Wait until I2S handle is opened

	System_printf("SOUND: Playing sound\n");

	// Open File
	lRetVal = sl_FsOpen((unsigned char *)&fil, FS_MODE_OPEN_READ, NULL, &DeviceFileHandle);
	if(lRetVal < 0)
	{
		CloseSoundFile(DeviceFileHandle);
		//System_printf("SOUND: Failed to read file %s\n", fileName);
		return -1;
	}
	// Read from file and discard wav header
	// get info on the file
	lRetVal = sl_FsGetInfo((unsigned char *)&fil, NULL, &pFsFileInfo);
	if(lRetVal < 0)
	{
		CloseSoundFile(DeviceFileHandle);
		//System_printf("SOUND: Failed to read file %s\n", fileName);
		return -1;
	}
	// Read from file
	lRetVal = sl_FsRead(DeviceFileHandle, 0, tBuffer, 4);
	if(lRetVal < 0)
	{
		CloseSoundFile(DeviceFileHandle);
		//System_printf("SOUND: Failed to read file %s\n", fileName);
		return -1;
	}
	// discard wav header
	// read header
	// check if file is a wav file
	if ( ( tBuffer[0] != 'R'
		  || tBuffer[1] != 'I'
		  || tBuffer[2] != 'F'
		  || tBuffer[3] != 'F' ))
	{
		System_printf("ERROR: Not wav format\n");
		CloseSoundFile(DeviceFileHandle);
		System_printf("SOUND: Failed to read file %s\n", fileName);
		return -1;
	}
	System_printf("SOUND: Sound is RIFF Wave\n");

	offset += sizeof(waveHeaderType);

	_u8 *ptr = fileBuffer;

	bufDesc[0].bufPtr = ptr;
	bufDesc[0].bufSize = 3072;

	ptr += 1536;
	bufDesc[1].bufPtr = ptr;
	bufDesc[1].bufSize = 3072;

	ptr += 1536;
	bufDesc[2].bufPtr = ptr;
	bufDesc[2].bufSize = 3072;

	ptr = fileBuffer;
	System_printf("ptr: %x\n", ptr);

	sl_FsRead(DeviceFileHandle, offset, tBuffer, 3072);
	memcpy(bufDesc[0].bufPtr, tBuffer, 3072);
	sl_FsRead(DeviceFileHandle, offset, tBuffer, 3072);
	memcpy(bufDesc[1].bufPtr, tBuffer, 3072);
	sl_FsRead(DeviceFileHandle, offset, tBuffer, 3072);
	memcpy(bufDesc[2].bufPtr, tBuffer, 3072);

    I2S_writeIssue(i2sHandle, &bufDesc[0]);
	I2S_writeIssue(i2sHandle, &bufDesc[1]);
	I2S_writeIssue(i2sHandle, &bufDesc[2]);

	int doneReading = 0;
	int i = 2;
	while (!doneReading) {
		i++;
		ptr += 1536;
		if(i==10) {
			ptr = fileBuffer;
			i = 0;
		}
		I2S_writeReclaim(i2sHandle, &pDesc);
		if (pDesc ==  NULL)
			while (1);
		lRetVal = sl_FsRead(DeviceFileHandle, offset, tBuffer, 3072);
		if (lRetVal < 0)
		{
			CloseSoundFile(DeviceFileHandle);
			System_printf("SOUND: Failed to read file %s\n", fileName);
		}
		else if (lRetVal < 3072)
		{
			doneReading = 1;
		}
		//System_printf("ptr: %x\n", ptr);
		memcpy(ptr, tBuffer, lRetVal);

		pDesc->bufPtr = ptr;
		pDesc->bufSize = lRetVal<3072?lRetVal: 3072;
		I2S_writeIssue(i2sHandle, pDesc);
		offset+=lRetVal;
	}

	System_printf("SOUND: Done playing sound.\n");
	CloseSoundFile(DeviceFileHandle);

	return 0;
}

  • Greg,

    Can you please clarify…  Are you able to play sound using the I2S driver when you don’t use the SimpleLink file system to get the buffers?  Is it only when you try to use the two together that there is no sound?

    Also, can you please post the code that initializes I2S parameters and calls I2S_open()?

    Thanks,
    Scott

  • Hi Scott,

    I do not get sound either way. I just tested with a 16-bit, 16000Hz sampling rate, stereo sine wave converted to a static c-array. I then memcpy this array into the big buffer referencing it like before using the code above. I do not get sound out of the codec. I have attached the setup function. I have also tested this with the operationMode set to I2S_OPMODE_TX_ONLY.

    I do know the codec is being setup on I2C as we can communicate with other devices on the bus, and registers read back correctly.

    void setupSound()
    {
        Error_Block eb;
        Error_init(&eb);
    
        Semaphore_Params_init(&semWaterMark);
        semWaterMark.mode = Semaphore_Mode_BINARY;
        semWaterMarkHandle = Semaphore_create(0, &semWaterMark, &eb);
    
        // Initialize the coded
        I2SSound_init(); // Setup the codec
    
        // Setup I2S params
        I2S_Params_init(&i2sParams);
        I2SCC3200DMA_Params_init(&I2SCC3200DMA_serialParams);
        i2sParams.customParams = (uintptr_t) &I2SCC3200DMA_serialParams;
        i2sParams.operationMode = I2S_OPMODE_TX_RX_SYNC;
        i2sHandle = I2S_open(Board_I2S0, &i2sParams);
        if(i2sHandle < 0)
        {
        	System_printf("SOUND: Could not open I2S\n");
        }
    }
  • Hi Greg,

    OK, thanks.

    Are you using a TI Launchpad, or is this on a custom board?  There is an “I2S Echo” example in the TI-RTOS 2.16.00.08 release, I wonder if you’ve tried that?  This example requires a booster pack to be mounted on the Launchpad.  If you have a different setup it might still be useful to look at this example for reference.

    I talked to another engineer about what you are reporting and he said to be sure that the RX and TX buffers are 32-bit (4 byte) aligned.  If they aren’t this might explain the DMA error you see.  In your code snippet fileBuffer is of type “unsigned short”.  I think if you use “unsigned” instead that will do it.

    Hope this helps...

    Regards,
    Scott