Hello community,
I was wondering whether anyone had come across a similar situation. I am examining the edma_record_playback driver example in SDK 2.7, on a FRDMK66F board. With it's default settings (16kHz, 16-bit) it seems to work fine, however if you extend the word width to 24-bit (modifying #define DEMO_AUDIO_BIT_WIDTH kSAI_WordWidth24bits and setting the DA7212 config to a bitWidth of 24), the application plays static.
Modifying the sample word width to 32-bits or 8 bits the application works OK. It appears to be an issue with only the 24-bit sample size.
I have debugged sufficiently to eliminate the problem being with the configuration of the audio codec (although there are a number of minor problems with the 7212 driver and the device configuration, none of them would result in this specific issue). I have been examining the SAI APIs and I suspect the SAI clock configuration, however I can't say definitively.
Interestingly, I have got the SAI interface to work correctly in 24-bit sample size using the legacy style APIs. I am including the code below for reference (note, I have commented out the provided SAI code).
Has anyone come across a similar issue?
Thanks,
/Scott
// ----- Working SAI init code for 24-bit sample size, note only tested with 48KHz sample rate) ----
/* SAI init */
/*
SAI_Init(DEMO_SAI);
*/
memset(&sai_format, 0U, sizeof(sai_transfer_format_t));
SAI_TxGetDefaultConfig(&sai_config);
sai_config.masterSlave = kSAI_Master;
SAI_TxInit(DEMO_SAI, &sai_config);
SAI_RxGetDefaultConfig(&sai_config);
SAI_RxInit(DEMO_SAI, &sai_config);
sai_format.bitWidth = DEMO_AUDIO_BIT_WIDTH;
sai_format.channel = 0U;
sai_format.sampleRate_Hz = DEMO_AUDIO_SAMPLE_RATE;
sai_format.masterClockHz = OVER_SAMPLE_RATE * sai_format.sampleRate_Hz;
sai_format.protocol = sai_config.protocol;
sai_format.stereo = kSAI_Stereo;
sai_format.watermark = FSL_FEATURE_SAI_FIFO_COUNT / 2U;
SAI_TransferTxCreateHandleEDMA(DEMO_SAI, &txHandle, tx_callback, NULL, &dmaTxHandle);
SAI_TransferRxCreateHandleEDMA(DEMO_SAI, &rxHandle, rx_callback, NULL, &dmaRxHandle);
/*
// I2S mode configurations
SAI_GetClassicI2SConfig(&config, DEMO_AUDIO_BIT_WIDTH, kSAI_Stereo, kSAI_Channel0Mask);
config.syncMode = DEMO_SAI_TX_SYNC_MODE;
SAI_TransferTxSetConfigEDMA(DEMO_SAI, &txHandle, &config);
config.syncMode = DEMO_SAI_RX_SYNC_MODE;
SAI_TransferRxSetConfigEDMA(DEMO_SAI, &rxHandle, &config);
// set bit clock divider
SAI_TxSetBitClockRate(DEMO_SAI, DEMO_AUDIO_MASTER_CLOCK, DEMO_AUDIO_SAMPLE_RATE, DEMO_AUDIO_BIT_WIDTH,
DEMO_AUDIO_DATA_CHANNEL);
SAI_RxSetBitClockRate(DEMO_SAI, DEMO_AUDIO_MASTER_CLOCK, DEMO_AUDIO_SAMPLE_RATE, DEMO_AUDIO_BIT_WIDTH,
DEMO_AUDIO_DATA_CHANNEL);
// master clock configurations
#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
(defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
#if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
mclkConfig.mclkHz = DEMO_AUDIO_MASTER_CLOCK;
mclkConfig.mclkSourceClkHz = DEMO_SAI_CLK_FREQ;
#endif
SAI_SetMasterClockConfig(DEMO_SAI, &mclkConfig);
#endif
*/
SAI_TransferTxSetFormatEDMA(DEMO_SAI, &txHandle, &sai_format,
CLOCK_GetFreq(kCLOCK_CoreSysClk),
sai_format.masterClockHz);
SAI_TransferRxSetFormatEDMA(DEMO_SAI, &rxHandle, &sai_format,
CLOCK_GetFreq(kCLOCK_CoreSysClk),
sai_format.masterClockHz);