2024-08-12 03:32 AM
Hello,
I am trying to configure an ADC channel using IIO library to work in triggered buffer with high frequency (preferably more than 100kHz). I configured ADC and timers as described here (including trigger configuration in kernel device tree) and tested the its performance:
https://wiki.st.com/stm32mpu/wiki/How_to_use_the_IIO_user_space_interface
Testing Method
I tested the configuration by measuring 100Hz sinusoidal signal made with a function generator at different sampling frequencies. The sampling frequency value was set to 10000Hz in iio user space as displayed in iio_info (important later):
attr 0: sampling_frequency value: 10000
The signal was measured with the iio_readdev | hexdump command and ploted on a graph
Blue is 100Hz, 1Vpp amplitude, 1V DC offset sine (ignore orange).
The sine looks good and it takes 10kHz/100Hz=100 samples to display a full sine period, so everything works correctly.
The Problem
The sampling rate was then set to 100kHz (which should be achievable) and the same 100Hz signal was measured. While setting the frequency, a weird iio_info output was observed (set frequency 100037 instead of 100000):
attr 0: sampling_frequency value: 100037
While measuring and plotting with with the iio_readdev | hexdump the iio library returned this message:
WARNING: High-speed mode not enabled
Blue is 100Hz, 1Vpp amplitude, 1V DC offset sine (ignore orange).
In the correct signal, one sine period should take 100Khz/100Hz=1000 samples. Here, it takes around 500 so it's around 50kHz. The other problem of my approach is the visible sample skipping artifacts (for example around 800th sample).
Questions
My question is how can i solve this issue? I imagine this low sample rate limit is caused by some performance bottleneck somewhere in the reading of my buffer. Is it because the iio driver isnt actually using dma to transfer samples like explained here?
https://ez.analog.com/linux-software-drivers/f/q-a/561766/warning-high-speed-mode-not-enabled
Could someone please hint me how can I enable high speed mode or increase the drivers performance? I tried to upgrade my IIO driver from 0.15 > 0.21 the issue with sample skipping was less present but the frequency limit was still there. I also tried to use the library with python wrapper with no effect. Maybe i need to upgrade of my OpenSTLinux kernel or the dma has to be configured differently in the devicetree? Thanks in advance.
Technical details
Board: Octavo Systems OSD32MP157F
100kHz iio_info:
Library version: 0.15 (git tag: 6ecff5d)
Compiled with backends: local xml ip usb
IIO context created with local backend.
Backend version: 0.15 (git tag: 6ecff5d)
Backend description string: Linux osd32mp1-brk 5.10.10 #1 SMP PREEMPT Sat Jan 23 15:04:06 UTC 2021 armv7l
IIO context has 1 attributes:
local,kernel: 5.10.10
IIO context has 9 devices:
trigger5: tim1_ch4
0 channels found:
iio:device1: 48003000.adc:adc@0 (buffer capable)
1 channels found:
voltage0: (input, index: 0, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw ERROR: Device or resource busy (-16)
attr 1: offset value: 0
attr 2: scale value: 0.044250488
2 device-specific attributes found:
attr 0: trigger_polarity value: rising-edge
attr 1: trigger_polarity_available value: rising-edge falling-edge both-edges
2 buffer-specific attributes found:
attr 0: watermark value: 1
attr 1: data_available value: 0
1 debug attributes found:
debug attr 0: direct_reg_access value: 0x1000
Current trigger: trigger1(tim1_trgo2)
trigger3: tim1_ch2
0 channels found:
trigger1: tim1_trgo2
0 channels found:
3 device-specific attributes found:
attr 0: sampling_frequency value: 100037
attr 1: master_mode value: reset
attr 2: master_mode_available value: reset enable update compare_pulse OC1REF OC2REF OC3REF OC4REF OC5REF OC6REF compare_pulse_OC4REF compare_pulse_OC6REF compare_pulse_OC4REF_r_or_OC6REF_r compare_pulse_OC4REF_r_or_OC6REF_f compare_pulse_OC5REF_r_or_OC6REF_r compare_pulse_OC5REF_r_or_OC6REF_f
iio:device2: 48003000.adc:adc@100 (buffer capable)
1 channels found:
voltage1: (input, index: 0, format: le:U16/16>>0)
3 channel-specific attributes found:
attr 0: raw ERROR: Device or resource busy (-16)
attr 1: offset value: 0
attr 2: scale value: 0.044250488
2 device-specific attributes found:
attr 0: trigger_polarity value: rising-edge
attr 1: trigger_polarity_available value: rising-edge falling-edge both-edges
2 buffer-specific attributes found:
attr 0: watermark value: 1
attr 1: data_available value: 0
1 debug attributes found:
debug attr 0: direct_reg_access value: 0x1000
Current trigger: trigger1(tim1_trgo2)
trigger4: tim1_ch3
0 channels found:
iio:device0: 44000000.timer:timer@0
1 channels found:
count0: (input)
8 channel-specific attributes found:
attr 0: enable_mode value: always
attr 1: preset value: 2087
attr 2: trigger_mode ERROR: Invalid argument (-22)
attr 3: en value: 1
attr 4: raw value: 11
attr 5: scale value: 1.000000000
attr 6: trigger_mode_available value: trigger
attr 7: enable_mode_available value: always gated triggered
trigger2: tim1_ch1
0 channels found:
trigger0: tim1_trgo
0 channels found:
3 device-specific attributes found:
attr 0: sampling_frequency value: 100037
attr 1: master_mode value: update
attr 2: master_mode_available value: reset enable update compare_pulse OC1REF OC2REF OC3REF OC4REF
I also attached my device tree
2024-08-23 02:29 AM
Hi @jromanki
Since you are using Octavo Systems OSD32MP157F did you already try to contact Octavo support ?
Thanks
Olivier
2024-08-23 03:41 AM
Hello Oliver,
Yes, I have contacted Octavo Systems with the exact same problem, however i am waiting for their response
Best Regards,
Jakub