AnsweredAssumed Answered

libiio tx channel disable

Question asked by rrogers on Feb 26, 2015
Latest reply on Mar 9, 2015 by rgetz

Hello,

 

I have a matlab script (attached) to generate iq data files for a single tx channel of the fmcomms3 for a CW tone at a given frequency offset.  The output spectrum shows the main frequency component at half the expected frequency (ie, for a 25KHz offset file, the spectral peak will be at 12.5KHz).  I'm guessing this is due to the tx iio buffer expecting interleaved samples for both TX1 and TX2.  I am currently reading the file data directly into the iio tx buffer.  How do I disable TX2 such that the iio buffer will handle the only TX1 data? 

 

Below is a snippet of the setup code (copied from the iio stream example); my attempt to disable tx2 below is unsuccessful.

 

int fmc_ifc_init_dev( fmc_iodev_e dev, fmc_stream_cfg *cfg )

{

  struct iio_device **dev_ptr;

  struct iio_channel *i_ch, *q_ch;

  char dev_str[8];

  struct timespec dbg_ts;

  int ret;

 

 

// dbg_printf("%s() - enter\n", __FUNCTION__);

 

  dbg_timer( DBG_TIMER_START, &dbg_ts, NULL );

 

 

  switch ( dev )

  {

  case FMC_TX:

  dev_ptr = &tx;

  i_ch = tx0_i;

  q_ch = tx0_q;

  sprintf( dev_str, "TX" );

  break;

 

 

  case FMC_RX:

  dev_ptr = ℞

  i_ch = rx0_i;

  q_ch = rx0_q;

  sprintf( dev_str, "RX" );

  break;

 

 

  default:

  break;

  }

 

 

  printfl("\t* Acquiring AD9361 %s streaming device\n", dev_str );

  if ( !get_ad9361_stream_dev(ctx, dev, dev_ptr) )

  {

  printfe("%s() - No %s dev found\n", __FUNCTION__, dev_str);

  return -1;

  }

 

 

  printfl("\t* Configuring AD9361 for %s streaming\n", dev_str );

  if ( !cfg_ad9361_streaming_ch(ctx, cfg, dev, 0) )

  {

  printfe("%s() - port %s_0 not found\n", __FUNCTION__, dev_str);

  return -1;

  }

 

 

  printfl("\t* Disabling AD9361 IIO %s streaming channels\n", dev_str);

  if ( !get_ad9361_stream_ch(ctx, dev, *dev_ptr, 1, &i_ch) )

  {

  printfe("%s() - chan %s_i not found\n", __FUNCTION__, dev_str);

  return -1;

  }

  if ( !get_ad9361_stream_ch(ctx, dev, *dev_ptr, 1, &q_ch) )

  {

  printfe("%s() - chan %s_q not found\n", __FUNCTION__, dev_str);

  return -1;

  }

  iio_channel_disable( i_ch );

  iio_channel_disable( q_ch );

 

 

 

  printfl("\t* Initializing AD9361 IIO %s streaming channels\n", dev_str);

  if ( !get_ad9361_stream_ch(ctx, dev, *dev_ptr, 0, &i_ch) )

  {

  printfe("%s() - chan %s_i not found\n", __FUNCTION__, dev_str);

  return -1;

  }

  if ( !get_ad9361_stream_ch(ctx, dev, *dev_ptr, 0, &q_ch) )

  {

  printfe("%s() - chan %s_q not found\n", __FUNCTION__, dev_str);

  return -1;

  }

 

 

  iio_channel_enable( i_ch );

  iio_channel_enable( q_ch );

 

 

  /* Clear all status bits */

  ret = iio_device_reg_write( *dev_ptr, 0x80000088, 0x6 );

  if ( ret )

  {

  printfe("%s() - reg_write ERR: %d, %s\n", __FUNCTION__,

  ret, strerror(-ret));

  }

 

 

  dbg_timer( DBG_TIMER_STOP, &dbg_ts, "AD9361 Cfg" );

 

 

  return 0;

}

Attachments

Outcomes