AnsweredAssumed Answered

Phase shifted data obtained from ad1836

Question asked by spaceboy on Jun 1, 2011
Latest reply on Jul 28, 2011 by spaceboy
Hello,
I am working on dual-core single application (choose from project wizard), based on example project Audio Codec Talkthrough - TDM (C).
The main purpose of the program is to localize sound source using 4 microphones plugged in RCA connectors of my EZ-LITE kit.
My problem is to make my system "real-time", because the data I receive from ad1836 seems to be incorrect.
CoreA firstly sets up the interrupts and then it puts data received from iRxBuffer1 to the 4 FRAME_SIZE buffers in Process_Data(). Still in Process_Data() it checks if the buffers are full and if so, the global variable located in shared memory tells CoreB that it can copy prepared buffers and do further processing.
I am aware of SPI anomaly mentioned in http://www.analog.com/static/imported-files/application_notes/504555030370765719AN_AD1836_21161.pdf but I do not know if it is still relevant(ADC_control registers are sent once in demo talkthrough project). I also know about shifting obtained data 8 bits to the left.
The "weird data" I was talking about is presented on the attached screen, I don't know why buffers from different channel (left channel0 and left channel1) are not the same, instead they are shifted and scaled. The input signal is a sine wave.
The ad1836 settings:
volatile short sCodec1836TxRegs[CODEC_1836_REGS_LENGTH] =
{                                                                 DAC_CONTROL_1     | 0x000,
DAC_CONTROL_2     | 0x000,
DAC_VOLUME_0     | 0x3ff,
DAC_VOLUME_1     | 0x3ff,
DAC_VOLUME_2     | 0x3ff,
DAC_VOLUME_3     | 0x3ff,
DAC_VOLUME_4     | 0x3ff,
DAC_VOLUME_5     | 0x3ff,
ADC_CONTROL_1     | 0x000,
ADC_CONTROL_2     | 0x180,
ADC_CONTROL_3     | 0x000
};
Function called from interrupt(when packed audio frame has arrived):
volatile int i = 0; // Internal counter
volatile int buffer_switch = 0;
void Process_Data(void)
{
if(buffer_switch == 0)
{
//adi_try_lock(sem0);
mic1A[i] = iChannel0LeftIn;
mic2A[i] = iChannel0RightIn;
mic3A[i] = iChannel1LeftIn;
mic4A[i] = iChannel1RightIn;
//ssync();
i++;
}
else // buffer_switch == 1
{
mic1B[i] = iChannel0LeftIn;
mic2B[i] = iChannel0RightIn;
mic3B[i] = iChannel1LeftIn;
mic4B[i] = iChannel1RightIn;
//ssync();
i++;
}
if(i == (FFT_SIZE - 1))
{
if(buffer_switch == 0)
{
ssync();
sem0 = 1;
}
else // buffor_switch == 1
{
ssync();
sem1 = 1;
}
buffer_switch = !buffer_switch;
i = 0;
}
}

Best regards.

 

Message was edited by: spaceboy

Attachments

Outcomes