Hi,
When I sent pure tone(480 Hz sine wave @ 48KHz sampling freq), it is working fine and no chopping noise in audio output. But when I send captured I2S PCM samples there is chopping noise in audio output.If it is a buffer problem then pure tone also produce chopping noise.
Today I tried to configure my tuner module as master and vybrid as slave. But I am not able to capture the audio. Below is the details. Could you please tell me how to configure vybrid as slave and all clocks will be provided by tuner module.
Pin used in primary elevator J8 Header to interface tuner module
1) pin 24: RX_DATA
2) pin 58: RX_BCLK
3) pin 59: RX_WS
modification in init_sai.c bsp file
------------------------------------------
KSAI_INIT_STRUCT _bsp_ksai_init = {
2, /* Selected peripheral (HW channel) */
0, /* TX channel */
0, /* RX channel */
I2S_TX_ASYNCHRONOUS | /* TX is asynchronous */
I2S_RX_ASYNCHRONOUS |
I2S_TX_BCLK_NORMAL | /* Both TX and RX are clocked by the transmitter */
I2S_RX_BCLK_SWAPPED,
I2S_TX_MASTER | /* SAI transmitter mode */
I2S_RX_SLAVE, /* SAI receiver mode */
16, /* Data bits */
I2S_CLK_EXT, /* Clock source */
FALSE, /* Tx Dummy */
5, /* Interrupt priority */
2048, /* Buffer size */
CM_CLOCK_SOURCE_PLL_AUDIO, /* Internal master clock source */
&_bsp_audio_data_init /* Audio init */
};
I2s init application code:
---------------------------
_mqx_int InitTunerI2S(HTUNER h)
{
TUNER* p = (TUNER*)h;
_mqx_int errcode = 0;
uint_32 mclk_freq;
_mqx_int param = 0;// temp;
char* modeString;
/* 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 */
#if BSPCFG_ENABLE_SAI
uint_8 mode = (I2S_TX_SLAVE | I2S_RX_SLAVE);
#else
uint_8 mode = I2S_MODE_MASTER;
#endif
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_SLAVE, &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)
{
printf("I2S initialised.....\r\n");
}
return (MQX_OK);
}