Page 1 of 1

Maximum GPIO frequency from kernel space

Posted: Wed Jan 15, 2020 7:15 pm
by Genwolf
Hello,
I know that frequencies higher than 20MHz are imposible on the gpios from user space. Is that different when using the gpios from kernel space? Could I achieve higher stable frequencies for interfacing with a ADC for example?

Re: Maximum GPIO frequency from kernel space

Posted: Wed Jan 15, 2020 8:51 pm
by joan
I've seen people claim more than 20 MHz from user land.

Define stable frequency.

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 12:06 am
by HermannSW
Genwolf wrote:
Wed Jan 15, 2020 7:15 pm
I know that frequencies higher than 20MHz are imposible on the gpios from user space.
Not true, 50MHz PWM even on Pi Zero is clean, verified with 400Msps logic analyzer:
https://www.raspberrypi.org/forums/view ... 3#p1087893
Image


It was my first contact with Joan's pigpio library three years ago, especially the pigs command.
Until I last year used pigpio library a lot (C interface as well as pigs) for v1 camera global external shutter work.
I used single digit µs length (5000lm) led flashes, with pigpio waveforms:
Image

pigs command for 50MHz:
http://abyz.me.uk/rpi/pigpio/pigs.html#HP

Code: Select all

pigs hp 12 50000000 500000

125MHz is possible as well, but more than 400Msps logic analyzer (I don't have) is needed to verify cleanly:
Image

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 8:06 am
by Genwolf
joan wrote:
Wed Jan 15, 2020 8:51 pm
I've seen people claim more than 20 MHz from user land.

Define stable frequency.
The frequency at which i can read the actual states of the gpios without any interuptions for relatively long time (let's say 5 minutes).

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 8:10 am
by Genwolf
HermannSW wrote:
Thu Jan 16, 2020 12:06 am
Genwolf wrote:
Wed Jan 15, 2020 7:15 pm
I know that frequencies higher than 20MHz are imposible on the gpios from user space.
Not true, 50MHz PWM even on Pi Zero is clean, verified with 400Msps logic analyzer:
https://www.raspberrypi.org/forums/view ... 3#p1087893
Image


It was my first contact with Joan's pigpio library three years ago, especially the pigs command.
Until I last year used pigpio library a lot (C interface as well as pigs) for v1 camera global external shutter work.
I used single digit µs length (5000lm) led flashes, with pigpio waveforms:
Image

pigs command for 50MHz:
http://abyz.me.uk/rpi/pigpio/pigs.html#HP

Code: Select all

pigs hp 12 50000000 500000

125MHz is possible as well, but more than 400Msps logic analyzer (I don't have) is needed to verify cleanly:
Image
Do you know if this is true when reading the gpio as well?

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 8:35 am
by joan
The Pi has limited hardware support for regular GPIO reads. You need hardware support as software based reads will be subject to Linux jitter.

I'm not sure if DPI would work. Perhaps SPI.

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 7:04 pm
by Genwolf
joan wrote:
Thu Jan 16, 2020 8:35 am
You need hardware support as software based reads will be subject to Linux jitter.
What do you mean by hardware support ? Will there still be considerable jitter if i read the gpios from kernel (using DMA perhaps)?

Re: Maximum GPIO frequency from kernel space

Posted: Thu Jan 16, 2020 10:10 pm
by joan
I mean you need to use one of the Pi's hardware peripherals to guarantee accurate and regular timing.

DMA as used in pigpio sampling will not work faster than perhaps 2 MHz.

I don't know anything about the DPI hardware or how SPI might be used to capture such data.