Using PWM through /dev/mem


I’m trying to learn how to use PWM through mmap’ing /dev/mem. I have been reading through the TI OMAP335x technical documentation and I am trying to figure out exactly how to enable the pwm clocks and how to output a PWM signal.

Are there any examples out there showing how to set up a PWM clock on the beaglebone through mmap of /dev/mem. (duty cycle, etc…)

I have been looking over pybbio to help me write some c equivalent code, but there is no PWM support in there to use as a reference.

Any advice is appreciated.


Hi Ethan,
I got below code sometime back in this group itself. I didn't find that link now. Find the link below, c code for enable PWM clock in beaglebone. It works fine for me.

How to compile it ? Does it have a Makefile ?

Awesome! Thanks for this, it really helps me out a lot.

Have a good one,

You can compile as normal c program or default Makefile also works.:slight_smile:

Ok, so it looks like this enables the clock registers. Very helpful.

However, how do I actually output the pulses to, for example, move a servo?
Do I basically write a loop while(1) that constantly looks at the current clock value in /dev/mem to figure out what value to output?

If so, how would I implement something like this in C since this would essentially be blocking. Would I multi-thread it?