Faster GPIO on XU4

Post Reply
sgjava
Posts: 78
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 4 times
Contact:

Faster GPIO on XU4

Post by sgjava »

I'm working on a light weight cross platform IO library for Java called Java Periphery https://github.com/sgjava/java-periphery which can use MMIO for GPIO updating registers directly instead of using GPIO device or deprecated sysfs interface. Using GPIO device I get 44 KHz (square wave) and using MMIO I get 300 KHz. I've seen where people have said you can get 2-3 MHz, but I've not seen that. Also, I'm only using a single core. With my Allwinner boards I get 2+ MHz on a single core using same exact code.

User avatar
odroid
Site Admin
Posts: 40798
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3089 times
Been thanked: 1703 times
Contact:

Re: Faster GPIO on XU4

Post by odroid »

Try our wiringpi library to narrow down root causes.
https://wiki.odroid.com/odroid-xu4/appl ... o/wiringpi

sgjava
Posts: 78
Joined: Mon Dec 29, 2014 7:47 am
languages_spoken: english
ODROIDs: C1, C1+, C2, XU4
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Faster GPIO on XU4

Post by sgjava »

It's an apples and oranges kind of thing. Firstly, I'm running Armbian with a 5.4.x kernel. Secondly, I'm trying to stay away from deprecated interfaces such as sysfs and wiringPi (although I did look at the wiringPi XU3/XU4 code). I'm using /dev/mem and register mappings to keep my MMIO code board cross platform. I see there's /dev/gpiomem, so I'm going to test this since it should be a bit safer than /dev/mem.

LikeSmith
Posts: 9
Joined: Tue May 06, 2014 8:03 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 2 times
Been thanked: 2 times
Contact:

Re: Faster GPIO on XU4

Post by LikeSmith »

Looks like I'm a little late to the party, but I'm currently setting up servo signals with my XU4 using C and the memory mapped gpio registers. I've been able to get somewhat reasonably accurate timings using bitbanging with an thread running real time. Still not as good as what I could get off a microcontroller, but much better than what I get without the RT!

User avatar
mctom
Posts: 2735
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 366 times
Been thanked: 479 times
Contact:

Re: Faster GPIO on XU4

Post by mctom »

LikeSmith wrote:
Sun Feb 19, 2023 2:37 pm
Looks like I'm a little late to the party, but I'm currently setting up servo signals with my XU4 using C and the memory mapped gpio registers. I've been able to get somewhat reasonably accurate timings using bitbanging with an thread running real time. Still not as good as what I could get off a microcontroller, but much better than what I get without the RT!
I had the same problems with my pistackmon projects, where I bitbanged serial data to emulate PWM on 16 LEDs. It worked quite well with C++ sleep_until, and incrementing the target time by fixed amount on each cycle. It was more stable than a comparable sleep_for.
I'm taking about 50us resolution here, so as you said, not comparable to microcontroller performance at all. :)
These users thanked the author mctom for the post:
LikeSmith (Mon Feb 20, 2023 1:15 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

Post Reply

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests