I2s capture in vybrid is noisy

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

I2s capture in vybrid is noisy

ソリューションへジャンプ
8,937件の閲覧回数
abdulnihad
Contributor III

I want to capture audio using I2S protocol. I have connected my audio slave device to SAI2 of vybrid. I have configured vybrid as master and my audio device as slave.

We have configured vybid I2S as master Receiver and tuner I2S as slave transmitter. Here it is clear that we have to use vybrid receive channel. But according to vybrid reference manual I2S_RX_BCLK(Pin#58) and I2S_RX_SYNC (Pin#59) are bi-directional So vybrid master will provide all the clock signal for tuner through its I2S_RX_xx pins and vybrid receive PCM samples through its I2S_RX_DATA. But this configuration is not working and not able to get audio . But When I used SAI2_TX clock signals it worked. According to demo setup we are using SAI2_TX_BCLK (Y5) ,  SAI2_RX_WS (U6) , SAI2_RX_DATA (E17). But captured audio is noisy. How to fix this issue. I am pasting snaps of my initialization code here.

#define DEFAULT_SAMPLE_RATE_HZ   48000
#define DEFAULT_NUM_CHANNELS     2
#define DEFAULT_BITS_PER_SAMPLE  16
#define SAMPLE_SIZE_IN_BYTE     DEFAULT_BITS_PER_SAMPLE/8

_mqx_int InitTunerI2S(HTUNER h)

{

    TUNER* p = (TUNER*)h;

    _mqx_int     errcode = 0;

    uint_32        mclk_freq;

   // _mqx_int    param, temp;

    /* Prepare audio format struct */

    p->audio_format.ENDIAN         = AUDIO_LITTLE_ENDIAN;

    p->audio_format.ALIGNMENT     = AUDIO_ALIGNMENT_LEFT;

    p->audio_format.BITS         = DEFAULT_BITS_PER_SAMPLE;

    p->audio_format.SIZE         = SAMPLE_SIZE_IN_BYTE;

    p->audio_format.CHANNELS     = DEFAULT_NUM_CHANNELS;

    p->audioSamplingFreq         = DEFAULT_SAMPLE_RATE_HZ;

    mclk_freq = p->audioSamplingFreq * CLK_MULT;  /* Set master clock frequency so oversampling = 384 */

   uint_8 mode = I2S_MODE_MASTER;

    p->tunerI2S_fd = fopen(AUDIO_DEVICE, "r");

    if (p->tunerI2S_fd == NULL)

    {

        printf("\n  InitTunerI2S error: Unable to open audio device.\r\n");

        return(0xDEAD);

    }

    /* Setup device */

    if (ioctl(p->tunerI2S_fd, IO_IOCTL_AUDIO_SET_IO_DATA_FORMAT, &(p->audio_format)) != I2S_OK)

    {

        printf("  Error: Input data format not supported.\n");

        fclose(p->tunerI2S_fd);

        return (MQX_ERROR);

    }

    if(I2S_OK != ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_SET_DATA_BITS, &(p->audio_format.BITS)))

        errcode = -1;

    if(I2S_OK != ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_SET_MODE_MASTER, &mode))

        errcode = -1;

    if(I2S_OK != ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_SET_MCLK_FREQ, &mclk_freq))

        errcode = -1;

    if(I2S_OK != ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_SET_FS_FREQ, &p->audioSamplingFreq))

        errcode = -1;

    _time_delay(50);

    if(errcode != -1)

    {

        ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_GET_FS_FREQ, &p->audioSamplingFreq);

        ioctl(p->tunerI2S_fd, IO_IOCTL_I2S_GET_BCLK_FREQ, &p->audioBitClkFreq);

        printf("I2S Settings:\r\n");

        printf("  Sampling frequency:     %d Hz\r\n", p->audioSamplingFreq);

        printf("  Bit depth:              %d bits\r\n", p->audio_format.BITS);

        printf("  Bit rate :              %d bits/sec\r\n", p->audioBitClkFreq);

        printf("  Channels:               ");

        if (p->audio_format.CHANNELS == 1)

        {

          printf("mono\n");

        }

        else

        {

            printf("stereo\n");

        }

        printf("I2S initialised.....\r\n");

    }

    return (MQX_OK);

}

ラベル(4)
0 件の賞賛
返信
1 解決策
7,117件の閲覧回数
juangutierrez
NXP Employee
NXP Employee

SAI and eSAI driver has been added in MQX 4.1.0 which is expected to be released during Februrary.

元の投稿で解決策を見る

0 件の賞賛
返信
29 返答(返信)
1,784件の閲覧回数
abdulnihad
Contributor III

Hi,

Any hope to get help on this issue?

BR/-

Nihad

0 件の賞賛
返信
1,784件の閲覧回数
abdulnihad
Contributor III

Hi,

Is there any issue with vybrid Sai dma driver?. Does the latest MQX 4.1 support vybrid sai audio driver. Does the clk and dma driver configured properly for sai dma driver? any chance to get support on audio issue.

I found one issue with interrupt based sai driver in MQX 4.1. In _vi2s_set_mclk_freq function all the audio mclk frequencies CPU_PLL_AUDIO_CLK_HZ_x included in bsp_cm.h  is not considered. for example

in MQX 4.0.2 CPU_PLL_AUDIO_CLK_HZ_0 is 846720000UL 

But in MQX 4.1 CPU_PLL_AUDIO_CLK_HZ_0 is 423360000UL

due to this bit clk calculation for sampling frequency 44100 Hz is wrong.

BR/-

Nihad

0 件の賞賛
返信
1,784件の閲覧回数
juangutierrez
NXP Employee
NXP Employee

Does the sample for SAI, provided by MQX run as expected?

0 件の賞賛
返信
1,784件の閲覧回数
abdulnihad
Contributor III

Hi,

PCM samples captured while using sai dma driver is already posted on Mar 10th post. Its not proper.

sai int driver is also not giving as expected.

In MQX 4.1 release note page number 14 shows that sai driver is not supported on vybrid but in page 8 what is new section shows dma driver supported on vybrid. Has this driver validated?.

Are you considering little endian and big endian data format in sai dma driver?.

BR/-

nihad

0 件の賞賛
返信
1,784件の閲覧回数
juangutierrez
NXP Employee
NXP Employee

The support for audio-related drivers (SAI, eSAI and ASRC) was added in 4.1 for Vybrid as stated in page 8 of Release Notes.

New DMA driver should have been validated before release.

It seems they forgot to update Table in page 14 but support was added for SAI.

Try to run the sai_dma_demo in the mqx samples, this should run as expected.

Use this sample as reference.

0 件の賞賛
返信
1,784件の閲覧回数
abdulnihad
Contributor III

Hi,

I dont have freescale audio peripheral board to test the audio demo application. I written my application based on sai_dma_demo code. I am directly using our custom vybrid platform. Audio is coming out with slight choppy effect when I use sai_int_ksai driver. But when I use sai_dma_ksai driver only heavy noise is coming out. I want to fix the choppy effect. I think it will get fixed if I use sai_dma_driver. But dma driver output only noise here.

BR/-

Nihad

0 件の賞賛
返信
1,787件の閲覧回数
haku_sato
NXP Employee
NXP Employee

Hi Nihad,

Thank you so much for the details.  Your explanation is very helpful. 

From your explanation, the issue now seem to be MQX related than the actual setting of the IP blocks.  Since my expertise is in HW systems, I need to loop in a person who is well versed in MQX specifics. 

Thanks for your patience!

Haku

karinavalencia

0 件の賞賛
返信
1,787件の閲覧回数
karina_valencia
NXP Apps Support
NXP Apps Support

juangutierrez  please continue with   the follow up.

0 件の賞賛
返信
1,787件の閲覧回数
RossMcLuckie
NXP Employee
NXP Employee

Abdul,

The reason for the questions is to try better understand your set up and help you debug, without answers that makes things harder. The issue here will be with your set up, we have another hardware platform using Vybrid in an automotive set up with a SiLabs tuner that is working perfectly, so without additonal information that is the only reference we have to go on. What is likely here is the tuner module set up and Vybrid settings don't match, looking at one side of these settings may offer much help, the SAI can be configured in many ways.

For instance you state when using RX clocks nothing is working, but when using TX clocks things work, that is down to how you set up the SAI itself, in synchronous mode the RX and TX sections use the same set of clocks, from the TX side, independent clocks for RX ad TX can be used in asynchronous mode, so this is the sort of thing you should be aware of.

I assume your tuner module, which we have no experience of or support, uses something like an I2C interface to set up it's parameters, if so what have you done there, these settings will determine data width, MSB or LSB aligned, formats, etc, this has to match with what Vybrid is set up to receive, so that's what you need to be looking for here.

Have you looked at the signals on an oscilloscope, do they look clean and as expected or do you see any signs of distortion or problems that could related to the way you have things connected together?

How are you supplying the power to the TWR module and the tuner, are your ground references correct, etc.

From a hardware perspective you have to check signal connections and intergrity to see if anything is not as expected.

From a software perspective you need to review how you are clocking the system, is this as you require, do you understand how the module is clocked, asynchronous/synchrounous operation, are the clocks generated as you expect, does the tuner and SAI module configuration match, have you confirmed this?

This is a well known and tested configuration for Vybrid so the issue will almost certainly be in your current set up.

Ross