Other Parts Discussed in Thread: CC3200
Tool/software: Code Composer Studio
Update: I am now getting audio to play through my device after working with the code, however I cannot change the sample rate from 16000 while configuring the speakercodec and still get audio to play.
I have been attempting to play a .wav file from an SD card with the CC3200AudioBooster Pack addon but it does not output any sound. I have based my Speaker.c code off of code found in this post
and the Wifi-Audio example in the cc3200 sdk.When I debug this code the pRxBuffer fills and is forever stuck in the while loop waiting for it to empty. I can post the code from my main.c if that would help.
//*****************************************************************************
// GLOBAL VARIABLES -- Start
//*****************************************************************************
extern tUDPSocket g_UdpSock;
int g_iReceiveCount =0;
int g_iRetVal =0;
int iCount =0;
#define USERFILE "trance.wav"
#define BUFFSIZE 100
unsigned char pBuffer[BUFFSIZE];
FIL fp;
FATFS fs;
FRESULT res;
DIR dir;
UINT Size;
extern unsigned long g_ulStatus;
extern unsigned char g_ucSpkrStartFlag;
extern unsigned char g_uiPlayWaterMark;
extern unsigned char g_loopback;
extern tCircularBuffer *pRxBuffer;
//*****************************************************************************
// GLOBAL VARIABLES -- End
//*****************************************************************************
static void
ListDirectory()
{
FILINFO fno;
FRESULT res;
unsigned long ulSize;
tBoolean bIsInKB;
for(;;)
{
res = f_readdir(&dir, &fno); // Read a directory item
if (res != FR_OK || fno.fname[0] == 0)
{
break; // Break on error or end of dir
}
ulSize = fno.fsize;
bIsInKB = false;
if(ulSize > 1024)
{
ulSize = ulSize/1024;
bIsInKB = true;
}
Report("->%-15s%5d %-2s %-5s\n\r",fno.fname,ulSize,\
(bIsInKB == true)?"KB":"B",(fno.fattrib&AM_DIR)?"Dir":"File");
}
}
void openFile(){
Message("\n\rReading user file...\n\r");
res = f_open(&fp,USERFILE,FA_READ);
f_lseek(&fp,44);
}
void readFile(){
if(res == FR_OK)
{
f_read(&fp,pBuffer,BUFFSIZE,&Size);
Report("Read : %d Bytes\n\n\r",Size);
Report("%s",pBuffer);
}
else
{
Report("Failed to open %s\n\r",USERFILE);
}
}
void closeFile(){
f_close(&fp);
}
//*****************************************************************************
//
//! Speaker Routine
//!
//! \param pvParameters Parameters to the task's entry function
//!
//! \return None
//
//*****************************************************************************
void Speaker( void *pvParameters )
{
long iRetVal;
f_mount(&fs,"0",1);
res = f_opendir(&dir,"/");
ListDirectory();
//open file
openFile();
g_ucSpkrStartFlag = 1;
while(1)
{
while(g_ucSpkrStartFlag)
{
// Read from file and discard wav header
readFile();
/* Wait to avoid buffer overflow as reading speed is faster than playback */
while((IsBufferSizeFilled(pRxBuffer,PLAY_WATERMARK) == TRUE)){};
if( Size > 0)
{
iRetVal = FillBuffer(pRxBuffer,(unsigned char*)pBuffer, Size);
if(iRetVal < 0)
{
UART_PRINT("Unable to fill buffer");
LOOP_FOREVER();
}
}
else
{ // we reach at the of file
//close file
closeFile();
// reopen the file
openFile();
}
if(g_uiPlayWaterMark == 0)
{
if(IsBufferSizeFilled(pRxBuffer,PLAY_WATERMARK) == TRUE)
{
g_uiPlayWaterMark = 1;
}
}
g_iReceiveCount++;
}
MAP_UtilsDelay(1000);
}
}