fsl_sai_edma.c does not work for multi-channel Rx mode. MIMXRT1060, i.MX RT

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

fsl_sai_edma.c does not work for multi-channel Rx mode. MIMXRT1060, i.MX RT

ソリューションへジャンプ
1,187件の閲覧回数
caleb
Contributor III

Hello,

    I reported this before here, but since it hasn't been fixed in the latest SDK, I wanted to report it again.

Chip:  i.MXRT with multi-channel SAI port
SDK version: SDK_2_12_1_EVK-MIMXRT1060.zip
fsl_sai_edma.h version: 2.5.0

The problems:

There are three separate problems:
1) the TCE field of TCR3 is currently being set to 1 << handle->channel, which only works for single channel operation.  it needs to be set to handle->channelMask
2) the RCE field of RCR3 must be set to handle->channelMask, same as #1
3) in the RxSetConfig, saiConfig->fifo.fifoCombine  *must* be set to 0b10 or 0b11, however, the enums for kSAI_FifoCombineModeEnabledOnRead is incorrect for the SAI4 RCR FCOMB, it is only correct for SAI1 TCR4 FCOMB.  So, you need to change the assert statement to be kSAI_FifoCombineModeEnabledOnWrite instead of kSAI_FifoCombineModeEnabledOnRead, for the RCR4 assert.

 

caleb_3-1668455688415.png

 

caleb_2-1668455635275.png

The mode we want  on TCR4 is mode 0b10, and the mode we want on RCR4 is mode 0b10.  So, we *always* want 0b10.

However, the enum is defined like this, which is correct ONLY for TCR4 mode.

typedef enum _sai_fifo_combine
{
    kSAI_FifoCombineDisabled = 0U, /*!< sai fifo combine mode disabled */
    kSAI_FifoCombineModeEnabledOnRead, /*!< sai fifo combine mode enabled on FIFO reads */
    kSAI_FifoCombineModeEnabledOnWrite, /*!< sai fifo combine mode enabled on FIFO write */
    kSAI_FifoCombineModeEnabledOnReadWrite, /*!< sai fifo combined mode enabled on FIFO read/writes */
} sai_fifo_combine_t;

 

So, we must change the fsl_sai_edma.c with the following change:

***************
*** 439,441 ****
          (saiConfig->channelNums <= 1U) ||
!         ((saiConfig->channelNums > 1U) && ((saiConfig->fifo.fifoCombine == kSAI_FifoCombineModeEnabledOnWrite) || (saiConfig->fifo.fifoCombine == kSAI_FifoCombineModeEnabledOnReadWrite))));
--- 439,441 ----
          (saiConfig->channelNums <= 1U) ||
!         ((saiConfig->channelNums > 1U) && ((saiConfig->fifo.fifoCombine == kSAI_FifoCombineModeEnabledOnRead) || (saiConfig->fifo.fifoCombine == kSAI_FifoCombineModeEnabledOnReadWrite))));

 

I have included a patch that fixes the issues.

0 件の賞賛
返信
1 解決策
1,166件の閲覧回数
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @caleb,

Thanks for reporting this bug.

This issue has already been reported to the SDK team, and they are currently working on it. It is possible that the next mayor SDK release will implement the fix, but we cannot say for sure.

 

Thank you for your patience,

Edwin.

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,141件の閲覧回数
scott_thompson
Contributor III

Many thanks for the tri-state find!  I've been working for days trying to figure out why I wasn't getting any Rx data properly when using the non-deprecated (config vs format) initialization code.  

0 件の賞賛
返信
1,167件の閲覧回数
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @caleb,

Thanks for reporting this bug.

This issue has already been reported to the SDK team, and they are currently working on it. It is possible that the next mayor SDK release will implement the fix, but we cannot say for sure.

 

Thank you for your patience,

Edwin.

0 件の賞賛
返信
1,186件の閲覧回数
caleb
Contributor III

As an aside for anybody else trying to get the SAI to work in multi-channel mode, it's also critical that you set the Tx pin mode to TriState with something like this, or the TX will take over and drive zeros on SAI1_RX_DATA[1..3]

 

 

 

// NOTE!  This is your configuration for the Tx
// side of the SAI to get the Rx side to work!

sai_transceiver_t config;
SAI_GetTDMConfig(
    &config,
    kSAI_FrameSyncLenOneBitClk, 
    kSAI_WordWidth32bits, 
    16, 
    kSAI_Channel0Mask | kSAI_Channel1Mask | kSAI_Channel2Mask);
config.serialData.dataMode = kSAI_DataPinStateTriState;
[...]
SAI_TransferTxSetConfigEDMA(sai, &sai_edma_handle, &config);
[...]