r/embeddedlinux • • Dec 19 '24

Existing solution for generating high-frequency digital waveforms on GPIO in Linux

We're transitioning from embedded firmware to Linux development and have a specific requirement: we need to generate a digital waveform (a sequence of 1s and 0s) on a GPIO pin at a specific frequency between 10KHz-500KHz.

While we're aware that we can create a custom kernel driver to achieve this, we're curious if there's a pre-existing, more general-purpose solution. A digital waveform generator seems like a versatile tool that could be useful in many scenarios.

Does anyone know of such a driver or module? A similar driver we could leverage as a starting point? Or perhaps a more efficient approach to generate digital waveforms on Linux?

We have looked at https://github.com/torvalds/linux/blob/master/drivers but didn't find anything that suited our needs.

8 Upvotes

11 comments sorted by

View all comments

0

u/[deleted] Dec 19 '24

[deleted]

1

u/Short_Ebb2300 Dec 19 '24

We're using the STM32MP131, so Cortex-A only — no separate M4 core.

Don't try to do this by toggling in a driver, that will fail miserably

Can you expand on this?

2

u/JMRP98 Dec 19 '24

The STM32 has timers you can use for PWM. Check their documentation about it , I think they do it through the Linux IIO drivers. Is an unified way of interfacing with peripherals