christoffer

How to get SAI running with FRDM-KL28Z

Discussion created by christoffer on May 16, 2017
Latest reply on Jun 7, 2017 by Robin_Shen

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);

Outcomes