AD9361 No-OS I and Q sample printing to console


I am currently implementing a console command called stream_block_rx_data(), which uses adc_capture() and console_print() to send the samples to the PC.  I currently have the transmitter connected directly to the receiver so I am just looping a tone back into the receiver.  I have set the RX_LO and TX_LO to the same frequency (200MHz) and I would expect to see a very stable value for I and Q.  What I see is no value for Q, and noisy values for I.  I am curious as to whether I am even reading the samples from DMA correctly.  Please see my code below:

uint16_t length = param[0];

uint16_t h_length = length/2;

uint16_t data;
uint16_t sample_Q1[h_length];
uint16_t sample_I1[h_length];
uint16_t sample_Q2[h_length];
uint16_t sample_I2[h_length];

uint32_t n;

Xil_DCacheInvalidateRange(ADC_DDR_BASEADDR,h_length * 8);
adc_capture(h_length, ADC_DDR_BASEADDR);

for (n =0;n<length;n+=2)

data = Xil_In32((ADC_DDR_BASEADDR+(n*4)));
sample_Q1[n/2]=(data & 0xFFFF);
sample_I1[n/2]=(data >> 16) & 0xFFFF;
data = Xil_In32(ADC_DDR_BASEADDR +((n+1)*4));
sample_Q2[n/2]=(data & 0xFFFF);
sample_I2[n/2]=(data >> 16) & 0xFFFF;

console_print("%d, %d, \r",sample_Q1[n/2], sample_I1[n/2]);


Is there a test I can do to check if I am reading the IQ samples correctly?  i.e. a known configuration with known IQ results that I can read from memory and plot to verify?



  • UPDATE:  

    1. I wasn't using Invalidate cache correctly.  Now that I have placed it directly after the adc_capture() call, I can correctly receive known I and Q samples in my console.  My apologies, simple mistake!

    2. I would like to know why my I and Q samples do not match my RSSI results however.  I have plotted 3 images as shown below, the first is the RSSI, which shows that I detected two targets.  This is what I expect to see and it is great I can see this using RSSI.  However If you have a look at the Magnitude (plot 2) and Phase (plot 3) plots which I generated from the I and Q samples, there are no visible targets.  

    I generated the magnitude and phase by post processing in python using the following identities:

    Magnitude = SQRT((I^2)+(Q^2))

    Phase = atan(Q/I)

    The I and Q samples are being generated by setting the TX and RX LO frequencies to be the same and by setting the DDS tone frequencies to 0. The LO frequency is then being swept and at each point of the sweep, a measurement is taken. Is the issue to do with the fact that I am not setting any DDS tone frequency?