Post Go back to editing

no-os sample code to synchronize AD9361 chips on a FMComms5 board

I am using a FMComms5 board with a Xilinx ZC702 FPGA board in a beamforming application. The application is bare metal (no-os) that uses ad9361.c, ad9361.h, ad9361_api.c, ad9361_api.h and the other .c and .h files that make up the AD9361 no-os library which was downloaded from github. I am able to operate both AD9361 chips successfully and everything seems to work fine.

I am attempting to synchronize the received signals from both AD9361 chips as described here wiki.analog.com/.../multi-chip-sync
This page provides sample code to synchronize the chips on the FMComms5 board github.com/.../fmcomms2_adv.c

The example code has a function called trx_phase_rotation(struct iio_device *dev, gdouble val); which computes the phase rotation needed to synchronize the two AD9361's and then sets the phase rotation by calling iio_channel_attr_write_double(out0, "calibscale", (double) vcos); and iio_channel_attr_write_double(out0, "calibphase", (double) (-1.0 * vsin));

The example code looks like it was built to run on linux with these functions calling into the IIO driver. My application is a bare metal (no os) with no IIO driver and no Linux operating system.
I have been trying to find out exactly what iio_channel_attr_write_double() actually does when called with the parameters "calibscale" and "calibphase", but I have not been able to find it anywhere in any of the example C code on the ADI web site.
The function must write the desired phase angle somwehere, but where? Does this function write to the AD9361 chip over the SPI port or does it write to the axi_ad9361 component in the Vivado FPGA design (also downloaded from github and successfully built).
Can you provide information on exactly what iio_channel_attr_write_double() does, and what register addresses "calibphase" and "calibscale" map to? Do you have source code for this function?
I have searched the AD9361 datasheet, the AD9361 Register Map (UG671), the AD9361 Reference Manual (UG570), ad9361_api.h and ad9361.h for a clue but have not been able to find anything.

Any information you can provide would be most appreciated.

Thread Notes

Top Replies

    •  Analog Employees 
    Sep 29, 2020 +1 verified

    Hi ,

    That example code is an IIO client application running on PC.

    At some point it issues that iio_channel_attr_write_double() call and writes to "calibphase" and "calibscale" IIO channel attributes…