Hi,
Is there any example on how to get SAI running with FRDM-KL28Z using SDK_2.2_FRDM-KL28Z?
I have tried with the below code to send some bytes but it hangs in the SAI_WriteBlocking. This due to register bit FWF (Enabled transmit FIFO is empty) will not be set after sending first word. Anyone knows why?
Best regards,
Christoffer
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define BUFFER_SIZE (64)
uint8_t srcBuff[BUFFER_SIZE];
sai_config_t user_config;
sai_transfer_format_t user_format;
user_config.protocol = kSAI_BusPCMA,
user_config.masterSlave = kSAI_Master;
user_config.mclkSource = kSAI_MclkSourceSysclk;
user_config.bclkSource = kSAI_BclkSourceMclkDiv;
user_config.syncMode = kSAI_ModeAsync;
SAI_TxInit(I2S0, &user_config);
user_format.bitWidth = 16;
user_format.channel = 0;
user_format.masterClockHz = 24000000;
user_format.protocol = kSAI_BusPCMA;
user_format.sampleRate_Hz = 8000;
user_format.stereo = kSAI_Stereo;
user_format.watermark = 4;
SAI_TransferTxSetFormat(I2S0,&user_handle,&user_format,25000000,24000000);
SAI_TxEnable(I2S0,true);
SAI_WriteBlocking(I2S0, 0, 16, srcBuff, BUFFER_SIZE);
Hi christoffer,
There are several SAI examples in SDK_2.2_TWR-KL28Z72M. Maybe you can refer these examples.
I try to test the SAI interrupt_transfer example in SDK_2.2_TWR-KL28Z72M with default sai_config.
Just modify the code shown below.
I can hear the tone from headphone which connect to J7-SGTL5000.
Have you try to use other user_config.protocol, for example:
user_config.protocol = kSAI_BusLeftJustified;
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------