Hello, community!
I have a problem with SAI EDMA driver for FRDM-K64f (and for FRDM-K82). I used an example of SAI EDMA driver from SDK2.0 pack for TWR-K64. it work fine, but only once!
I used a example code from "sai_edma_transfer_twrk64f120m" for two parts - "sai_init" and "sai_play". and try to call "sai_play" repeatedly.
at First time a data transfer takes place without problems, but at second time data is not sent because it is not processed callback function.
I am a bit do not understand how to use the new KSDK 2 drivers as they differ significantly from previous versions.
May be community help me with realisation of repeatedly call SAI_TransferSendEDMA() function???
I attached a project, and wait for help!!!
Regards, Oleg
Original Attachment has been moved to: sai2.zip
Hello All,
A fix was provided for this issue, it is only needed to disable Tx and Rx on SAI_TransferAbortSendEDMA and SAI_TransferAbortReceiveEDMA respectively:
void SAI_TransferAbortSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
{
assert(handle);
/* Disable dma */
EDMA_AbortTransfer(handle->dmaHandle);
/* Disable DMA enable bit */
SAI_TxEnableDMA(base, kSAI_FIFORequestDMAEnable, false);
#if APPLY_FIX
/* Disable Tx */
SAI_TxEnable(base, false);
#endif
/* Set the handle state */
handle->state = kSAI_Idle;
}
void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle)
{
assert(handle);
/* Disable dma */
EDMA_AbortTransfer(handle->dmaHandle);
/* Disable DMA enable bit */
SAI_RxEnableDMA(base, kSAI_FIFORequestDMAEnable, false);
#if APPLY_FIX
/* Disable Rx */
SAI_RxEnable(base, false);
#endif
/* Set the handle state */
handle->state = kSAI_Idle;
}
If you disable Tx and Rx and leave the driver as it was (without clearing FEF flag) it should be working properly.
Regards,
Isaac
I've checked it. It works, but it hangs after few playing attempts.
Manfred Schnell solution works 100/100.
Hi Isaac,
thanks for this fix.
I applied it to my sources. --> it works as expected.
EDIT 2016-07-14/MS:
In some cases (when playing sound is cancelled) there is a fifo error. --> next start fails
--> I use my workaround again.
In Function SAI_TxEnable() I changed line
base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK);
to
base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK | I2S_TCSR_FEF_MASK);
EDIT end:
Best regards
Manfred
Hello Reed,
I want to configure the SAI in Slave mode and SGTL5000 in master mode. I have made SAI configuration as below for Slave mode but not able to make the SGTL5000 configuration in master mode.
SAI config for Slave mode :
static sai_user_config_t i2s_Config =
{
.protocol = kSaiBusI2SType,
.channel = 0,
.slave_master = kSaiSlave,
.sync_mode = kSaiModeAsync,
.bclk_source = kSaiBclkSourceMclkDiv,
.mclk_source = kSaiMclkSourceSelect1,
.dma_source = kDmaRequestMux0I2S0Tx
};
Can you please help to me to configure the SGTL5000 in Master mode ?
Thanks,
Ajay-
Here is an example of working code that uses the KSDK 2.0 SAI eDMA driver:
bass.slab/audio_output.cpp at master · flit/bass.slab · GitHub
bass.slab/audio_output.h at master · flit/bass.slab · GitHub
It has been used on the K22F512 and K66F. I haven't made any changes to the SAI driver.
Hello, Christopher!
I look into Your example and have a question:
in file "audio_output.cpp" in line 59:
saiConfig.masterSlave = kSAI_Slave; // kSAI_Master; |
then You send out a data via SAI_TransferSendEDMA
are your MCU uses as SAI slave?
Because in my project I use MCU as SAI master.
regards, Oleg
Hi Oleg,
The master/slave setting in sai_config_t simply determines which side drives the bit and word clock signals. In master mode, the SAI module drives those signals, whereas in slave mode the audio codec drives them.
Regardless of master or slave mode, you still use SAI_TransferSendEDMA() to transmit data and SAI_TransferReceiveEDMA() to receive data.
I have also used this code in master mode (why kSAI_Master is commented out on that line). It just happens that the SGTL5000 codec driver configures the codec for slave mode (thus, SAI must be master), while the DA7212 driver configures the codec for master mode.
Hello Oleg,
I had the same Problem.
In the meantime I use the following workaround:
In Function SAI_TxEnable() I changed line
base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK);
to
base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | I2S_TCSR_TE_MASK | I2S_TCSR_FEF_MASK);
--> so the FIFO Error is cleared at every SAI_TxEnable().
Additionally I had to change the function EDMA_AbortTransfer()
last action in this function is:
handle->tcdUsed = 0;
This may be quick and dirty... but it works for me. I'm waiting for KSDK 2.x. ...
Best regards
Manfred
I was reported SAI under DMA problem here:
Many thanks Manfred Schnell !! It works for me.
Hello,
I've already reported this issue to SDK team, it seems to be a FIFO Error flag on SAI Transmitter that is causing the issue. I've already requested for help in order to understand the best way to implement multiple calls to SAI_TransferSendEDMA().
I will let you know as soon as any response is gotten.
Regards,
Isaac