Post Go back to editing

Error -22 writing to channel "sampling_frequency" value may not be supported.

Hello,

I have used two examples https://github.com/analogdevicesinc/libad9361-iio/blob/master/ad9361_baseband_auto_rate.c and https://github.com/analogdevicesinc/libiio/blob/master/examples/ad9361-iiostream.c to load custom FIR and get samples with lowest sampling rate. My FIR config with taps from Matlab ADI Wizard is:

RX 3 GAIN -12 DEC 4 TX 3 GAIN -12 INT 4 RRX 800000000 25000000 8333333 4166666 2083333 520833 RTX 800000000 25000000 8333333 4166666 2083333 520833 BWRX 433256 BWTX 433256 114,114 -98,-98 157,157 -154,-154 -23,-23 -330,-330 -346,-346 -619,-619 -656,-656 -791,-791 -692,-692 -598,-598 -315,-315 -59,-59 257,257 440,440 542,542 443,443 239,239 -85,-85 -378,-378 -605,-605 -637,-637 -491,-491 -156,-156 245,245 625,625 830,830 803,803 502,502 17,17 -538,-538 -971,-971 -1147,-1147 -962,-962 -451,-451 273,273 987,987 1470,1470 1525,1525 1092,1092 241,241 -792,-792 -1704,-1704 -2172,-2172 -1990,-1990 -1118,-1118 250,250 1749,1749 2901,2901 3276,3276 2610,2610 932,932 -1410,-1410 -3790,-3790 -5440,-5440 -5628,-5628 -3869,-3869 -64,-64 5417,5417 11790,11790 17991,17991 22911,22911 25630,25630 25630,25630 22911,22911 17991,17991 11790,11790 5417,5417 -64,-64 -3869,-3869 -5628,-5628 -5440,-5440 -3790,-3790 -1410,-1410 932,932 2610,2610 3276,3276 2901,2901 1749,1749 250,250 -1118,-1118 -1990,-1990 -2172,-2172 -1704,-1704 -792,-792 241,241 1092,1092 1525,1525 1470,1470 987,987 273,273 -451,-451 -962,-962 -1147,-1147 -971,-971 -538,-538 17,17 502,502 803,803 830,830 625,625 245,245 -156,-156 -491,-491 -637,-637 -605,-605 -378,-378 -85,-85 239,239 443,443 542,542 440,440 257,257 -59,-59 -315,-315 -598,-598 -692,-692 -791,-791 -656,-656 -619,-619 -346,-346 -330,-330 -23,-23 -154,-154 157,157 -98,-98 114,114

The config loads just fine, I can see filter enabled and all settings as expected in:

root@analog:/sys/bus/iio/devices/iio:device2# cat in_voltage_sampling_frequency

520833

BUT: setting channel sampling frequency fails:

ret = iio_channel_attr_write_longlong(chan, "sampling_frequency", rate);

if (ret < 0) { printf("* Can't write sampling frequency: %d.\n", ret); return ret;

}

results in:

* Can't write sampling frequency: -22.

or:

// Configure phy and lo channels printf("* Acquiring AD9361 phy channel %d\n", chid);

if (!get_phy_chan(ctx, type, chid, &chn)) { return false; }

wr_ch_str(chn, "rf_port_select", cfg->rfport);

wr_ch_lli(chn, "rf_bandwidth", cfg->bw_hz);

wr_ch_lli(chn, "sampling_frequency", cfg->fs_hz);

in:

Error -22 writing to channel "sampling_frequency" value may not be supported.

What I am missing ?  Thanks !



Added second code example.
[edited by: MichalM at 11:02 PM (GMT 0) on 9 Mar 2020]
Parents
  • Loading the filter files generated from MATLAB will update the sample rate automatically. So you don't need to do this again.

    Also, to achieve certain rates you need to have a certain FIR loaded. It's not clear from your code snippets what you are doing before trying to set sample rate.

    -Travis

  • Hi Travis,

    I am loading the configuration of FIR as above using:

    ret = iio_device_attr_write_raw(dev, "filter_fir_config", buf, len);

    which is successful.

    The issue is that if I comment out rate settings or channel then 

    nbytes_rx = iio_buffer_refill(rxbuf);

    fails with:

    Error refilling buf -110

    This was working fine without filter.

  • Can you provide the filter file?

    -Travis

  • RX 3 GAIN -12 DEC 4
    TX 3 GAIN -12 INT 4
    RRX 800000000 25000000 8333333 4166666 2083333 520833
    RTX 800000000 25000000 8333333 4166666 2083333 520833
    BWRX 433256
    BWTX 433256
    114,114
    -98,-98
    157,157
    -154,-154
    -23,-23
    -330,-330
    -346,-346
    -619,-619
    -656,-656
    -791,-791
    -692,-692
    -598,-598
    -315,-315
    -59,-59
    257,257
    440,440
    542,542
    443,443
    239,239
    -85,-85
    -378,-378
    -605,-605
    -637,-637
    -491,-491
    -156,-156
    245,245
    625,625
    830,830
    803,803
    502,502
    17,17
    -538,-538
    -971,-971
    -1147,-1147
    -962,-962
    -451,-451
    273,273
    987,987
    1470,1470
    1525,1525
    1092,1092
    241,241
    -792,-792
    -1704,-1704
    -2172,-2172
    -1990,-1990
    -1118,-1118
    250,250
    1749,1749
    2901,2901
    3276,3276
    2610,2610
    932,932
    -1410,-1410
    -3790,-3790
    -5440,-5440
    -5628,-5628
    -3869,-3869
    -64,-64
    5417,5417
    11790,11790
    17991,17991
    22911,22911
    25630,25630
    25630,25630
    22911,22911
    17991,17991
    11790,11790
    5417,5417
    -64,-64
    -3869,-3869
    -5628,-5628
    -5440,-5440
    -3790,-3790
    -1410,-1410
    932,932
    2610,2610
    3276,3276
    2901,2901
    1749,1749
    250,250
    -1118,-1118
    -1990,-1990
    -2172,-2172
    -1704,-1704
    -792,-792
    241,241
    1092,1092
    1525,1525
    1470,1470
    987,987
    273,273
    -451,-451
    -962,-962
    -1147,-1147
    -971,-971
    -538,-538
    17,17
    502,502
    803,803
    830,830
    625,625
    245,245
    -156,-156
    -491,-491
    -637,-637
    -605,-605
    -378,-378
    -85,-85
    239,239
    443,443
    542,542
    440,440
    257,257
    -59,-59
    -315,-315
    -598,-598
    -692,-692
    -791,-791
    -656,-656
    -619,-619
    -346,-346
    -330,-330
    -23,-23
    -154,-154
    157,157
    -98,-98
    114,114

    uploaded

  • For some reason ADI Wizard do not allow me to save FIR file, I can only export to Matlab workspace.

  • Did you design TX and RX? Both must be designed before export is possible.

    -Travis

  • This is very good point ! I just wanted RX, but it seems I need both ? Also the example was saying it is better to enable both directions. Let me try it.

Reply Children
No Data