Is the demo_apps/sai example (imxrt1060) two channels?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is the demo_apps/sai example (imxrt1060) two channels?

Jump to solution
2,037 Views
EdSutter
Senior Contributor II

I'm working with the demo_apps/sai example code.  Specifically the recordplayback.c loop.  This is a nice example to gain better familiarity with eDMA and SAI.  I have a mic/headset plugged into the MIMXRT1060EVK and when I run the application I can tap on the on-board mic and I hear that noise in both headset channels; however, I do not hear anything coming from the headset microphone.

Digging a bit more I found that the initialized wm8960Config structure did not have the leftInputSource member configured (hence it defaults to 0, which is kWM8960_InputClosed).  Based on the schematic it appears that it should be set to kWM8960_InputDifferentialMicInput3, but that didn't make any difference.  

My guess is that this is a correct change, and that something else up the chain (SAI or eDMA) is causing the left/right mapping to get confused (I'm suspicious of this because the on-board mic is heard in both channels).  I want both channels active in both directions so I can then get a better understanding of how SAI/eDMA and the Codec are working together.

Any ideas?

Labels (1)
Tags (1)
1 Solution
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

HiEd Sutter

  The official SDK already realize the loop back function:

  • Board-MIC to right-heaphone-speaker
  • HP-Mic to left-headphone-speaker

SDK_2.7.0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\sai\edma_record_playback

You can check the code readme:

Note: This demo uses both headphone mic and board main mic(P1) as input source. The headphone mic provides left
channel data, and main mic (P1) provides right channel data. If users found there is noise while do record operation,
most probably it is the headphone standard issue (OMTP and CTIA standard difference). You should use the OMTP
standard headphone. You can disable the left channel by using an headphone without microphone feature.

I also double check it with our expert, it's really support two channel loopback.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

15 Replies
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ed Sutter,

   I contact with the code author, he give me the updated code, you can check it on your side.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,773 Views
EdSutter
Senior Contributor II

Kerry,

This updated file just has the fix that I mentioned above.  So my above question remains open...

To get a better understanding of SAI/EDMA I want to use SAI1/EDMA to loop back both audio channels (left and right) on the WM8960.  Referring to the MIMXRT1060 schematic, pg 9, the two channels would be:

  • Board-MIC to right-heaphone-speaker
  • HP-Mic to left-headphone-speaker

Am I trying to do something that for some non-obvious reason can't be done?

Ed

0 Kudos
1,774 Views
kerryzhou
NXP TechSupport
NXP TechSupport

HiEd Sutter

  The official SDK already realize the loop back function:

  • Board-MIC to right-heaphone-speaker
  • HP-Mic to left-headphone-speaker

SDK_2.7.0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\sai\edma_record_playback

You can check the code readme:

Note: This demo uses both headphone mic and board main mic(P1) as input source. The headphone mic provides left
channel data, and main mic (P1) provides right channel data. If users found there is noise while do record operation,
most probably it is the headphone standard issue (OMTP and CTIA standard difference). You should use the OMTP
standard headphone. You can disable the left channel by using an headphone without microphone feature.

I also double check it with our expert, it's really support two channel loopback.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,773 Views
EdSutter
Senior Contributor II

Just wanted to confirm that with the proper headset (OMTP), the 2-channel loopback is clean in the headset...

Ed

0 Kudos
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ed Sutter

  Do you already get the headset OMTP?  Still have issues?

Nest Regards,

Kerry

0 Kudos
1,773 Views
EdSutter
Senior Contributor II

Hi Kerry,

The OMTP headset definitely improved things, but I did have to include the the configuration

of the left input source....

.leftInputSource  = kWM8960_InputDifferentialMicInput3,

as I mentioned above.  Also, while it appears that things are doing what they should at the SAI bit streams, I hear left and right audio in both ears...  In other words, as best I can tell the left signal goes to both ears and the right input goes to both ears.  For now I am just assuming that is some WM8960 issue (or possibly the headset).  The important thing from my point of view is that the SAI stream is as expected.

Thanks

0 Kudos
1,773 Views
EdSutter
Senior Contributor II

One minor point, which I won't be able to confirm until I get the CTIA-to-OMTP converter...

The code in the demo_apps/sai example does not have the .leftInputSource configured in the wm8960Config structure;

so that may still cause the codec to not properly hook up to the headphone mic.  I believe the correct initialization there should include: 

.leftInputSource  = kWM8960_InputDifferentialMicInput3,

Ed

1,773 Views
EdSutter
Senior Contributor II

Kerry,

Well, that was the issue... Quite honestly I never heard of OMTP vs CTIA regarding headsets.  It turns out I am using a CTIA-standard headset.  And while I don't fully understand why, when that was plugged into the board, it caused the output of the BOARD-Mic to be on both channels of the headset.  Yesterday I wired up a 4-channel scope to the SAI1 signals connected to the WM8960 and it showed me the same thing; so that mic/gnd reversal in the headset really confused the codec on the analog side. 

Anyway, I've already ordered a CTIA-to-OMTP converter cable, but meanwhile I was able to confirm that when I pull out the headphone plug the signals on the scope reflect the correct loopback.

Thanks for the code and your patience!  

Ed

0 Kudos
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  Ed Sutter 

   Attached is the SAI 4 channel RX DMA code, you can check it, whether it is useful to you or not.

   It is  modified based on the SDK SAI one channel project.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,773 Views
EdSutter
Senior Contributor II

Kerry, I was able to modify your code (thanks very much, this is much easier to follow without all the SDK overhead) to work in single-channel in/out mode with the WM8960 on the MIMXRT1060-EVK.  Next I'm hoping to work with your multi-channel code,  using the WM8960 as a 2-in/2-out codec.

I think I follow how it works, using linked DMA channels, with each of the RX channels pulling directly from the SAI FIFO (hence SOFF=0).  It appears you are looping Rx[PLAYBACK_RX_CHN] to Tx0 and the other three RX channels are just dumping to buffers.  Is that correct?

0 Kudos
1,773 Views
EdSutter
Senior Contributor II

I spent the day on this with no luck.

I see no examples that appear to use both audio channels on the WM8960 (MIMXRT1060-EVK),

so now I'm wondering if I'm trying to so something that can't be done for some reason...

All I want to do is use SAI1/EDMA to essentially loop back both audio channels on the WM8960...

Referring to teh MIMXRT1060 schematic, pg 9...

  • Board-MIC to right-headphone-speaker and HP-Mic to left-headphone-speaker. 

Am I trying to do something that for some non-obvious reason can't be done?

Ed

0 Kudos
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ed Sutter

  I will help you to check it with our SAI expert, please give me more time.

  Any updated information, will let you know.

  Please keep patient.

Best regards,

Kerry

0 Kudos
1,773 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ed Sutter

  Yes, you are right!

      DMA0->TCD[SAI_TX0_DMA_CHN].SADDR = (uint32_t)buffer[PLAYBACK_RX_CHN] + tx_buf_index * BUFFER_SIZE;

DMA0->TCD[SAI_RX0_DMA_CHN].DADDR = (uint32_t)buffer[0] + rx_buf_index * BUFFER_SIZE;
DMA0->TCD[SAI_RX1_DMA_CHN].DADDR = (uint32_t)buffer[1] + rx_buf_index * BUFFER_SIZE;
DMA0->TCD[SAI_RX2_DMA_CHN].DADDR = (uint32_t)buffer[2] + rx_buf_index * BUFFER_SIZE;
DMA0->TCD[SAI_RX3_DMA_CHN].DADDR = (uint32_t)buffer[3] + rx_buf_index * BUFFER_SIZE;

  Buffer 0 is play back to the TX0.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,773 Views
EdSutter
Senior Contributor II

Kerry,

I am still trying implement a 2-channel loopback using your code on the IMRT1060EVK.  

In the process I noticed something in your code that looks strange...

I can't test this, but it looks like SAI_RX3_DMA_CHN_IRQHandler() in the file you sent may have an error...

void SAI_RX3_DMA_CHN_IRQHandler(void)
{
 DMA0->CDNE |= DMA_CDNE_CDNE(SAI_RX0_DMA_CHN);
 DMA0->CDNE |= DMA_CDNE_CDNE(SAI_RX1_DMA_CHN);
 DMA0->CDNE |= DMA_CDNE_CDNE(SAI_RX2_DMA_CHN);
 DMA0->CDNE |= DMA_CDNE_CDNE(SAI_RX3_DMA_CHN);
 DMA0->CDNE |= DMA_CINT_CINT(SAI_RX0_DMA_CHN);     <<<<<
 DMA0->CDNE |= DMA_CINT_CINT(SAI_RX1_DMA_CHN);     <<<<<
 DMA0->CDNE |= DMA_CINT_CINT(SAI_RX2_DMA_CHN);     <<<<<
 DMA0->CINT |= DMA_CINT_CINT(SAI_RX3_DMA_CHN);

      fullBlock++;
      rx_busy = false;

 __DSB();
}

Should those final three 'CDNE' writes actually be CINT?

Ed

0 Kudos
1,773 Views
EdSutter
Senior Contributor II

Thanks Kerry!  I'm digging into this now.  Are you using this code on an iMXRT1060?

0 Kudos